Class: Fontisan::Tables::HeadTable

Inherits:
SfntTable
  • Object
show all
Defined in:
lib/fontisan/tables/head_table.rb

Overview

OOP representation of the 'head' (Font Header) table

The head table contains global information about the font, including metadata about the font file, bounding box, and indexing information.

This class extends SfntTable to provide head-specific validation and convenience methods for accessing common head table fields.

Examples:

Accessing head table data

head = font.table("head")  # Returns SfntTable instance
head.magic_number_valid?  # => true
head.units_per_em  # => 2048
head.bounding_box  # => {x_min: -123, y_min: -456, ...}

Instance Attribute Summary

Attributes inherited from SfntTable

#data, #entry, #font, #parsed

Instance Method Summary collapse

Methods inherited from SfntTable

#available?, #calculate_checksum, #checksum, #data_loaded?, #human_name, #initialize, #inspect, #length, #load_data!, #offset, #parse, #parsed?, #required?, #tag, #to_s, #validate!

Constructor Details

This class inherits a constructor from Fontisan::SfntTable

Instance Method Details

#bounding_boxHash?

Get font bounding box

Returns:

  • (Hash, nil)

    Bounding box hash, or nil if not parsed



36
37
38
39
40
41
42
43
44
45
# File 'lib/fontisan/tables/head_table.rb', line 36

def bounding_box
  return nil unless parsed

  {
    x_min: parsed.x_min,
    y_min: parsed.y_min,
    x_max: parsed.x_max,
    y_max: parsed.y_max,
  }
end

#font_revisionFloat?

Get font revision

Returns:

  • (Float, nil)

    Font revision as Fixed-point number



71
72
73
# File 'lib/fontisan/tables/head_table.rb', line 71

def font_revision
  parsed&.font_revision
end

#index_to_loc_formatInteger?

Get index to loc format

Returns:

  • (Integer, nil)

    IndexToLocFormat value, or nil if not parsed



50
51
52
# File 'lib/fontisan/tables/head_table.rb', line 50

def index_to_loc_format
  parsed&.index_to_loc_format
end

#long_loca_format?Boolean

Check if using long loca format

Returns:

  • (Boolean)

    true if using 32-bit loca offsets



57
58
59
# File 'lib/fontisan/tables/head_table.rb', line 57

def long_loca_format?
  index_to_loc_format == 1
end

#magic_number_valid?Boolean

Check if magic number is valid

Returns:

  • (Boolean)

    true if magic number is 0x5F0F3CF5



22
23
24
# File 'lib/fontisan/tables/head_table.rb', line 22

def magic_number_valid?
  parsed && parsed.magic_number == Tables::Head::MAGIC_NUMBER
end

#units_per_emInteger?

Get units per em

Returns:

  • (Integer, nil)

    Units per em value, or nil if not parsed



29
30
31
# File 'lib/fontisan/tables/head_table.rb', line 29

def units_per_em
  parsed&.units_per_em
end

#versionFloat?

Get font version

Returns:

  • (Float, nil)

    Font version as Fixed-point number



64
65
66
# File 'lib/fontisan/tables/head_table.rb', line 64

def version
  parsed&.version
end