Module: Fontisan::Ufo::Compile::Hvar
- Defined in:
- lib/fontisan/ufo/compile/hvar.rb
Overview
Builds the OpenType HVAR (Horizontal Metrics Variation) table.
Stores advance-width variation deltas per glyph, enabling variable-font renderers to adjust spacing without loading gvar.
Class Method Summary collapse
-
.build(default_widths:, master_widths:, axis_count:) ⇒ String
HVAR table bytes.
Class Method Details
.build(default_widths:, master_widths:, axis_count:) ⇒ String
Returns HVAR table bytes.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fontisan/ufo/compile/hvar.rb', line 17 def self.build(default_widths:, master_widths:, axis_count:) glyph_count = default_widths.size master_count = master_widths.size # Compute deltas: deltas[glyph][master] = master_width - default_width deltas = Array.new(glyph_count) do |gid| Array.new(master_count) do |mid| master_widths.dig(mid, gid).to_i - default_widths[gid].to_i end end store = ItemVariationStore.build( axis_count: axis_count, master_count: master_count, item_count: glyph_count, deltas: deltas, ) # HVAR header: version(4) + itemVariationStoreOffset(4) + # advanceWidthMappingOffset(4) + lsbMappingOffset(4) + rsbMappingOffset(4) [0x00010000, 20].pack("NN") + [0, 0, 0].pack("NNN") + store end |