Class: Ucode::Glyphs::RealFonts::CmapCache
- Inherits:
-
Object
- Object
- Ucode::Glyphs::RealFonts::CmapCache
- Defined in:
- lib/ucode/glyphs/real_fonts/cmap_cache.rb
Overview
Lazily loads each Tier 1 font's cmap and answers per-codepoint coverage queries. Used by SourceConfig::CoverageAssertion to walk every assigned codepoint without re-parsing the same font once per block.
One font load per unique label. The cache key is the source's
label (fontist formula name or name=path short name) —
if two blocks reference the same label, the cmap loads once.
Fonts that cannot be located or parsed produce an empty set; CoverageAssertion records every assigned codepoint in those blocks as a gap. Missing fonts are themselves curation findings — the walker surfaces them rather than hiding them behind an exception.
Instance Method Summary collapse
-
#covers?(source, codepoint) ⇒ Boolean
True when the source's cmap includes the codepoint.
-
#initialize(font_locator: FontLocator.new) ⇒ CmapCache
constructor
A new instance of CmapCache.
Constructor Details
#initialize(font_locator: FontLocator.new) ⇒ CmapCache
Returns a new instance of CmapCache.
32 33 34 35 |
# File 'lib/ucode/glyphs/real_fonts/cmap_cache.rb', line 32 def initialize(font_locator: FontLocator.new) @font_locator = font_locator @cmaps = {} end |
Instance Method Details
#covers?(source, codepoint) ⇒ Boolean
Returns true when the source's cmap includes the codepoint. False when the font is missing, fails to load, or doesn't have an outline for that codepoint.
42 43 44 |
# File 'lib/ucode/glyphs/real_fonts/cmap_cache.rb', line 42 def covers?(source, codepoint) cmap_for(source).include?(codepoint) end |