Class: Fontisan::Ufo::Compile::VariableOtf
- Inherits:
-
Object
- Object
- Fontisan::Ufo::Compile::VariableOtf
- Defined in:
- lib/fontisan/ufo/compile/variable_otf.rb
Overview
VariableOtf — produces a variable OTF with CFF2 outlines.
The orchestrator assembles a default-master UFO plus variation masters into a variable OpenType font with:
- CFF2 outlines with blend operators for each varying coordinate
- ItemVariationStore embedded in the CFF2 table (regions only;
deltas live in charstring blend operands)
- fvar (axes + instances)
- STAT (style attributes)
- avar (axis remapping, when maps are provided)
Instance Method Summary collapse
-
#build_tables ⇒ Hash<String,String>
Build all tables for the variable OTF.
-
#compile(output_path:) ⇒ String
Compile the variable OTF directly to the output path.
-
#initialize(default_font, master_fonts: [], axes: [], instances: []) ⇒ VariableOtf
constructor
A new instance of VariableOtf.
Constructor Details
#initialize(default_font, master_fonts: [], axes: [], instances: []) ⇒ VariableOtf
Returns a new instance of VariableOtf.
25 26 27 28 29 30 |
# File 'lib/fontisan/ufo/compile/variable_otf.rb', line 25 def initialize(default_font, master_fonts: [], axes: [], instances: []) @default = default_font @masters = master_fonts @axes = axes @instances = instances end |
Instance Method Details
#build_tables ⇒ Hash<String,String>
Build all tables for the variable OTF.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fontisan/ufo/compile/variable_otf.rb', line 47 def build_tables glyphs = @default.glyphs.values tables = { "head" => Head.build(@default, glyphs: glyphs, loca_format: Head::LOCA_FORMAT_LONG), "hhea" => Hhea.build(@default, glyphs: glyphs), "maxp" => Maxp.build(@default, glyphs: glyphs, version: Maxp::VERSION_OPEN_TYPE), "OS/2" => Os2.build(@default, glyphs: glyphs), "name" => Name.build(@default), "post" => Post.build(@default), "hmtx" => Hmtx.build(@default, glyphs: glyphs), "cmap" => Cmap.build(@default, glyphs: glyphs), "CFF2" => build_cff2(glyphs), "fvar" => Fvar.build(@default, axes: @axes, instances: @instances), "STAT" => Stat.build(axes: @axes), } avar_bytes = Avar.build(axes: @axes) tables["avar"] = avar_bytes if avar_bytes tables end |
#compile(output_path:) ⇒ String
Compile the variable OTF directly to the output path.
35 36 37 38 39 40 41 42 43 |
# File 'lib/fontisan/ufo/compile/variable_otf.rb', line 35 def compile(output_path:) tables = build_tables Fontisan::FontWriter.write_to_file( tables.transform_values { |t| t.is_a?(String) ? t : t.to_binary_s }, output_path, sfnt_version: 0x4F54544F, ) output_path end |