Class: Fontisan::Tables::CblcIndexSubTableFormatParser
- Inherits:
-
Object
- Object
- Fontisan::Tables::CblcIndexSubTableFormatParser
- Defined in:
- lib/fontisan/tables/cblc_index_subtable_format_parser.rb
Overview
Per-format CBLC IndexSubTable parser. Extracted as a sibling class so that CblcIndexSubTable remains a pure data model.
The five OpenType formats differ in how the offset array encodes glyph lengths and CBDT offsets. This class hides that arithmetic behind a uniform [.locations] entry point that returns a flat list of CblcGlyphBitmapLocation objects (one per glyph in the range).
Reference: OpenType CBLC spec, IndexSubTable formats 1–5.
Defined Under Namespace
Classes: UnsupportedFormat
Class Method Summary collapse
-
.locations(header:, bytes:, base:, first:, last:) ⇒ Array<CblcGlyphBitmapLocation>
Returns an Array of CblcGlyphBitmapLocation, one per glyph in the IndexSubTable's glyph range.
-
.raw_bytes(header:, bytes:, base:, first:, last:) ⇒ String
Returns the raw bytes the IndexSubTable occupies in CBLC.
Class Method Details
.locations(header:, bytes:, base:, first:, last:) ⇒ Array<CblcGlyphBitmapLocation>
Returns an Array of CblcGlyphBitmapLocation, one per glyph in the IndexSubTable's glyph range.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fontisan/tables/cblc_index_subtable_format_parser.rb', line 28 def locations(header:, bytes:, base:, first:, last:) case header.index_format when 1 then format_1(header, bytes, base, first, last) when 2 then format_2(header, bytes, base, first, last) when 3 then format_3(header, bytes, base, first, last) when 5 then format_5(header, bytes, base, first, last) when 4 raise UnsupportedFormat, "CBLC IndexSubTable format 4 (bit-packed) is unsupported" else raise UnsupportedFormat, "Unknown CBLC IndexSubTable format: #{header.index_format}" end end |
.raw_bytes(header:, bytes:, base:, first:, last:) ⇒ String
Returns the raw bytes the IndexSubTable occupies in CBLC.
46 47 48 49 50 |
# File 'lib/fontisan/tables/cblc_index_subtable_format_parser.rb', line 46 def raw_bytes(header:, bytes:, base:, first:, last:) count = last - first + 1 length = byte_length(header.index_format, count, bytes, base) bytes[base, length] end |