Class: Fontisan::Ufo::Compile::VariableTtf

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/ufo/compile/variable_ttf.rb

Overview

Orchestrates compilation of a UFO source plus its variation masters into a single variable TrueType font.

Pipeline:

default UFO font
│
├─ TtfCompiler tables (head, hhea, maxp, OS/2, name,
│                     post, hmtx, cmap, glyf, loca)
│
├─ fvar  (axes + named instances)
├─ gvar  (per-glyph point deltas across masters)
├─ HVAR  (advance-width deltas across masters)
├─ MVAR  (font-wide metric deltas across masters)
├─ avar  (per-axis non-linear maps; defaults to identity)
└─ STAT  (style attributes for OS matching)

Masters are supplied as an Array of Hashes, each with:

- :font   — the master UFO::Font
- :axes   — Hash<String, Float> mapping axis tag → region peak

Constant Summary collapse

SFNT_VERSION =
BaseCompiler::SFNT_VERSION_TRUE_TYPE

Instance Method Summary collapse

Constructor Details

#initialize(font:, axes:, masters:, instances: nil, stat_axis_values: nil, stat_elided_name_id: nil, default_metrics: nil, master_metrics: nil) ⇒ VariableTtf

Returns a new instance of VariableTtf.

Parameters:

  • font (Fontisan::Ufo::Font)

    default master

  • axes (Array<Hash>)

    axis definitions (tag, min/default/max, optional name_id, ordering, maps)

  • masters (Array<Hash>)

    each master: { font:, axes: }

  • instances (Array<Hash>) (defaults to: nil)

    named instances for fvar

  • stat_axis_values (Array<Hash>, nil) (defaults to: nil)

    STAT axis value records

  • stat_elided_name_id (Integer, nil) (defaults to: nil)

    STAT elided fallback name

  • default_metrics (Hash<Symbol, Integer>, nil) (defaults to: nil)

    MVAR defaults

  • master_metrics (Array<Hash<Symbol, Integer>>, nil) (defaults to: nil)

    MVAR per-master



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fontisan/ufo/compile/variable_ttf.rb', line 39

def initialize(font:, axes:, masters:, instances: nil,
               stat_axis_values: nil, stat_elided_name_id: nil,
               default_metrics: nil, master_metrics: nil)
  @font = font
  @axes = axes
  @masters = masters
  @instances = instances
  @stat_axis_values = stat_axis_values
  @stat_elided_name_id = stat_elided_name_id
  @default_metrics = default_metrics
  @master_metrics = master_metrics
end

Instance Method Details

#compile(output_path:) ⇒ String

Returns the output path.

Parameters:

  • output_path (String)

Returns:

  • (String)

    the output path



54
55
56
57
58
# File 'lib/fontisan/ufo/compile/variable_ttf.rb', line 54

def compile(output_path:)
  tables = base_tables.merge(variation_tables)
  write(tables, output_path)
  output_path
end