fix(block-cache): address PR211 review follow-ups
- expand_defn: dedup the <1px baseline LOD branch the same way the <5px greek branch does, so colour-split MTEXT no longer stacks N overlapping baselines (one per \C segment) over the same OBB. - sysfont: memoise canonical_family_name process-wide. resolve_font calls it once per word on the MTEXT measure hot path and Face::resolve re-runs it right after; the fontdb query + linear family scans were uncached. - dimension/multileader/table: reword the 6 fill_tris_low FIXMEs. They cited a stale line and the wrong consumer — these fills render on the top-level path (panic-safe .get().unwrap_or), not the block cache, so they cannot trip emit_wire's debug_assert. State the real status: latent f32-precision debt, not a crash. Also fix the mis-indented text-fill WireModel in dimension.rs. - tests: add a host-independent colour-split test (two \C segments in a block keep ≥2 distinct wire colours — guards the per-wire colour fix) and a TTF-gated UTM fill test (paired, non-zero fill_tris_low). Note the arial-style test's LFF-fallback limitation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
a84da122f4
commit
a93271c1bd
6 changed files with 174 additions and 31 deletions
|
|
@ -6,7 +6,8 @@
|
|||
// TTF glyph engine). LFF stroke fonts stay separate — this is purely the
|
||||
// TrueType side of the renderer.
|
||||
|
||||
use std::sync::OnceLock;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
struct SysFonts {
|
||||
db: fontdb::Database,
|
||||
|
|
@ -38,7 +39,27 @@ pub fn families() -> &'static [String] {
|
|||
}
|
||||
|
||||
/// Resolve a requested family name to the canonical installed system family name (with exact case).
|
||||
///
|
||||
/// Memoised process-wide: `resolve_font` calls this once per word on the MTEXT
|
||||
/// measure hot path for inline-`\f` TTF runs, and `Face::resolve` re-runs it
|
||||
/// immediately after — the underlying fontdb query plus linear family scans are
|
||||
/// not free. The cache keys on the raw request string; results are stable for
|
||||
/// the process lifetime (the font DB is loaded once via `OnceLock`).
|
||||
pub fn canonical_family_name(family: &str) -> Option<String> {
|
||||
static CACHE: OnceLock<Mutex<HashMap<String, Option<String>>>> = OnceLock::new();
|
||||
let cache = CACHE.get_or_init(|| Mutex::new(HashMap::new()));
|
||||
if let Some(hit) = cache.lock().unwrap().get(family) {
|
||||
return hit.clone();
|
||||
}
|
||||
let resolved = canonical_family_name_uncached(family);
|
||||
cache
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(family.to_string(), resolved.clone());
|
||||
resolved
|
||||
}
|
||||
|
||||
fn canonical_family_name_uncached(family: &str) -> Option<String> {
|
||||
let db = &fonts().db;
|
||||
|
||||
// 1. Try exact match first
|
||||
|
|
|
|||
Loading…
Reference in a new issue