Skip to content

fix(glyphs): close two positional-correlation gaps (#57, #58) - #86

Merged
ronaldtse merged 2 commits into
mainfrom
fix/positional-matcher-long-font-names
Jul 21, 2026
Merged

fix(glyphs): close two positional-correlation gaps (#57, #58)#86
ronaldtse merged 2 commits into
mainfrom
fix/positional-matcher-long-font-names

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Fixes #57 (Mongolian Supplement U+1166C) and #58 (Myanmar Extended-C U+116DA).

Root causes

  1. Font name truncation. mutool trace emits font names truncated to 31 chars (PDF base-font-name limit). The BaseFont dict carries the full original name. For long-named fonts like HBBJCP+Uni11660Mongoliansupplement (34 chars) the trace emits HBBJCP+Uni11660Mongoliansupplem, and every verbatim == comparison against the BaseFont name silently failed.

  2. Partial ToUnicode coverage. The Unicode Consortium ships charts whose embedded fonts render MORE glyphs than their /ToUnicode CMaps admit (orphan glyphs whose CIDs were forgotten in the CMap build). needs_positional? only checked for empty/out-of-scope intrinsic results, so partial coverage fell through.

Fix

  • TraceGlyph.normalize_name / TraceGlyph.name_match? truncate both sides to the 31-char PDF limit before comparing. PageTraceCache and TraceCorrelator route every name comparison through these helpers.
  • CodepointMapper#needs_positional? gains a 4th predicate: intrinsic_has_uncovered_gids? queries the trace cache for distinct GIDs and fires positional when the font ships more glyphs than the intrinsic result covers.

Test plan

  • Four new regression specs in page_trace_cache_spec.rb for long-name tolerance across #each_page_for, #references_font?, #distinct_gids_for, #find_glyph.
  • End-to-end CLI: Mongolian_Supplement 12 → 13 SVGs (U+1166C recovered).
  • End-to-end CLI: Myanmar_Extended-C 19 → 20 SVGs (U+116DA recovered).
  • All 237 specs in spec/ucode/code_chart/, spec/ucode/glyphs/embedded_fonts/, spec/ucode/cli_spec.rb pass.
  • bundle exec rubocop clean on touched files.

#57 Mongolian Supplement U+1166C and #58 Myanmar Extended-C U+116DA
were both shipped as missing glyphs in every ucode release since the
positional correlator landed. Two root causes:

1. **Font name truncation.** mutool trace emits font names truncated
   to 31 chars (PDF base-font-name limit, PDF 32000-1 §7.9.6). The
   BaseFont dict carries the full original name. For long-named
   fonts like HBBJCP+Uni11660Mongoliansupplement (34 chars) the
   trace emits HBBJCP+Uni11660Mongoliansupplem, and every verbatim
   == comparison against the BaseFont name silently failed. Fix:
   TraceGlyph.normalize_name / TraceGlyph.name_match? truncate
   both sides to the 31-char limit before comparing. PageTraceCache
   and TraceCorrelator now route every name comparison through these
   helpers.

2. **Partial ToUnicode coverage.** The Unicode Consortium ships
   charts whose embedded fonts render MORE glyphs than their
   /ToUnicode CMaps admit (orphan glyphs whose CIDs were forgotten
   in the CMap build). For these fonts, ToUnicodeStrategy returns
   a partial {cp => gid} map and TraceStrategy never fires because
   needs_positional? only checked for empty/out-of-scope results.
   Fix: needs_positional? now also returns true when the trace cache
   observes the font rendering more distinct GIDs than the intrinsic
   result covers. The positional pass then fills the gaps via the
   chart's hex labels; merge_with_positional_precedence keeps the
   intrinsic mappings untouched where they agree.

After this fix:
- Mongolian_Supplement: 12 -> 13 SVGs (U+1166C recovered)
- Myanmar_Extended-C: 19 -> 20 SVGs (U+116DA recovered)

Adds four regression specs covering the long-name tolerance in
PageTraceCache's lookup methods. The fix would have caught both
regressions; the next pre-existing partial-CMap font will now Just
Work.
The 0.5.1 release bumped lib/ucode/version.rb but missed syncing
config/unicode17_universal_glyph_set.yml#ucode_version. Same gap
that happened on 0.5.0; the smoke spec asserting the two stay in
sync catches this on the next PR's CI run.
@ronaldtse
ronaldtse merged commit 3c37152 into main Jul 21, 2026
18 checks passed
@ronaldtse
ronaldtse deleted the fix/positional-matcher-long-font-names branch July 21, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant