Class: Fontisan::Tables::Cff::TableBuilder
- Inherits:
-
Object
- Object
- Fontisan::Tables::Cff::TableBuilder
- Defined in:
- lib/fontisan/tables/cff/table_builder.rb
Overview
Rebuilds CFF table with modifications
This builder extracts sections from a source CFF table, applies modifications (e.g., hint parameters to Private DICT), recalculates offsets, and assembles a new CFF table.
Process:
-
Extract all CFF sections (header, indexes, dicts)
-
Apply modifications to Private DICT
-
Recalculate offsets (charstrings, private)
-
Rebuild Top DICT INDEX with new offsets
-
Reassemble all sections into new CFF table
Direct Known Subclasses
Class Method Summary collapse
-
.rebuild(source_cff, modifications = {}) ⇒ String
Rebuild CFF table with modifications.
Instance Method Summary collapse
-
#apply_modifications(mods) ⇒ Object
Apply modifications to CFF structure.
-
#initialize(source_cff) ⇒ TableBuilder
constructor
Initialize with source CFF.
-
#serialize ⇒ String
Serialize to binary CFF table.
Constructor Details
#initialize(source_cff) ⇒ TableBuilder
Initialize with source CFF
46 47 48 49 |
# File 'lib/fontisan/tables/cff/table_builder.rb', line 46 def initialize(source_cff) @source = source_cff @sections = extract_sections end |
Class Method Details
.rebuild(source_cff, modifications = {}) ⇒ String
Rebuild CFF table with modifications
37 38 39 40 41 |
# File 'lib/fontisan/tables/cff/table_builder.rb', line 37 def self.rebuild(source_cff, modifications = {}) new(source_cff).tap do |builder| builder.apply_modifications(modifications) end.serialize end |
Instance Method Details
#apply_modifications(mods) ⇒ Object
Apply modifications to CFF structure
54 55 56 57 |
# File 'lib/fontisan/tables/cff/table_builder.rb', line 54 def apply_modifications(mods) update_private_dict(mods[:private_dict_hints]) if mods[:private_dict_hints] update_charstrings(mods[:per_glyph_hints]) if mods[:per_glyph_hints] end |
#serialize ⇒ String
Serialize to binary CFF table
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fontisan/tables/cff/table_builder.rb', line 62 def serialize # Calculate initial offsets offsets = OffsetRecalculator.calculate_offsets(@sections) top_dict = extract_top_dict_data updated = OffsetRecalculator.update_top_dict(top_dict, offsets) rebuild_top_dict_index(updated) # Recalculate after Top DICT rebuild (size may change) offsets = OffsetRecalculator.calculate_offsets(@sections) updated = OffsetRecalculator.update_top_dict(top_dict, offsets) rebuild_top_dict_index(updated) assemble end |