Class: Fontisan::Stitcher::Deduplicator
- Inherits:
-
Object
- Object
- Fontisan::Stitcher::Deduplicator
- Defined in:
- lib/fontisan/stitcher/deduplicator.rb
Overview
Registry mapping glyph signatures to canonical glyph names in the target font. Enables signature-based deduplication: when two bindings produce glyphs with identical outlines, they share one gid and the duplicate's codepoint is redirected to the canonical glyph.
Replaces the Stitcher's previous name-based dedup with outline-based dedup. This merges visually identical glyphs from different donors even when their names differ, reducing the glyph count below the TrueType 65,535 cap.
Instance Attribute Summary collapse
-
#signatures ⇒ Object
readonly
Returns the value of attribute signatures.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#find(glyph) ⇒ String?
The canonical name if an identical glyph was already registered, nil otherwise.
-
#initialize ⇒ Deduplicator
constructor
A new instance of Deduplicator.
-
#register(glyph, canonical_name) ⇒ Object
Record that
glyphmaps tocanonical_namein the target. -
#size ⇒ Integer
Number of unique signatures registered.
Constructor Details
#initialize ⇒ Deduplicator
Returns a new instance of Deduplicator.
18 19 20 |
# File 'lib/fontisan/stitcher/deduplicator.rb', line 18 def initialize @signatures = {} end |
Instance Attribute Details
#signatures ⇒ Object (readonly)
Returns the value of attribute signatures.
16 17 18 |
# File 'lib/fontisan/stitcher/deduplicator.rb', line 16 def signatures @signatures end |
Instance Method Details
#empty? ⇒ Boolean
42 43 44 |
# File 'lib/fontisan/stitcher/deduplicator.rb', line 42 def empty? @signatures.empty? end |
#find(glyph) ⇒ String?
Returns the canonical name if an identical glyph was already registered, nil otherwise.
33 34 35 |
# File 'lib/fontisan/stitcher/deduplicator.rb', line 33 def find(glyph) @signatures[GlyphSignature.for(glyph)] end |
#register(glyph, canonical_name) ⇒ Object
Record that glyph maps to canonical_name in the target.
26 27 28 |
# File 'lib/fontisan/stitcher/deduplicator.rb', line 26 def register(glyph, canonical_name) @signatures[GlyphSignature.for(glyph)] = canonical_name end |
#size ⇒ Integer
Returns number of unique signatures registered.
38 39 40 |
# File 'lib/fontisan/stitcher/deduplicator.rb', line 38 def size @signatures.size end |