Class: Fontisan::Subset::TableStrategy::Head

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

Overview

Head strategy: recompute xMin/yMin/xMax/yMax (offsets 36–43) from the subset's actual glyphs. The source TTC's bbox covers every donor font in the collection and is far larger than any per-block subset needs; an inflated bbox makes browsers render glyphs at the wrong visual size. The remaining head fields pass through unchanged — checksumAdjustment is rewritten by FontWriter.

Class Method Summary collapse

Class Method Details

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

Returns binary head bytes for the subset.

Parameters:

  • context (SubsetContext)
  • tag (String)

    "head"

  • table (Head)

    parsed head table (unused)

Returns:

  • (String)

    binary head bytes for the subset



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fontisan/subset/table_strategy/head.rb', line 17

def self.call(context:, tag:, table:)
  ensure_glyf_built!(context)

  data = context.font.table_data["head"].dup
  bbox = context.state.subset_bbox
  return data unless bbox

  x_min, y_min, x_max, y_max = bbox
  data[36, 8] = [x_min, y_min, x_max, y_max].pack("n4")
  data
end