Class: Fontisan::Subset::TableStrategy::Hhea

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/subset/table_strategy/hhea.rb

Overview

Hhea strategy: rewrite numberOfHMetrics (offset 34, uint16) and advanceWidthMax (offset 10, uint16). The source TTC's advanceWidthMax covers every donor font and can be far larger than any per-block subset needs; recomputing from the subset's actual hmtx keeps the value honest.

Hhea runs alphabetically before Hmtx, so the Hmtx strategy's SharedState cache hasn't been populated yet — we walk the source hmtx directly to find the max.

Class Method Summary collapse

Class Method Details

.call(context:, tag:, table:) ⇒ String

Returns binary hhea bytes for the subset.

Parameters:

Returns:

  • (String)

    binary hhea bytes for the subset



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fontisan/subset/table_strategy/hhea.rb', line 20

def self.call(context:, tag:, table:)
  data = table.to_binary_s.dup

  new_num_h_metrics = calculate_number_of_h_metrics(context, table)
  data[34, 2] = [new_num_h_metrics].pack("n")

  new_max = compute_subset_max_advance(context)
  data[10, 2] = [new_max].pack("n") if new_max.positive?

  data
end