Module: Fontisan::Ufo::Compile::Cff2
- Defined in:
- lib/fontisan/ufo/compile/cff2.rb
Overview
Builds the OpenType CFF2 table from UFO glyphs.
CFF2 is simpler than CFF1: no Name INDEX, String INDEX, Encoding, or Charset. The Top DICT references CharStrings and a Font DICT INDEX (which wraps at least one Font DICT pointing to a Private DICT).
Layout (static font, single Font DICT, empty Private DICT):
Header (5 bytes)
Top DICT (variable — offsets to CharStrings + Font DICT INDEX)
Global Subr INDEX (4 bytes — empty)
CharStrings INDEX (variable)
Font DICT INDEX (variable — wraps one Font DICT)
Font DICT: DICT with Private operator [0, 0] (empty Private)
The Top DICT offsets depend on the Top DICT's own size — a circular dependency resolved with fixed-point iteration (the same pattern as the CFF1 builder).
Constant Summary collapse
- CHARSTRINGS_OPERATOR =
CFF2 Top DICT operator encodings.
17- VARIATION_STORE_OPERATOR =
0x11
24- FONT_DICT_INDEX_OPERATOR =
0x18
[12, 36].freeze
- PRIVATE_OPERATOR =
0x12
18
Class Method Summary collapse
-
.build(font, glyphs:, masters: nil, axis_count: nil, variation_store: nil) ⇒ String
CFF2 table bytes.
Class Method Details
.build(font, glyphs:, masters: nil, axis_count: nil, variation_store: nil) ⇒ String
Returns CFF2 table bytes.
45 46 47 48 49 50 51 52 |
# File 'lib/fontisan/ufo/compile/cff2.rb', line 45 def self.build(font, glyphs:, masters: nil, axis_count: nil, variation_store: nil) if masters&.any? build_variable(font, glyphs, masters, axis_count) else build_static(font, glyphs, variation_store:) end end |