Class: HexaPDF::Font::TrueType::Table::Head

Inherits:
HexaPDF::Font::TrueType::Table show all
Extended by:
Utils::BitField
Defined in:
lib/hexapdf/font/true_type/table/head.rb

Overview

The ‘head’ table contains global information about the font.

See: developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6head.html

Constant Summary

Constants inherited from HexaPDF::Font::TrueType::Table

TIME_EPOCH

Instance Attribute Summary collapse

Attributes inherited from HexaPDF::Font::TrueType::Table

#font

Instance Method Summary collapse

Methods included from Utils::BitField

bit_field

Methods inherited from HexaPDF::Font::TrueType::Table

calculate_checksum, #directory_entry, #initialize

Constructor Details

This class inherits a constructor from HexaPDF::Font::TrueType::Table

Instance Attribute Details

#bboxObject

The bounding box for all glyphs of the font in the form [xmin, ymin, xmax, ymax].



71
72
73
# File 'lib/hexapdf/font/true_type/table/head.rb', line 71

def bbox
  @bbox
end

#checksum_adjustmentObject

The adjustment value for the checksum.



55
56
57
# File 'lib/hexapdf/font/true_type/table/head.rb', line 55

def checksum_adjustment
  @checksum_adjustment
end

#createdObject

The creation time of the font.



65
66
67
# File 'lib/hexapdf/font/true_type/table/head.rb', line 65

def created
  @created
end

#flagsObject

Various font flags. See Flags.



58
59
60
# File 'lib/hexapdf/font/true_type/table/head.rb', line 58

def flags
  @flags
end

#font_direction_hintObject

Represents an indication of the direction of the glyphs of the font.

0

Mixed directional font

1

Font with only left-to-right glyphs

-1

Font with only right-to-left glyphs

2

Font with left-to-right and neutral (e.g. punctuation) glyphs

-2

Font with right-to-left and neutral (e.g. punctuation) glyphs



88
89
90
# File 'lib/hexapdf/font/true_type/table/head.rb', line 88

def font_direction_hint
  @font_direction_hint
end

#font_revisionObject

The revision of the font as set by the manufacturer (a Rational).



52
53
54
# File 'lib/hexapdf/font/true_type/table/head.rb', line 52

def font_revision
  @font_revision
end

#index_to_loc_formatObject

Indicates the type of offset format used in the ‘loca’ table, 0 for short offsets, 1 for long offsets.

See: Loca



94
95
96
# File 'lib/hexapdf/font/true_type/table/head.rb', line 94

def index_to_loc_format
  @index_to_loc_format
end

#mac_styleObject

Apple Mac style information.



74
75
76
# File 'lib/hexapdf/font/true_type/table/head.rb', line 74

def mac_style
  @mac_style
end

#modifiedObject

The modification time of the font.



68
69
70
# File 'lib/hexapdf/font/true_type/table/head.rb', line 68

def modified
  @modified
end

#smallest_readable_sizeObject

The smallest readable size in pixels per em for this font.



79
80
81
# File 'lib/hexapdf/font/true_type/table/head.rb', line 79

def smallest_readable_size
  @smallest_readable_size
end

#units_per_emObject

The number of units per em for the font. Should be a power of 2 in the range from 64 through 16384.



62
63
64
# File 'lib/hexapdf/font/true_type/table/head.rb', line 62

def units_per_em
  @units_per_em
end

#versionObject

The version of the font (a Rational).



49
50
51
# File 'lib/hexapdf/font/true_type/table/head.rb', line 49

def version
  @version
end

Instance Method Details

#checksum_valid?Boolean

The checksum for the head table is calculated differently because the checksum_adjustment value is not used during the calculation.

See: Table#checksum_valid?

Returns:

  • (Boolean)


100
101
102
103
104
105
106
# File 'lib/hexapdf/font/true_type/table/head.rb', line 100

def checksum_valid?
  super unless directory_entry

  data = with_io_pos(directory_entry.offset) { io.read(directory_entry.length) }
  data[8, 4] = 0.chr * 4
  directory_entry.checksum == self.class.calculate_checksum(data)
end