fix: resolve DXF %%x codes and render MText decoration strokes
Text/MText values now correctly handle DXF special-character sequences: - %%d → °, %%p → ±, %%c → ⌀, %%nnn → Unicode scalar (resolved in tessellation) - %%u / %%o toggle underline and overline strokes for TEXT entities MText decoration codes (\L/\l, \O/\o, \K/\k) were previously consumed as argument-bearing codes, silently eating the decorated text. Fixed strip_mtext_codes to keep them as zero-width markers; tessellate_text_ex now emits actual line strokes (underline, overline, strikethrough). measure_mtext_chars and word_wrap skip markers so line widths are correct. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
089612584d
commit
4504916f97
4 changed files with 222 additions and 37 deletions
|
|
@ -3,7 +3,7 @@ use glam::Vec3;
|
|||
|
||||
use crate::command::EntityTransform;
|
||||
use crate::entities::common::{edit_prop as edit, parse_f64, square_grip};
|
||||
use crate::entities::text_support::{resolve_text_style, text_local_bounds};
|
||||
use crate::entities::text_support::{resolve_dxf_special_chars, resolve_text_style, text_local_bounds};
|
||||
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, TruckConvertible};
|
||||
use crate::scene::acad_to_truck::{TruckEntity, TruckObject};
|
||||
use crate::scene::cxf;
|
||||
|
|
@ -71,9 +71,11 @@ fn to_truck(t: &Text, document: &acadrust::CadDocument) -> TruckEntity {
|
|||
(_, VA::Bottom | VA::Middle | VA::Top, Some(a)) => [a.x as f32, a.y as f32],
|
||||
_ => [t.insertion_point.x as f32, t.insertion_point.y as f32],
|
||||
};
|
||||
// Strip %%u/%%o for bounds (they add no width); resolve %%d/%%c/%%p for correct advance.
|
||||
let value_for_bounds = resolve_dxf_special_chars(&t.value);
|
||||
let bounds = text_local_bounds(
|
||||
&font_name,
|
||||
&t.value,
|
||||
&value_for_bounds,
|
||||
t.height as f32,
|
||||
width_factor,
|
||||
oblique_angle,
|
||||
|
|
@ -99,6 +101,7 @@ fn to_truck(t: &Text, document: &acadrust::CadDocument) -> TruckEntity {
|
|||
anchor[0] - (anchor_local_x * cos_r - anchor_local_y * sin_r),
|
||||
anchor[1] - (anchor_local_x * sin_r + anchor_local_y * cos_r),
|
||||
];
|
||||
// Pass raw value — tessellate_text_ex resolves %%x codes and emits decoration strokes.
|
||||
let strokes_2d = cxf::tessellate_text_ex(
|
||||
origin,
|
||||
t.height as f32,
|
||||
|
|
|
|||
Loading…
Reference in a new issue