Class: Ucode::Glyphs::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/source.rb

Overview

Abstract glyph source — one tier of the 4-tier sourcing strategy.

The canonical Resolver holds an ordered array of Source subclasses and returns the first non-nil Result for a given codepoint. Each tier is one subclass:

* Tier 1   — {Sources::Tier1RealFont}: real-font cmap + outline
           extraction (highest fidelity).
* Pillar 1 — {Sources::Pillar1EmbeddedTounicode}: PDF-embedded
           CIDFont + /ToUnicode CMap.
* Pillar 2 — {Sources::Pillar2Correlator}: PDF content-stream
           positional correlation for fonts without /ToUnicode.
* Pillar 3 — {Sources::Pillar3LastResort}: Last Resort UFO
           placeholder outlines (catches the tail).

Subclasses must implement #tier, #provenance, and #fetch. #fetch returns nil when the source cannot produce a glyph for the given codepoint — this is NOT an error, it's the signal for the resolver to try the next source.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#fetch(codepoint) ⇒ Result?

Returns nil when this source cannot produce a glyph.

Parameters:

  • codepoint (Integer)

Returns:

  • (Result, nil)

    nil when this source cannot produce a glyph

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/ucode/glyphs/source.rb', line 43

def fetch(codepoint)
  raise NotImplementedError
end

#provenanceString

Returns dotted provenance string, e.g. "tier-1:lentariso", "pillar-3:last-resort".

Returns:

  • (String)

    dotted provenance string, e.g. "tier-1:lentariso", "pillar-3:last-resort"

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/ucode/glyphs/source.rb', line 37

def provenance
  raise NotImplementedError
end

#tierSymbol

Returns one of :tier1, :pillar1, :pillar2, :pillar3.

Returns:

  • (Symbol)

    one of :tier1, :pillar1, :pillar2, :pillar3

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/ucode/glyphs/source.rb', line 31

def tier
  raise NotImplementedError
end