Class: Ucode::Glyphs::EmbeddedFonts::Catalog
- Inherits:
-
Object
- Object
- Ucode::Glyphs::EmbeddedFonts::Catalog
- Defined in:
- lib/ucode/glyphs/embedded_fonts/catalog.rb
Overview
Composes PdfIndexer + CodepointMapper to build a global
{codepoint => FontEntry} index from a Code Charts PDF.
Responsibilities split cleanly:
* {PdfIndexer} — subprocess + dict parsing → Array<RawFontDescriptor>
* {CodepointMapper} — 3-path codepoint→GID strategy → {cp => gid}
* {Catalog} (this class) — composes both into FontEntry objects
and exposes the public lookup interface
When multiple fonts cover the same codepoint, the first font discovered wins. Discovery order follows mutool info's page-major listing, so earlier blocks' fonts win — the expected behavior.
Instance Method Summary collapse
-
#codepoints ⇒ Array<Integer>
Every codepoint this PDF covers.
-
#font_count ⇒ Integer
Number of Type0 fonts with non-empty maps.
-
#font_entries ⇒ Array<FontEntry>
Every font entry (one per Type0 font).
-
#index ⇒ Hash{Integer=>FontEntry}
Frozen codepoint → entry map.
-
#initialize(source, block_range: nil, force_positional_for_font_ids: Set.new, correlator_configs: {}) ⇒ Catalog
constructor
A new instance of Catalog.
- #lookup(codepoint) ⇒ FontEntry?
-
#size ⇒ Integer
Number of codepoints covered.
Constructor Details
#initialize(source, block_range: nil, force_positional_for_font_ids: Set.new, correlator_configs: {}) ⇒ Catalog
Returns a new instance of Catalog.
35 36 37 38 39 40 41 42 43 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 35 def initialize(source, block_range: nil, force_positional_for_font_ids: Set.new, correlator_configs: {}) @source = source @block_range = block_range @force_positional_for_font_ids = force_positional_for_font_ids @correlator_configs = correlator_configs @index = nil end |
Instance Method Details
#codepoints ⇒ Array<Integer>
Returns every codepoint this PDF covers.
57 58 59 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 57 def codepoints index.keys end |
#font_count ⇒ Integer
Returns number of Type0 fonts with non-empty maps.
67 68 69 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 67 def font_count font_entries.size end |
#font_entries ⇒ Array<FontEntry>
Returns every font entry (one per Type0 font).
72 73 74 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 72 def font_entries @font_entries ||= build_font_entries end |
#index ⇒ Hash{Integer=>FontEntry}
Returns frozen codepoint → entry map.
46 47 48 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 46 def index @index ||= build_index.freeze end |
#lookup(codepoint) ⇒ FontEntry?
52 53 54 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 52 def lookup(codepoint) index[codepoint] end |
#size ⇒ Integer
Returns number of codepoints covered.
62 63 64 |
# File 'lib/ucode/glyphs/embedded_fonts/catalog.rb', line 62 def size index.size end |