forked from 1b-agent/opencadstudio-upstream
fix(mtext): render font italic flag and non-breaking space
Complete the editor/layout support for two MTEXT inline codes that were parsed but not rendered: - `\f…|i1;` set the font italic flag but layout only fed oblique from `\Q`, so imported italic showed upright. Map font.italic to the same 15° slant the editor's Italic button uses (explicit `\Q` still wins), and make that button recognise + clear the flag so imported italic can be toggled off. - `\~` (non-breaking space) was a normal Space atom, so lines could wrap at it. Fold it into the word — it still renders as a space but no longer breaks. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
977701b47e
commit
57ff14d3f3
2 files changed
+51
-7
No files matched your search
+15
-2
@@ -707,8 +707,21 @@ impl super::OpenCADStudio {
|
||||
each(&mut cells[a..b], |p| p.set_strikethrough(on));
|
||||
}
|
||||
MTextFmt::Italic => {
|
||||
let on = !all_have(&cells[a..b], |p| p.oblique_angle == Some(15.0));
|
||||
each(&mut cells[a..b], |p| p.oblique_angle = on.then_some(15.0));
|
||||
// Italic is the editor's canonical 15° oblique. An imported
|
||||
// run may instead carry the font italic flag (`\f…|i1;`);
|
||||
// recognise that as italic too, and clear it on toggle so
|
||||
// the one canonical form is the oblique — otherwise an
|
||||
// imported italic run could never be switched off.
|
||||
let on = !all_have(&cells[a..b], |p| {
|
||||
p.oblique_angle == Some(15.0)
|
||||
|| p.font.as_ref().is_some_and(|f| f.italic)
|
||||
});
|
||||
each(&mut cells[a..b], |p| {
|
||||
p.oblique_angle = on.then_some(15.0);
|
||||
if let Some(f) = p.font.as_mut() {
|
||||
f.italic = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
MTextFmt::Bold => {
|
||||
// Real bold: set the font's bold flag (the SDF renderer bakes
|
||||
|
||||
Reference in new issue
Block a user