Class: Fontisan::Subset::Builder
- Inherits:
-
Object
- Object
- Fontisan::Subset::Builder
- Defined in:
- lib/fontisan/subset/builder.rb
Overview
Main font subsetting engine
The Builder 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
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
68 69 70 71 72 73 74 |
# File 'lib/fontisan/subset/builder.rb', line 68 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
53 54 55 |
# File 'lib/fontisan/subset/builder.rb', line 53 def closure @closure end |
#font ⇒ TrueTypeFont, OpenTypeFont (readonly)
Font instance to subset
41 42 43 |
# File 'lib/fontisan/subset/builder.rb', line 41 def font @font end |
#glyph_ids ⇒ Array<Integer> (readonly)
Base set of glyph IDs requested for subsetting
45 46 47 |
# File 'lib/fontisan/subset/builder.rb', line 45 def glyph_ids @glyph_ids end |
#mapping ⇒ GlyphMapping (readonly)
Glyph ID mapping (old GID → new GID)
57 58 59 |
# File 'lib/fontisan/subset/builder.rb', line 57 def mapping @mapping end |
#options ⇒ Options (readonly)
Subsetting options
49 50 51 |
# File 'lib/fontisan/subset/builder.rb', line 49 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
93 94 95 96 97 98 99 |
# File 'lib/fontisan/subset/builder.rb', line 93 def build validate_input! calculate_closure build_mapping tables = subset_tables assemble_font(tables) end |