Class: Fontisan::Tables::CblcIndexSubTable
- Inherits:
-
Object
- Object
- Fontisan::Tables::CblcIndexSubTable
- Defined in:
- lib/fontisan/tables/cblc_index_subtable.rb
Overview
Parsed IndexSubTable from a CBLC table.
The IndexSubTable is the format-specific directory describing how to locate each glyph's bitmap inside CBDT. Five formats are defined by the OpenType spec:
1 — variable metrics, variable size (uint32 offset array)
2 — constant metrics, constant size (single imageSize for the range)
3 — variable metrics, variable size, 4-byte-aligned (uint16 offsets × 4)
4 — variable metrics, variable size, bit-packed offsets (rare)
5 — constant metrics, constant size, with explicit uint32 offsetArray
Each parsed IndexSubTable exposes one [CblcGlyphBitmapLocation] per glyph in its range, plus the raw bytes so a subsetter can preserve unchanged subtables verbatim if needed.
Format-specific parsing is delegated to [CblcIndexSubTableFormatParser]; this class only owns the data model.
Reference: OpenType CBLC spec, IndexSubTable formats 1–5.
Instance Attribute Summary collapse
-
#first_glyph_index ⇒ Integer
readonly
First glyph ID covered by this subtable.
-
#image_data_offset ⇒ Integer
readonly
Absolute imageDataOffset from start of CBDT.
-
#image_format ⇒ Integer
readonly
ImageFormat field (e.g. 17 = small metrics + PNG).
-
#index_format ⇒ Integer
readonly
IndexFormat field (1, 2, 3, or 5).
-
#last_glyph_index ⇒ Integer
readonly
Last glyph ID covered by this subtable.
-
#locations ⇒ Array<CblcGlyphBitmapLocation>
readonly
One per glyph in range.
-
#raw_bytes ⇒ String
readonly
Raw bytes of this IndexSubTable in the source CBLC.
Class Method Summary collapse
-
.parse(cblc_bytes, index_subtable_offset:, first_glyph_index:, last_glyph_index:) ⇒ CblcIndexSubTable
Parse an IndexSubTable from a CBLC binary blob.
Instance Method Summary collapse
-
#glyph_count ⇒ Integer
Number of glyphs covered by this subtable.
-
#initialize(index_format:, image_format:, image_data_offset:, first_glyph_index:, last_glyph_index:, locations:, raw_bytes:) ⇒ CblcIndexSubTable
constructor
A new instance of CblcIndexSubTable.
Constructor Details
#initialize(index_format:, image_format:, image_data_offset:, first_glyph_index:, last_glyph_index:, locations:, raw_bytes:) ⇒ CblcIndexSubTable
Returns a new instance of CblcIndexSubTable.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 47 def initialize(index_format:, image_format:, image_data_offset:, first_glyph_index:, last_glyph_index:, locations:, raw_bytes:) @index_format = index_format @image_format = image_format @image_data_offset = image_data_offset @first_glyph_index = first_glyph_index @last_glyph_index = last_glyph_index @locations = locations @raw_bytes = raw_bytes end |
Instance Attribute Details
#first_glyph_index ⇒ Integer (readonly)
Returns first glyph ID covered by this subtable.
36 37 38 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 36 def first_glyph_index @first_glyph_index end |
#image_data_offset ⇒ Integer (readonly)
Returns absolute imageDataOffset from start of CBDT.
33 34 35 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 33 def image_data_offset @image_data_offset end |
#image_format ⇒ Integer (readonly)
Returns imageFormat field (e.g. 17 = small metrics + PNG).
30 31 32 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 30 def image_format @image_format end |
#index_format ⇒ Integer (readonly)
Returns indexFormat field (1, 2, 3, or 5).
27 28 29 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 27 def index_format @index_format end |
#last_glyph_index ⇒ Integer (readonly)
Returns last glyph ID covered by this subtable.
39 40 41 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 39 def last_glyph_index @last_glyph_index end |
#locations ⇒ Array<CblcGlyphBitmapLocation> (readonly)
Returns one per glyph in range.
42 43 44 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 42 def locations @locations end |
#raw_bytes ⇒ String (readonly)
Returns raw bytes of this IndexSubTable in the source CBLC.
45 46 47 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 45 def raw_bytes @raw_bytes end |
Class Method Details
.parse(cblc_bytes, index_subtable_offset:, first_glyph_index:, last_glyph_index:) ⇒ CblcIndexSubTable
Parse an IndexSubTable from a CBLC binary blob.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 67 def self.parse(cblc_bytes, index_subtable_offset:, first_glyph_index:, last_glyph_index:) header = CblcIndexSubTableHeader.read( cblc_bytes[index_subtable_offset, 8], ) new( index_format: header.index_format, image_format: header.image_format, image_data_offset: header.image_data_offset, first_glyph_index: first_glyph_index, last_glyph_index: last_glyph_index, locations: CblcIndexSubTableFormatParser.locations( header: header, bytes: cblc_bytes, base: index_subtable_offset, first: first_glyph_index, last: last_glyph_index, ), raw_bytes: CblcIndexSubTableFormatParser.raw_bytes( header: header, bytes: cblc_bytes, base: index_subtable_offset, first: first_glyph_index, last: last_glyph_index, ), ) end |
Instance Method Details
#glyph_count ⇒ Integer
Number of glyphs covered by this subtable.
99 100 101 |
# File 'lib/fontisan/tables/cblc_index_subtable.rb', line 99 def glyph_count last_glyph_index - first_glyph_index + 1 end |