Class: Ucode::Glyphs::EmbeddedFonts::CodepointMapper::Strategy
- Inherits:
-
Object
- Object
- Ucode::Glyphs::EmbeddedFonts::CodepointMapper::Strategy
- Defined in:
- lib/ucode/glyphs/embedded_fonts/codepoint_mapper/strategy.rb
Overview
Abstract base for the codepoint→GID resolution strategies.
Each subclass owns ONE mutool subcommand and ONE collaborator. Subclasses declare their role via #positional?:
* `positional? == false` — the strategy reads the font's own
intrinsic mapping (ToUnicode CMap). Authoritative for
cross-reference typography, but can be misleading when
the embedded font's CMap encodes composing characters
rather than the chart specimens (Enclosed Ideographic
Supplement, where CJKSymbols' CIDs map to the inner CJK
ideographs, not the squared characters themselves).
* `positional? == true` — the strategy attributes glyphs to
codepoints via chart-grid geometry (mutool trace, content
stream correlation). Authoritative for in-block specimens.
The orchestrator (Ucode::Glyphs::EmbeddedFonts::CodepointMapper) partitions strategies by
this predicate, gates positional strategies behind a
block-scope check, and merges with positional precedence
when both produce a result. Adding a new strategy = one
subclass + one positional? override + one entry in the
chain. No edit to CodepointMapper (Open/Closed Principle).
Direct Known Subclasses
Instance Method Summary collapse
-
#map(_descriptor) ⇒ Hash{Integer=>Integer}
Codepoint => gid; empty when the strategy cannot produce a mapping.
-
#positional? ⇒ Boolean
Declares whether this strategy attributes glyphs by chart geometry (true) or by the font's intrinsic mapping (false).
- #supports?(_descriptor) ⇒ Boolean
Instance Method Details
#map(_descriptor) ⇒ Hash{Integer=>Integer}
Returns codepoint => gid; empty when the strategy cannot produce a mapping.
38 39 40 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/strategy.rb', line 38 def map(_descriptor) raise NotImplementedError end |
#positional? ⇒ Boolean
Declares whether this strategy attributes glyphs by chart geometry (true) or by the font's intrinsic mapping (false). The default is false; positional strategies override.
47 48 49 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/strategy.rb', line 47 def positional? false end |
#supports?(_descriptor) ⇒ Boolean
31 32 33 |
# File 'lib/ucode/glyphs/embedded_fonts/codepoint_mapper/strategy.rb', line 31 def supports?(_descriptor) raise NotImplementedError end |