class TTFunk::Table::Hhea
Attributes
advance_width_max[R]
ascent[R]
caret_offset[R]
carot_slope_rise[R]
carot_slope_run[R]
descent[R]
line_gap[R]
metric_data_format[R]
min_left_side_bearing[R]
min_right_side_bearing[R]
number_of_metrics[R]
version[R]
x_max_extent[R]
Public Class Methods
encode(hhea, hmtx, original, mapping)
click to toggle source
# File lib/ttfunk/table/hhea.rb, line 23 def encode(hhea, hmtx, original, mapping) ''.b.tap do |table| table << [hhea.version].pack('N') table << [ hhea.ascent, hhea.descent, hhea.line_gap, *min_max_values_for(original, mapping), hhea.carot_slope_rise, hhea.carot_slope_run, hhea.caret_offset, 0, 0, 0, 0, hhea.metric_data_format, hmtx[:number_of_metrics] ].pack('n*') end end
Private Class Methods
min_max_values_for(original, mapping)
click to toggle source
# File lib/ttfunk/table/hhea.rb, line 37 def min_max_values_for(original, mapping) min_lsb = Min.new min_rsb = Min.new max_aw = Max.new max_extent = Max.new mapping.each do |_, old_glyph_id| horiz_metrics = original.horizontal_metrics.for(old_glyph_id) next unless horiz_metrics min_lsb << horiz_metrics.left_side_bearing max_aw << horiz_metrics.advance_width glyph = original.find_glyph(old_glyph_id) next unless glyph x_delta = glyph.x_max - glyph.x_min min_rsb << horiz_metrics.advance_width - horiz_metrics.left_side_bearing - x_delta max_extent << horiz_metrics.left_side_bearing + x_delta end [ max_aw.value_or(0), min_lsb.value_or(0), min_rsb.value_or(0), max_extent.value_or(0) ] end
Private Instance Methods
parse!()
click to toggle source
# File lib/ttfunk/table/hhea.rb, line 70 def parse! @version = read(4, 'N').first @ascent, @descent, @line_gap = read_signed(3) @advance_width_max = read(2, 'n').first @min_left_side_bearing, @min_right_side_bearing, @x_max_extent, @carot_slope_rise, @carot_slope_run, @caret_offset, _reserved, _reserved, _reserved, _reserved, @metric_data_format = read_signed(11) @number_of_metrics = read(2, 'n').first end