From de65cd7e509cd162c1d4839e3cc67ed1888f8149 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Tue, 6 Oct 2026 14:33:59 +0300 Subject: [PATCH] Text: stroke font space widths of the reference The SHX names the embedded LFF fonts stand in for (txt, monotxt, simplex, romans, romand, romanc, complex, italic, gdt, isocp) use the space advance of the reference's fonts. Co-Authored-By: Claude Opus 5.5 --- src/scene/text/lff.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/scene/text/lff.rs b/src/scene/text/lff.rs index 0fe1f877b..3314d9b11 100644 --- a/src/scene/text/lff.rs +++ b/src/scene/text/lff.rs @@ -87,6 +87,22 @@ const ALIASES: &[(&str, &str)] = &[ ("EXTFONT", "unicode"), ]; +/// The space advance of the reference's stroke fonts, in glyph units (cap +/// height 9), measured from their text extents: the SHX names these LFF +/// fonts stand in for keep the reference's word gaps. +const SHX_SPACE: &[(&str, f32)] = &[ + ("TXT", 9.0), + ("MONOTXT", 9.0), + ("SIMPLEX", 9.0 * 19.0 / 21.0), + ("ROMANS", 9.0), + ("ROMAND", 9.0), + ("ROMANC", 9.0), + ("COMPLEX", 9.0), + ("ITALIC", 9.0), + ("GDT", 9.0), + ("ISOCP", 3.6), +]; + // ── Public types ────────────────────────────────────────────────────────── /// One glyph: a list of open 2-D polyline strokes in glyph units. @@ -163,6 +179,12 @@ fn fonts_map() -> &'static HashMap { map.insert(alias.to_ascii_uppercase(), f); } } + // Those names keep the reference font's space width. + for (name, word) in SHX_SPACE { + if let Some(f) = map.get_mut(*name) { + f.word_spacing = *word; + } + } map }) }