Class: TTFunk::Table::Head
- Inherits:
-
TTFunk::Table
- Object
- TTFunk::Table
- TTFunk::Table::Head
- Defined in:
- lib/ttfunk/table/head.rb
Overview
Font Header (‘head`) Table.
Instance Attribute Summary collapse
-
#checksum_adjustment ⇒ Integer
readonly
Checksum adjustment.
-
#created ⇒ Integer
readonly
Font creation time.
-
#flags ⇒ Integer
readonly
Flags.
-
#font_direction_hint ⇒ Integer
readonly
Font direction hint.
-
#font_revision ⇒ Integer
readonly
Font revision.
-
#glyph_data_format ⇒ Integer
readonly
Glyph data format.
-
#index_to_loc_format ⇒ Integer
readonly
Index to Location format.
-
#lowest_rec_ppem ⇒ Integer
readonly
Smallest readable size in pixels.
-
#mac_style ⇒ Integer
readonly
Mac font style.
-
#magic_number ⇒ Integer
readonly
Magic number.
-
#modified ⇒ Integer
readonly
Font modification time.
-
#units_per_em ⇒ Integer
readonly
Units per Em.
-
#version ⇒ Integer
readonly
Table version.
-
#x_max ⇒ Integer
readonly
Maximum x coordinate across all glyph bounding boxes.
-
#x_min ⇒ Integer
readonly
Minimum x coordinate across all glyph bounding boxes.
-
#y_max ⇒ Integer
readonly
Maximum y coordinate across all glyph bounding boxes.
-
#y_min ⇒ Integer
readonly
Minimum y coordinate across all glyph bounding boxes.
Attributes inherited from TTFunk::Table
Class Method Summary collapse
-
.encode(head, loca, mapping) ⇒ EncodedString
Encode table.
-
.from_long_date_time(ldt) ⇒ Time
Convert Long Date Time timestamp to Time.
-
.to_long_date_time(time) ⇒ Integer
Convert Time to Long Date Time timestamp.
Methods inherited from TTFunk::Table
#exists?, #initialize, #raw, #tag
Constructor Details
This class inherits a constructor from TTFunk::Table
Instance Attribute Details
#checksum_adjustment ⇒ Integer (readonly)
Checksum adjustment.
19 20 21 |
# File 'lib/ttfunk/table/head.rb', line 19 def checksum_adjustment @checksum_adjustment end |
#created ⇒ Integer (readonly)
Font creation time.
35 36 37 |
# File 'lib/ttfunk/table/head.rb', line 35 def created @created end |
#flags ⇒ Integer (readonly)
Flags.
27 28 29 |
# File 'lib/ttfunk/table/head.rb', line 27 def flags @flags end |
#font_direction_hint ⇒ Integer (readonly)
Font direction hint. Deprecated, set to 2.
67 68 69 |
# File 'lib/ttfunk/table/head.rb', line 67 def font_direction_hint @font_direction_hint end |
#font_revision ⇒ Integer (readonly)
Font revision.
15 16 17 |
# File 'lib/ttfunk/table/head.rb', line 15 def font_revision @font_revision end |
#glyph_data_format ⇒ Integer (readonly)
Glyph data format.
75 76 77 |
# File 'lib/ttfunk/table/head.rb', line 75 def glyph_data_format @glyph_data_format end |
#index_to_loc_format ⇒ Integer (readonly)
Index to Location format.
71 72 73 |
# File 'lib/ttfunk/table/head.rb', line 71 def index_to_loc_format @index_to_loc_format end |
#lowest_rec_ppem ⇒ Integer (readonly)
Smallest readable size in pixels.
63 64 65 |
# File 'lib/ttfunk/table/head.rb', line 63 def lowest_rec_ppem @lowest_rec_ppem end |
#mac_style ⇒ Integer (readonly)
Mac font style.
59 60 61 |
# File 'lib/ttfunk/table/head.rb', line 59 def mac_style @mac_style end |
#magic_number ⇒ Integer (readonly)
Magic number.
23 24 25 |
# File 'lib/ttfunk/table/head.rb', line 23 def magic_number @magic_number end |
#modified ⇒ Integer (readonly)
Font modification time.
39 40 41 |
# File 'lib/ttfunk/table/head.rb', line 39 def modified @modified end |
#units_per_em ⇒ Integer (readonly)
Units per Em.
31 32 33 |
# File 'lib/ttfunk/table/head.rb', line 31 def units_per_em @units_per_em end |
#version ⇒ Integer (readonly)
Table version.
11 12 13 |
# File 'lib/ttfunk/table/head.rb', line 11 def version @version end |
#x_max ⇒ Integer (readonly)
Maximum x coordinate across all glyph bounding boxes.
51 52 53 |
# File 'lib/ttfunk/table/head.rb', line 51 def x_max @x_max end |
#x_min ⇒ Integer (readonly)
Minimum x coordinate across all glyph bounding boxes.
43 44 45 |
# File 'lib/ttfunk/table/head.rb', line 43 def x_min @x_min end |
#y_max ⇒ Integer (readonly)
Maximum y coordinate across all glyph bounding boxes.
55 56 57 |
# File 'lib/ttfunk/table/head.rb', line 55 def y_max @y_max end |
#y_min ⇒ Integer (readonly)
Minimum y coordinate across all glyph bounding boxes.
47 48 49 |
# File 'lib/ttfunk/table/head.rb', line 47 def y_min @y_min end |
Class Method Details
.encode(head, loca, mapping) ⇒ EncodedString
Encode table.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ttfunk/table/head.rb', line 92 def encode(head, loca, mapping) EncodedString.new do |table| table << [head.version, head.font_revision].pack('N2') << Placeholder.new(:checksum, length: 4) << [ head.magic_number, head.flags, head.units_per_em, head.created, head.modified, *min_max_values_for(head, mapping), head.mac_style, head.lowest_rec_ppem, head.font_direction_hint, loca[:type] || 0, head.glyph_data_format, ].pack('Nn2q>2n*') end end |
.from_long_date_time(ldt) ⇒ Time
Convert Long Date Time timestamp to Time.
111 112 113 |
# File 'lib/ttfunk/table/head.rb', line 111 def from_long_date_time(ldt) Time.at(ldt + LONG_DATE_TIME_BASIS, in: 'UTC') end |
.to_long_date_time(time) ⇒ Integer
Convert Time to Long Date Time timestamp
118 119 120 |
# File 'lib/ttfunk/table/head.rb', line 118 def to_long_date_time(time) Integer(time) - LONG_DATE_TIME_BASIS end |