Module: Fontisan::Ufo::Compile::Cff
- Defined in:
- lib/fontisan/ufo/compile/cff.rb
Overview
Builds the OpenType CFF table from UFO glyphs.
Pipeline:
1. Convert each UFO glyph's contours to a Models::Outline
(cubic Bezier commands).
2. Encode each outline as a Type 2 charstring via the
existing `Tables::Cff::CharStringBuilder`.
3. Build the CFF structural INDEXes (Name, Top DICT, String,
Global Subr, CharStrings) with correct offsets.
The Top DICT references absolute offsets to the charset, charstrings, and private dict. Those offsets depend on the size of everything that comes before them — including the Top DICT itself. We resolve the circular dependency with a fixed-point iteration: build the Top DICT, compute offsets, rebuild the Top DICT with the new offsets, repeat until it converges (typically 2 iterations).
Class Method Summary collapse
-
.build(font, glyphs:) ⇒ String
CFF table bytes.
Class Method Details
.build(font, glyphs:) ⇒ String
Returns CFF table bytes.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fontisan/ufo/compile/cff.rb', line 29 def self.build(font, glyphs:) name = font.info.postscript_font_name || font.info.family_name || "Untitled" charstrings = glyphs.map { |g| charstring_for(g) } private_dict = +"" layout = compute_layout(name: name, glyphs: glyphs, charstrings: charstrings, private_dict: private_dict) assemble(layout: layout) end |