Module: Fontisan::Converters::CffTableBuilder
- Included in:
- OutlineConverter, Type1Converter
- Defined in:
- lib/fontisan/converters/cff_table_builder.rb
Overview
Builds CFF table data from glyph outlines
This module handles the construction of complete CFF tables including all INDEX structures (name, Top DICT, String, GlobalSubr, CharStrings, LocalSubr) and the Private DICT.
The CFF table structure is:
-
Header (4 bytes)
-
Name INDEX
-
Top DICT INDEX
-
String INDEX
-
Global Subr INDEX
-
CharStrings INDEX
-
Private DICT (with offset in Top DICT)
-
Local Subr INDEX (with offset in Private DICT)
Instance Method Summary collapse
-
#build_cff_table(charstrings, local_subrs, font) ⇒ String
Build complete CFF table from pre-built charstrings.
Instance Method Details
#build_cff_table(charstrings, local_subrs, font) ⇒ String
Build complete CFF table from pre-built charstrings
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fontisan/converters/cff_table_builder.rb', line 30 def build_cff_table(charstrings, local_subrs, font) # If we have local subrs from optimization, use them local_subrs = [] unless local_subrs.is_a?(Array) # Build font metadata font_name = extract_font_name(font) # Build all INDEXes header_size = 4 name_index_data = Tables::Cff::IndexBuilder.build([font_name]) string_index_data = Tables::Cff::IndexBuilder.build([]) # Empty strings global_subr_index_data = Tables::Cff::IndexBuilder.build([]) # Empty global subrs charstrings_index_data = Tables::Cff::IndexBuilder.build(charstrings) local_subrs_index_data = Tables::Cff::IndexBuilder.build(local_subrs) # Build Private DICT with Subrs offset if we have local subroutines private_dict_data, private_dict_size = build_private_dict(local_subrs) # Calculate offsets with iterative refinement top_dict_index_data, = calculate_cff_offsets( header_size, name_index_data, string_index_data, global_subr_index_data, charstrings_index_data, private_dict_size, ) # Build CFF Header header = build_cff_header # Assemble complete CFF table header + name_index_data + top_dict_index_data + string_index_data + global_subr_index_data + charstrings_index_data + private_dict_data + local_subrs_index_data end |