Class: Fontisan::Tables::Cff2::TableBuilder
- Inherits:
-
Fontisan::Tables::Cff::TableBuilder
- Object
- Fontisan::Tables::Cff::TableBuilder
- Fontisan::Tables::Cff2::TableBuilder
- Defined in:
- lib/fontisan/tables/cff2/table_builder.rb
Overview
Rebuilds CFF2 table with modifications while preserving variation data
CFF2TableBuilder extends CFF TableBuilder to handle CFF2-specific structures including Variable Store and blend operators in CharStrings. It preserves variation data while applying hints to variable fonts.
Key Principles:
-
Variable Store is read-only and preserved unchanged
-
Blend operators in CharStrings are maintained
-
Blend in Private DICT is preserved
-
Reuses Phase 1+2 infrastructure for CharString modification
Reference: Adobe Technical Note #5177 (CFF2)
Constant Summary collapse
- INVALID_CFF_KEYS =
CFF2-specific operators not supported by CFF DictBuilder
[24].freeze
Instance Attribute Summary collapse
-
#num_axes ⇒ Integer
readonly
Number of variation axes.
-
#reader ⇒ CFF2TableReader
readonly
CFF2 table reader.
-
#variable_store ⇒ Hash?
readonly
Variable Store data.
Instance Method Summary collapse
-
#build ⇒ String
Build CFF2 table with hints applied.
-
#initialize(reader, hint_set = nil) ⇒ TableBuilder
constructor
Initialize builder with CFF2 table reader and hint set.
-
#variable? ⇒ Boolean
Check if table has variation data.
Methods inherited from Fontisan::Tables::Cff::TableBuilder
#apply_modifications, rebuild, #serialize
Constructor Details
#initialize(reader, hint_set = nil) ⇒ TableBuilder
Initialize builder with CFF2 table reader and hint set
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fontisan/tables/cff2/table_builder.rb', line 50 def initialize(reader, hint_set = nil) @reader = reader @hint_set = hint_set # Read CFF2 structures @reader.read_header @reader.read_top_dict @variable_store = @reader.read_variable_store # Determine number of axes from Variable Store @num_axes = extract_num_axes # Don't call super - CFF2 has different structure end |
Instance Attribute Details
#num_axes ⇒ Integer (readonly)
Returns Number of variation axes.
44 45 46 |
# File 'lib/fontisan/tables/cff2/table_builder.rb', line 44 def num_axes @num_axes end |
#reader ⇒ CFF2TableReader (readonly)
Returns CFF2 table reader.
38 39 40 |
# File 'lib/fontisan/tables/cff2/table_builder.rb', line 38 def reader @reader end |
#variable_store ⇒ Hash? (readonly)
Returns Variable Store data.
41 42 43 |
# File 'lib/fontisan/tables/cff2/table_builder.rb', line 41 def variable_store @variable_store end |
Instance Method Details
#build ⇒ String
Build CFF2 table with hints applied
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/fontisan/tables/cff2/table_builder.rb', line 68 def build # Check if we need to modify anything return @reader.data unless should_modify? # Extract and modify sections header_data = extract_header top_dict_hash = @reader.top_dict charstrings_data = extract_and_modify_charstrings private_dict_data = extract_and_modify_private_dict vstore_data = extract_variable_store # Rebuild CFF2 table rebuild_cff2_table( header: header_data, top_dict: top_dict_hash, charstrings: charstrings_data, private_dict: private_dict_data, vstore: vstore_data, ) end |
#variable? ⇒ Boolean
Check if table has variation data
92 93 94 |
# File 'lib/fontisan/tables/cff2/table_builder.rb', line 92 def variable? !@variable_store.nil? end |