Class: Fontisan::Variable::StaticFontBuilder
- Inherits:
-
Object
- Object
- Fontisan::Variable::StaticFontBuilder
- Defined in:
- lib/fontisan/variable/static_font_builder.rb
Overview
Builds static font instances from variable font data
This class takes a variable font and applied variation data, then constructs a complete static font by:
- Copying all non-variation tables unchanged
- Removing variation-specific tables (fvar, gvar, HVAR, etc.)
- Updating metric tables (hmtx, hhea) with varied values
- Updating head table's modified timestamp
- Writing the complete static font binary
The result is a valid static font at the specified instance point.
Constant Summary collapse
- VARIATION_TABLES =
Tables to remove from static font (variation-specific)
%w[fvar avar gvar cvar HVAR VVAR MVAR STAT].freeze
Instance Attribute Summary collapse
-
#table_updater ⇒ TableUpdater
readonly
Table updater instance.
Instance Method Summary collapse
-
#build(varied_metrics = {}, font_metrics = {}, options = {}) ⇒ String
Build static font from varied data.
-
#build_to_file(output_path, varied_metrics = {}, font_metrics = {}, options = {}) ⇒ Integer
Build static font and write to file.
-
#initialize(font) ⇒ StaticFontBuilder
constructor
Initialize the builder.
Constructor Details
#initialize(font) ⇒ StaticFontBuilder
Initialize the builder
30 31 32 33 |
# File 'lib/fontisan/variable/static_font_builder.rb', line 30 def initialize(font) @font = font @table_updater = TableUpdater.new end |
Instance Attribute Details
#table_updater ⇒ TableUpdater (readonly)
Returns Table updater instance.
25 26 27 |
# File 'lib/fontisan/variable/static_font_builder.rb', line 25 def table_updater @table_updater end |
Instance Method Details
#build(varied_metrics = {}, font_metrics = {}, options = {}) ⇒ String
Build static font from varied data
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fontisan/variable/static_font_builder.rb', line 44 def build(varied_metrics = {}, font_metrics = {}, = {}) # Collect tables for static font tables = collect_tables(varied_metrics, font_metrics, ) # Detect sfnt version sfnt_version = detect_sfnt_version(tables) # Write font using FontWriter FontWriter.write_font(tables, sfnt_version: sfnt_version) end |
#build_to_file(output_path, varied_metrics = {}, font_metrics = {}, options = {}) ⇒ Integer
Build static font and write to file
62 63 64 65 66 |
# File 'lib/fontisan/variable/static_font_builder.rb', line 62 def build_to_file(output_path, varied_metrics = {}, font_metrics = {}, = {}) binary = build(varied_metrics, font_metrics, ) File.binwrite(output_path, binary) end |