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’)
35 36 37 |
# File 'lib/fontisan/binary/structures.rb', line 35 def cff? sfnt_version == 0x4F54544F # 'OTTO' end |
#truetype? ⇒ Boolean
Check if this is a TrueType font (version 0x00010000 or ‘true’)
28 29 30 |
# File 'lib/fontisan/binary/structures.rb', line 28 def truetype? [0x00010000, 0x74727565].include?(sfnt_version) # 'true' end |
#version_tag ⇒ String
Get sfnt version as a tag string
42 43 44 45 46 47 48 49 50 |
# File 'lib/fontisan/binary/structures.rb', line 42 def version_tag if cff? "OTTO" elsif truetype? "TrueType" else format("0x%08X", sfnt_version) end end |