Class: Ucode::Glyphs::Sources::Tier1RealFont
- Inherits:
-
Ucode::Glyphs::Source
- Object
- Ucode::Glyphs::Source
- Ucode::Glyphs::Sources::Tier1RealFont
- Defined in:
- lib/ucode/glyphs/sources/tier1_real_font.rb
Overview
Tier 1 glyph source: real-font cmap + outline extraction.
For codepoints inside its assigned block range, looks up the
GID in the font's cmap, extracts the outline via
Fontisan::OutlineExtractor, and renders a standalone SVG via
EmbeddedFonts::Svg (which y-flips to SVG coordinates and
builds a padded viewBox around the outline bbox).
Codepoints outside the block range, missing from the cmap, or producing an empty outline return nil — the Resolver then falls through to lower tiers. This is the preferred source: highest fidelity, no chart-grid chrome composited in.
One Tier1RealFont per (block, font) pair. The Ucode::Glyphs::SourceBuilder expands a Ucode::Glyphs::SourceConfig into a flat array of these, one per configured block × Models::GlyphSource entry. When multiple Tier 1 fonts are configured for the same block, each becomes a separate source and the resolver tries them in declared order.
Instance Method Summary collapse
-
#fetch(codepoint) ⇒ Result?
Nil when this source cannot produce a glyph.
-
#initialize(block_range:, source:, install: true) ⇒ Tier1RealFont
constructor
A new instance of Tier1RealFont.
-
#provenance ⇒ String
"tier-1:
-
#tier ⇒ Symbol
:tier1.
Constructor Details
#initialize(block_range:, source:, install: true) ⇒ Tier1RealFont
Returns a new instance of Tier1RealFont.
41 42 43 44 45 46 |
# File 'lib/ucode/glyphs/sources/tier1_real_font.rb', line 41 def initialize(block_range:, source:, install: true) super() @block_range = block_range @source = source @install = install end |
Instance Method Details
#fetch(codepoint) ⇒ Result?
Returns nil when this source cannot produce a glyph.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ucode/glyphs/sources/tier1_real_font.rb', line 60 def fetch(codepoint) return nil unless @block_range.cover?(codepoint) gid = cmap[codepoint] return nil unless gid outline = extractor.extract(gid) return nil if outline.nil? || outline.empty? svg = EmbeddedFonts::Svg.new(outline, codepoint: codepoint, base_font: base_font).to_s Result.new(tier: tier, codepoint: codepoint, svg: svg, provenance: provenance) rescue StandardError # Font load failures, outline extraction errors, etc. — all # translate to "this source can't help". The resolver will # try the next tier. nil end |
#provenance ⇒ String
Returns "tier-1:
55 56 57 |
# File 'lib/ucode/glyphs/sources/tier1_real_font.rb', line 55 def provenance "tier-1:#{@source.label}" end |
#tier ⇒ Symbol
Returns :tier1.
49 50 51 |
# File 'lib/ucode/glyphs/sources/tier1_real_font.rb', line 49 def tier :tier1 end |