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 (static — blend/vsindex operators are TODO 07/18)
- fvar (axes + instances)
- STAT (style attributes)
- avar (axis remapping, when maps are provided)
NOTE: the CFF2 table currently contains static outlines (no VariationStore, no blend operators). Full variable CFF2 requires TODO 07 (blend/vsindex) and TODO 18 (blend integration) to be wired into the charstring builder.
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.
28 29 30 31 32 33 |
# File 'lib/fontisan/ufo/compile/variable_otf.rb', line 28 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.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fontisan/ufo/compile/variable_otf.rb', line 50 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" => Cff2.build(@default, glyphs: 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.
38 39 40 41 42 43 44 45 46 |
# File 'lib/fontisan/ufo/compile/variable_otf.rb', line 38 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 |