Class: Fontisan::Binary::OffsetTable
- Inherits:
-
BaseRecord
- Object
- BinData::Record
- BaseRecord
- Fontisan::Binary::OffsetTable
- Defined in:
- lib/fontisan/binary/structures.rb
Overview
OpenType Offset Table (Font Header)
This structure appears at the beginning of every OpenType font file. It contains metadata about the table directory.
Structure:
- uint32: sfnt_version (0x00010000 for TrueType, 'OTTO' for CFF)
- uint16: num_tables (number of tables in font)
- uint16: search_range (maximum power of 2 <= num_tables) * 16
- uint16: entry_selector (log2 of maximum power of 2 <= num_tables)
- uint16: range_shift (num_tables * 16 - search_range)
Instance Method Summary collapse
-
#cff? ⇒ Boolean
Check if this is an OpenType/CFF font (version 'OTTO').
-
#truetype? ⇒ Boolean
Check if this is a TrueType font (version 0x00010000 or 'true').
-
#version_tag ⇒ String
Get sfnt version as a tag string.
Methods inherited from BaseRecord
Instance Method Details
#cff? ⇒ Boolean
Check if this is an OpenType/CFF font (version 'OTTO')
33 34 35 |
# File 'lib/fontisan/binary/structures.rb', line 33 def cff? sfnt_version == 0x4F54544F # 'OTTO' end |
#truetype? ⇒ Boolean
Check if this is a TrueType font (version 0x00010000 or 'true')
26 27 28 |
# File 'lib/fontisan/binary/structures.rb', line 26 def truetype? [0x00010000, 0x74727565].include?(sfnt_version) # 'true' end |
#version_tag ⇒ String
Get sfnt version as a tag string
40 41 42 43 44 45 46 47 48 |
# File 'lib/fontisan/binary/structures.rb', line 40 def version_tag if cff? "OTTO" elsif truetype? "TrueType" else format("0x%08X", sfnt_version) end end |