Class: Fontisan::Subset::Builder
- Inherits:
-
Object
- Object
- Fontisan::Subset::Builder
- Defined in:
- lib/fontisan/subset/builder.rb
Overview
Main font subsetting engine
The [‘Builder`](lib/fontisan/subset/builder.rb) class orchestrates the entire subsetting process:
-
Validates input parameters
-
Calculates glyph closure (including composite dependencies)
-
Builds glyph ID mapping (old GID → new GID)
-
Subsets each table according to the selected profile
-
Assembles the final subset font binary
The subsetting process ensures that .notdef (GID 0) is always included as the first glyph, as required by the OpenType specification.
Reference: [‘docs/ttfunk-feature-analysis.md:455-492`](docs/ttfunk-feature-analysis.md:455)
Instance Attribute Summary collapse
-
#closure ⇒ Set<Integer>
readonly
Complete set of glyph IDs after closure calculation.
-
#font ⇒ TrueTypeFont, OpenTypeFont
readonly
Font instance to subset.
-
#glyph_ids ⇒ Array<Integer>
readonly
Base set of glyph IDs requested for subsetting.
-
#mapping ⇒ GlyphMapping
readonly
Glyph ID mapping (old GID → new GID).
-
#options ⇒ Options
readonly
Subsetting options.
Instance Method Summary collapse
-
#build ⇒ String
Build the subset font.
-
#initialize(font, glyph_ids, options = {}) ⇒ Builder
constructor
Initialize a new subsetting builder.
Constructor Details
#initialize(font, glyph_ids, options = {}) ⇒ Builder
Initialize a new subsetting builder
74 75 76 77 78 79 80 |
# File 'lib/fontisan/subset/builder.rb', line 74 def initialize(font, glyph_ids, = {}) @font = font @glyph_ids = Array(glyph_ids) @options = .is_a?(Options) ? : Options.new() @closure = nil @mapping = nil end |
Instance Attribute Details
#closure ⇒ Set<Integer> (readonly)
Complete set of glyph IDs after closure calculation
59 60 61 |
# File 'lib/fontisan/subset/builder.rb', line 59 def closure @closure end |
#font ⇒ TrueTypeFont, OpenTypeFont (readonly)
Font instance to subset
47 48 49 |
# File 'lib/fontisan/subset/builder.rb', line 47 def font @font end |
#glyph_ids ⇒ Array<Integer> (readonly)
Base set of glyph IDs requested for subsetting
51 52 53 |
# File 'lib/fontisan/subset/builder.rb', line 51 def glyph_ids @glyph_ids end |
#mapping ⇒ GlyphMapping (readonly)
Glyph ID mapping (old GID → new GID)
63 64 65 |
# File 'lib/fontisan/subset/builder.rb', line 63 def mapping @mapping end |
#options ⇒ Options (readonly)
Subsetting options
55 56 57 |
# File 'lib/fontisan/subset/builder.rb', line 55 def @options end |
Instance Method Details
#build ⇒ String
Build the subset font
This is the main entry point that performs the entire subsetting workflow:
-
Validates all input parameters
-
Calculates the glyph closure (composite dependencies)
-
Builds the glyph ID mapping
-
Subsets all required tables
-
Assembles the final font binary
99 100 101 102 103 104 105 |
# File 'lib/fontisan/subset/builder.rb', line 99 def build validate_input! calculate_closure build_mapping tables = subset_tables assemble_font(tables) end |