forked from 1b-agent/opencadstudio-upstream
refactor(text): parse single-line ATTRIB text via acadrust
Route single-line attribute text through the same acad_text_encode path TEXT uses (acadrust parse_plain_text, re-encoded for the stroke tessellator). Multi-line attributes already flow through layout_mtext (acadrust). No visible change — attribute text with %% codes rendered correctly before via the local tokenizer; this shares the one parser. TOLERANCE cells and complex-linetype text still use the local tokenizer (specialized paths that rarely carry %% codes). Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
a561b088d2
commit
1709d41e4f
2 files changed
+5
-2
No files matched your search
@@ -278,6 +278,9 @@ fn build_attr_truck(input: AttrTextInputs<'_>, document: &acadrust::CadDocument)
|
||||
anchor_f64[0] - (anchor_local_x as f64 * cos_r - local_y_for_line as f64 * sin_r),
|
||||
anchor_f64[1] - (anchor_local_x as f64 * sin_r + local_y_for_line as f64 * cos_r),
|
||||
];
|
||||
// Parse `%%` codes through acadrust (same as TEXT), re-encoded for the
|
||||
// stroke tessellator, so attribute text shares the one parser.
|
||||
let encoded = crate::entities::text::acad_text_encode(line);
|
||||
let (strokes, fill_tris) = lff::tessellate_text_ex(
|
||||
[0.0, 0.0],
|
||||
input.height as f32,
|
||||
@@ -285,7 +288,7 @@ fn build_attr_truck(input: AttrTextInputs<'_>, document: &acadrust::CadDocument)
|
||||
width_factor,
|
||||
oblique_angle,
|
||||
&resolved.font_name,
|
||||
line,
|
||||
&encoded,
|
||||
);
|
||||
strokes_all.push(TextStroke {
|
||||
strokes,
|
||||
|
||||
@@ -71,7 +71,7 @@ pub struct TextPlacement {
|
||||
/// inline grammar: specials arrive resolved to Unicode, and `%%u`/`%%o`
|
||||
/// underline/overline become `\L…\l` / `\O…\o` decoration markers. This keeps
|
||||
/// TEXT parsing in acadrust rather than OCS's own tokenizer.
|
||||
fn acad_text_encode(value: &str) -> String {
|
||||
pub(crate) fn acad_text_encode(value: &str) -> String {
|
||||
use acadrust::entities::mtext_format::parse_plain_text;
|
||||
let doc = parse_plain_text(value);
|
||||
let mut out = String::new();
|
||||
|
||||
Reference in new issue
Block a user