Module: Fontisan::Ufo::Compile::Gvar
- Defined in:
- lib/fontisan/ufo/compile/gvar.rb
Overview
Builds the OpenType gvar (Glyph Variation Data) table from
per-glyph deltas computed between a default master and one or
more extreme masters.
This is the hardest table in the variable-font specification. It stores, for every glyph, how each outline point moves between the default master and each extreme master.
This builder produces a minimal-but-valid gvar:
- One tuple per master (no shared tuples)
- Explicit per-point deltas (no IUP compression)
- Delta values encoded as int8 when possible, int16 otherwise
Constant Summary collapse
- VERSION_MAJOR =
1- VERSION_MINOR =
0- TUPLE_SHARED =
TupleIndex flags
0x8000- TUPLE_PRIVATE =
0x4000- TUPLE_AXIS_COUNT_MASK =
0x0FFF- DELTAS_ARE_ZERO =
Delta encoding flags (in the delta data header)
0x80- DELTAS_ARE_INT8 =
0x40- POINT_COUNT_MASK =
0x3FFF
Class Method Summary collapse
-
.build(default_glyphs:, masters:, axis_count:) ⇒ String
Gvar table bytes.
Class Method Details
.build(default_glyphs:, masters:, axis_count:) ⇒ String
Returns gvar table bytes.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fontisan/ufo/compile/gvar.rb', line 39 def self.build(default_glyphs:, masters:, axis_count:) glyph_count = default_glyphs.size return build_empty(glyph_count) if masters.empty? || glyph_count.zero? # Compute per-glyph variation data glyph_data = Array.new(glyph_count) do |gid| build_glyph_variation(default_glyphs[gid], masters, gid, axis_count) end assemble(glyph_count, axis_count, glyph_data) end |