fontisan 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +529 -65
  3. data/Gemfile +1 -0
  4. data/LICENSE +5 -1
  5. data/README.adoc +1301 -275
  6. data/Rakefile +27 -2
  7. data/benchmark/variation_quick_bench.rb +47 -0
  8. data/docs/EXTRACT_TTC_MIGRATION.md +549 -0
  9. data/fontisan.gemspec +4 -1
  10. data/lib/fontisan/binary/base_record.rb +22 -1
  11. data/lib/fontisan/cli.rb +309 -0
  12. data/lib/fontisan/collection/builder.rb +260 -0
  13. data/lib/fontisan/collection/offset_calculator.rb +227 -0
  14. data/lib/fontisan/collection/table_analyzer.rb +204 -0
  15. data/lib/fontisan/collection/table_deduplicator.rb +241 -0
  16. data/lib/fontisan/collection/writer.rb +306 -0
  17. data/lib/fontisan/commands/base_command.rb +8 -1
  18. data/lib/fontisan/commands/convert_command.rb +291 -0
  19. data/lib/fontisan/commands/export_command.rb +161 -0
  20. data/lib/fontisan/commands/info_command.rb +40 -6
  21. data/lib/fontisan/commands/instance_command.rb +295 -0
  22. data/lib/fontisan/commands/ls_command.rb +113 -0
  23. data/lib/fontisan/commands/pack_command.rb +241 -0
  24. data/lib/fontisan/commands/subset_command.rb +245 -0
  25. data/lib/fontisan/commands/unpack_command.rb +338 -0
  26. data/lib/fontisan/commands/validate_command.rb +178 -0
  27. data/lib/fontisan/commands/variable_command.rb +30 -1
  28. data/lib/fontisan/config/collection_settings.yml +56 -0
  29. data/lib/fontisan/config/conversion_matrix.yml +212 -0
  30. data/lib/fontisan/config/export_settings.yml +66 -0
  31. data/lib/fontisan/config/subset_profiles.yml +100 -0
  32. data/lib/fontisan/config/svg_settings.yml +60 -0
  33. data/lib/fontisan/config/validation_rules.yml +149 -0
  34. data/lib/fontisan/config/variable_settings.yml +99 -0
  35. data/lib/fontisan/config/woff2_settings.yml +77 -0
  36. data/lib/fontisan/constants.rb +69 -0
  37. data/lib/fontisan/converters/conversion_strategy.rb +96 -0
  38. data/lib/fontisan/converters/format_converter.rb +259 -0
  39. data/lib/fontisan/converters/outline_converter.rb +936 -0
  40. data/lib/fontisan/converters/svg_generator.rb +244 -0
  41. data/lib/fontisan/converters/table_copier.rb +117 -0
  42. data/lib/fontisan/converters/woff2_encoder.rb +416 -0
  43. data/lib/fontisan/converters/woff_writer.rb +391 -0
  44. data/lib/fontisan/error.rb +203 -0
  45. data/lib/fontisan/export/exporter.rb +262 -0
  46. data/lib/fontisan/export/table_serializer.rb +255 -0
  47. data/lib/fontisan/export/transformers/font_to_ttx.rb +172 -0
  48. data/lib/fontisan/export/transformers/head_transformer.rb +96 -0
  49. data/lib/fontisan/export/transformers/hhea_transformer.rb +59 -0
  50. data/lib/fontisan/export/transformers/maxp_transformer.rb +63 -0
  51. data/lib/fontisan/export/transformers/name_transformer.rb +63 -0
  52. data/lib/fontisan/export/transformers/os2_transformer.rb +121 -0
  53. data/lib/fontisan/export/transformers/post_transformer.rb +51 -0
  54. data/lib/fontisan/export/ttx_generator.rb +527 -0
  55. data/lib/fontisan/export/ttx_parser.rb +300 -0
  56. data/lib/fontisan/font_loader.rb +121 -12
  57. data/lib/fontisan/font_writer.rb +301 -0
  58. data/lib/fontisan/formatters/text_formatter.rb +102 -0
  59. data/lib/fontisan/glyph_accessor.rb +503 -0
  60. data/lib/fontisan/hints/hint_converter.rb +177 -0
  61. data/lib/fontisan/hints/postscript_hint_applier.rb +185 -0
  62. data/lib/fontisan/hints/postscript_hint_extractor.rb +254 -0
  63. data/lib/fontisan/hints/truetype_hint_applier.rb +71 -0
  64. data/lib/fontisan/hints/truetype_hint_extractor.rb +162 -0
  65. data/lib/fontisan/loading_modes.rb +113 -0
  66. data/lib/fontisan/metrics_calculator.rb +277 -0
  67. data/lib/fontisan/models/collection_font_summary.rb +52 -0
  68. data/lib/fontisan/models/collection_info.rb +76 -0
  69. data/lib/fontisan/models/collection_list_info.rb +37 -0
  70. data/lib/fontisan/models/font_export.rb +158 -0
  71. data/lib/fontisan/models/font_summary.rb +48 -0
  72. data/lib/fontisan/models/glyph_outline.rb +343 -0
  73. data/lib/fontisan/models/hint.rb +233 -0
  74. data/lib/fontisan/models/outline.rb +664 -0
  75. data/lib/fontisan/models/table_sharing_info.rb +40 -0
  76. data/lib/fontisan/models/ttx/glyph_order.rb +31 -0
  77. data/lib/fontisan/models/ttx/tables/binary_table.rb +67 -0
  78. data/lib/fontisan/models/ttx/tables/head_table.rb +74 -0
  79. data/lib/fontisan/models/ttx/tables/hhea_table.rb +74 -0
  80. data/lib/fontisan/models/ttx/tables/maxp_table.rb +55 -0
  81. data/lib/fontisan/models/ttx/tables/name_table.rb +45 -0
  82. data/lib/fontisan/models/ttx/tables/os2_table.rb +157 -0
  83. data/lib/fontisan/models/ttx/tables/post_table.rb +50 -0
  84. data/lib/fontisan/models/ttx/ttfont.rb +49 -0
  85. data/lib/fontisan/models/validation_report.rb +203 -0
  86. data/lib/fontisan/open_type_collection.rb +156 -2
  87. data/lib/fontisan/open_type_font.rb +296 -10
  88. data/lib/fontisan/optimizers/charstring_rewriter.rb +161 -0
  89. data/lib/fontisan/optimizers/pattern_analyzer.rb +308 -0
  90. data/lib/fontisan/optimizers/stack_tracker.rb +246 -0
  91. data/lib/fontisan/optimizers/subroutine_builder.rb +134 -0
  92. data/lib/fontisan/optimizers/subroutine_generator.rb +207 -0
  93. data/lib/fontisan/optimizers/subroutine_optimizer.rb +107 -0
  94. data/lib/fontisan/outline_extractor.rb +423 -0
  95. data/lib/fontisan/subset/builder.rb +268 -0
  96. data/lib/fontisan/subset/glyph_mapping.rb +215 -0
  97. data/lib/fontisan/subset/options.rb +142 -0
  98. data/lib/fontisan/subset/profile.rb +152 -0
  99. data/lib/fontisan/subset/table_subsetter.rb +461 -0
  100. data/lib/fontisan/svg/font_face_generator.rb +278 -0
  101. data/lib/fontisan/svg/font_generator.rb +264 -0
  102. data/lib/fontisan/svg/glyph_generator.rb +168 -0
  103. data/lib/fontisan/svg/view_box_calculator.rb +137 -0
  104. data/lib/fontisan/tables/cff/cff_glyph.rb +176 -0
  105. data/lib/fontisan/tables/cff/charset.rb +282 -0
  106. data/lib/fontisan/tables/cff/charstring.rb +905 -0
  107. data/lib/fontisan/tables/cff/charstring_builder.rb +322 -0
  108. data/lib/fontisan/tables/cff/charstrings_index.rb +162 -0
  109. data/lib/fontisan/tables/cff/dict.rb +351 -0
  110. data/lib/fontisan/tables/cff/dict_builder.rb +242 -0
  111. data/lib/fontisan/tables/cff/encoding.rb +274 -0
  112. data/lib/fontisan/tables/cff/header.rb +102 -0
  113. data/lib/fontisan/tables/cff/index.rb +237 -0
  114. data/lib/fontisan/tables/cff/index_builder.rb +170 -0
  115. data/lib/fontisan/tables/cff/private_dict.rb +284 -0
  116. data/lib/fontisan/tables/cff/top_dict.rb +236 -0
  117. data/lib/fontisan/tables/cff.rb +487 -0
  118. data/lib/fontisan/tables/cff2/blend_operator.rb +240 -0
  119. data/lib/fontisan/tables/cff2/charstring_parser.rb +591 -0
  120. data/lib/fontisan/tables/cff2/operand_stack.rb +232 -0
  121. data/lib/fontisan/tables/cff2.rb +341 -0
  122. data/lib/fontisan/tables/cvar.rb +242 -0
  123. data/lib/fontisan/tables/fvar.rb +2 -2
  124. data/lib/fontisan/tables/glyf/compound_glyph.rb +483 -0
  125. data/lib/fontisan/tables/glyf/compound_glyph_resolver.rb +136 -0
  126. data/lib/fontisan/tables/glyf/curve_converter.rb +343 -0
  127. data/lib/fontisan/tables/glyf/glyph_builder.rb +450 -0
  128. data/lib/fontisan/tables/glyf/simple_glyph.rb +382 -0
  129. data/lib/fontisan/tables/glyf.rb +235 -0
  130. data/lib/fontisan/tables/gvar.rb +270 -0
  131. data/lib/fontisan/tables/hhea.rb +124 -0
  132. data/lib/fontisan/tables/hmtx.rb +287 -0
  133. data/lib/fontisan/tables/hvar.rb +191 -0
  134. data/lib/fontisan/tables/loca.rb +322 -0
  135. data/lib/fontisan/tables/maxp.rb +192 -0
  136. data/lib/fontisan/tables/mvar.rb +185 -0
  137. data/lib/fontisan/tables/name.rb +99 -30
  138. data/lib/fontisan/tables/variation_common.rb +346 -0
  139. data/lib/fontisan/tables/vvar.rb +234 -0
  140. data/lib/fontisan/true_type_collection.rb +156 -2
  141. data/lib/fontisan/true_type_font.rb +297 -11
  142. data/lib/fontisan/utilities/brotli_wrapper.rb +159 -0
  143. data/lib/fontisan/utilities/checksum_calculator.rb +18 -0
  144. data/lib/fontisan/utils/thread_pool.rb +134 -0
  145. data/lib/fontisan/validation/checksum_validator.rb +170 -0
  146. data/lib/fontisan/validation/consistency_validator.rb +197 -0
  147. data/lib/fontisan/validation/structure_validator.rb +198 -0
  148. data/lib/fontisan/validation/table_validator.rb +158 -0
  149. data/lib/fontisan/validation/validator.rb +152 -0
  150. data/lib/fontisan/variable/axis_normalizer.rb +215 -0
  151. data/lib/fontisan/variable/delta_applicator.rb +313 -0
  152. data/lib/fontisan/variable/glyph_delta_processor.rb +218 -0
  153. data/lib/fontisan/variable/instancer.rb +344 -0
  154. data/lib/fontisan/variable/metric_delta_processor.rb +282 -0
  155. data/lib/fontisan/variable/region_matcher.rb +208 -0
  156. data/lib/fontisan/variable/static_font_builder.rb +213 -0
  157. data/lib/fontisan/variable/table_updater.rb +219 -0
  158. data/lib/fontisan/variation/blend_applier.rb +199 -0
  159. data/lib/fontisan/variation/cache.rb +298 -0
  160. data/lib/fontisan/variation/cache_key_builder.rb +162 -0
  161. data/lib/fontisan/variation/converter.rb +268 -0
  162. data/lib/fontisan/variation/data_extractor.rb +86 -0
  163. data/lib/fontisan/variation/delta_applier.rb +266 -0
  164. data/lib/fontisan/variation/delta_parser.rb +228 -0
  165. data/lib/fontisan/variation/inspector.rb +275 -0
  166. data/lib/fontisan/variation/instance_generator.rb +273 -0
  167. data/lib/fontisan/variation/interpolator.rb +231 -0
  168. data/lib/fontisan/variation/metrics_adjuster.rb +318 -0
  169. data/lib/fontisan/variation/optimizer.rb +418 -0
  170. data/lib/fontisan/variation/parallel_generator.rb +150 -0
  171. data/lib/fontisan/variation/region_matcher.rb +221 -0
  172. data/lib/fontisan/variation/subsetter.rb +463 -0
  173. data/lib/fontisan/variation/table_accessor.rb +105 -0
  174. data/lib/fontisan/variation/validator.rb +345 -0
  175. data/lib/fontisan/variation/variation_context.rb +211 -0
  176. data/lib/fontisan/version.rb +1 -1
  177. data/lib/fontisan/woff2/directory.rb +257 -0
  178. data/lib/fontisan/woff2/header.rb +101 -0
  179. data/lib/fontisan/woff2/table_transformer.rb +163 -0
  180. data/lib/fontisan/woff2_font.rb +712 -0
  181. data/lib/fontisan/woff_font.rb +483 -0
  182. data/lib/fontisan.rb +120 -0
  183. data/scripts/compare_stack_aware.rb +187 -0
  184. data/scripts/measure_optimization.rb +141 -0
  185. metadata +205 -4
@@ -0,0 +1,212 @@
1
+ # Font Format Conversion Matrix
2
+ #
3
+ # This file defines the supported font format conversions for Fontisan.
4
+ # Each conversion specifies a source format ('from') and target format ('to').
5
+ #
6
+ # Format identifiers:
7
+ # - ttf: TrueType Font (with glyf/loca tables)
8
+ # - otf: OpenType Font with CFF outlines (with CFF table)
9
+ # - woff: Web Open Font Format (not yet implemented)
10
+ # - woff2: Web Open Font Format 2 (implemented in Phase 2)
11
+ # - svg: SVG Font (implemented in Phase 2)
12
+ #
13
+ # Phase 1 (Milestone 1.3): Basic conversions
14
+ # - Same format (copy/optimize): ttf→ttf, otf→otf
15
+ # - Outline conversion: ttf↔otf (foundation implemented)
16
+ #
17
+ # Phase 2 (Milestone 2.1): Web font formats
18
+ # - WOFF2 compression: ttf to woff2, otf to woff2
19
+ #
20
+ # Phase 2 (Milestone 2.2): SVG font generation
21
+ # - SVG export: ttf to svg, otf to svg
22
+ #
23
+ # Future phases:
24
+ # - Phase 3: Variable font conversions
25
+
26
+ conversions:
27
+ # Same-format conversions (copy/optimize)
28
+ - from: ttf
29
+ to: ttf
30
+ strategy: table_copier
31
+ description: "Copy TrueType font with table optimization"
32
+ status: implemented
33
+
34
+ - from: otf
35
+ to: otf
36
+ strategy: table_copier
37
+ description: "Copy OpenType/CFF font with table optimization"
38
+ status: implemented
39
+
40
+ # Outline format conversions
41
+ - from: ttf
42
+ to: otf
43
+ strategy: outline_converter
44
+ description: "Convert TrueType outlines to CFF format"
45
+ status: foundation
46
+ notes: >
47
+ Foundation implemented. Full conversion requires complete CFF table
48
+ generation including CharString encoding, DICT structures, and
49
+ charset/encoding tables.
50
+
51
+ - from: otf
52
+ to: ttf
53
+ strategy: outline_converter
54
+ description: "Convert CFF outlines to TrueType format"
55
+ status: foundation
56
+ notes: >
57
+ Foundation implemented. Full conversion requires complete glyf/loca
58
+ table generation including cubic-to-quadratic curve conversion and
59
+ proper TrueType glyph structure encoding.
60
+
61
+ # Phase 2 conversions (Milestone 2.1) - WOFF2
62
+ - from: ttf
63
+ to: woff2
64
+ strategy: woff2_encoder
65
+ description: "Compress TrueType to WOFF2 format with Brotli"
66
+ status: implemented
67
+ notes: >
68
+ WOFF2 encoding with Brotli compression. Table transformations
69
+ are architectural placeholders for future optimization.
70
+
71
+ - from: otf
72
+ to: woff2
73
+ strategy: woff2_encoder
74
+ description: "Compress OpenType/CFF to WOFF2 format with Brotli"
75
+ status: implemented
76
+ notes: >
77
+ WOFF2 encoding with Brotli compression. Table transformations
78
+ are architectural placeholders for future optimization.
79
+
80
+ # Phase 2 conversions (Milestone 2.3) - WOFF
81
+ # NOTE: Temporarily disabled until WOFF writer bugs are fixed
82
+ # - from: ttf
83
+ # to: woff
84
+ # strategy: woff_writer
85
+ # description: "Compress TrueType to WOFF format with zlib"
86
+ # status: implemented
87
+ # notes: >
88
+ # WOFF 1.0 encoding with zlib compression. Supports optional metadata
89
+ # and private data blocks. Individual table compression for optimal
90
+ # file size reduction.
91
+
92
+ # - from: otf
93
+ # to: woff
94
+ # strategy: woff_writer
95
+ # description: "Compress OpenType/CFF to WOFF format with zlib"
96
+ # status: implemented
97
+ # notes: >
98
+ # WOFF 1.0 encoding with zlib compression. Supports optional metadata
99
+ # and private data blocks. Individual table compression for optimal
100
+ # file size reduction.
101
+
102
+ # Reverse WOFF conversions (WOFF → TTF/OTF)
103
+ - from: woff
104
+ to: ttf
105
+ strategy: woff_reader
106
+ description: "Extract TrueType from WOFF format"
107
+ status: implemented
108
+ notes: >
109
+ WOFF decompression with zlib. Preserves all font data and metadata.
110
+ Automatically detects font flavor from WOFF header.
111
+
112
+ - from: woff
113
+ to: otf
114
+ strategy: woff_reader
115
+ description: "Extract OpenType/CFF from WOFF format"
116
+ status: implemented
117
+ notes: >
118
+ WOFF decompression with zlib. Preserves all font data and metadata.
119
+ Automatically detects font flavor from WOFF header.
120
+
121
+ # Phase 2 conversions (Milestone 2.2) - SVG
122
+ - from: ttf
123
+ to: svg
124
+ strategy: svg_generator
125
+ description: "Generate SVG font from TrueType"
126
+ status: implemented
127
+ notes: >
128
+ SVG font generation with full glyph outline extraction and coordinate
129
+ transformation. Note: SVG fonts are deprecated in favor of WOFF2, but
130
+ useful for fallback, conversion, and inspection purposes.
131
+
132
+ - from: otf
133
+ to: svg
134
+ strategy: svg_generator
135
+ description: "Generate SVG font from OpenType/CFF"
136
+ status: implemented
137
+ notes: >
138
+ SVG font generation with full glyph outline extraction and coordinate
139
+ transformation. Note: SVG fonts are deprecated in favor of WOFF2, but
140
+ useful for fallback, conversion, and inspection purposes.
141
+
142
+ # Conversion compatibility matrix
143
+ #
144
+ # This section documents which source features are preserved in conversions.
145
+ # Not all features can be preserved across format boundaries.
146
+ #
147
+ compatibility:
148
+ ttf_to_otf:
149
+ preserves:
150
+ - glyph_outlines
151
+ - font_metrics
152
+ - name_table
153
+ - layout_features
154
+ - kerning
155
+ limitations:
156
+ - quadratic_to_cubic_approximation: >
157
+ TrueType quadratic curves are converted to CFF cubic curves.
158
+ The conversion is mathematically exact.
159
+ - hinting_loss: >
160
+ TrueType hinting instructions are not converted to CFF hints.
161
+
162
+ otf_to_ttf:
163
+ preserves:
164
+ - glyph_outlines
165
+ - font_metrics
166
+ - name_table
167
+ - layout_features
168
+ - kerning
169
+ limitations:
170
+ - cubic_to_quadratic_approximation: >
171
+ CFF cubic curves must be approximated as TrueType quadratic curves.
172
+ Multiple quadratic curves may be needed for accuracy.
173
+ - hinting_loss: >
174
+ CFF hints are not converted to TrueType hinting instructions.
175
+
176
+ same_format:
177
+ preserves:
178
+ - all_tables
179
+ - all_features
180
+ - exact_outline_data
181
+ benefits:
182
+ - table_reordering: Tables are written in optimal order
183
+ - checksum_correction: All checksums are recalculated
184
+ - padding_normalization: Table padding is normalized
185
+
186
+ to_woff2:
187
+ preserves:
188
+ - glyph_outlines
189
+ - font_metrics
190
+ - all_tables
191
+ - layout_features
192
+ benefits:
193
+ - brotli_compression: Excellent compression ratio for web delivery
194
+ - smaller_file_size: Typically 30-50% smaller than TTF/OTF
195
+ limitations:
196
+ - web_only: Primarily for web font delivery
197
+ - browser_support: Not all browsers support WOFF2
198
+
199
+ to_svg:
200
+ preserves:
201
+ - glyph_outlines: Outlines converted to SVG paths
202
+ - font_metrics: Basic metrics in font-face element
203
+ - unicode_mappings: Unicode to glyph associations
204
+ limitations:
205
+ - deprecated_format: SVG fonts deprecated in favor of WOFF2
206
+ - limited_browser_support: Mainly Safari
207
+ - no_hinting: Hinting information not preserved
208
+ - no_advanced_features: Complex layout features not supported
209
+ use_cases:
210
+ - fallback: Emergency fallback for very old browsers
211
+ - conversion: Intermediate format for font conversion workflows
212
+ - inspection: Easy-to-read format for font inspection
@@ -0,0 +1,66 @@
1
+
2
+ # Font Export Settings
3
+ #
4
+ # Configuration for font export to YAML/JSON formats
5
+
6
+ # Default export settings
7
+ defaults:
8
+ binary_format: hex # hex or base64
9
+ pretty: true
10
+ include_metadata: true
11
+
12
+ # Table export strategies
13
+ # - parsed: Full Lutaml::Model serialization
14
+ # - binary: Store as hex/base64
15
+ # - mixed: Summary + binary data
16
+ table_strategies:
17
+ parsed:
18
+ - head
19
+ - hhea
20
+ - maxp
21
+ - post
22
+ - OS/2
23
+ - name
24
+ - fvar
25
+ - HVAR
26
+ - VVAR
27
+ - MVAR
28
+ - cvar
29
+ - gvar
30
+
31
+ binary:
32
+ - cvt
33
+ - fpgm
34
+ - prep
35
+ - gasp
36
+ - DSIG
37
+ - GDEF
38
+ - GPOS
39
+ - GSUB
40
+
41
+ mixed:
42
+ - glyf
43
+ - loca
44
+ - cmap
45
+ - CFF
46
+ - hmtx
47
+ - vmtx
48
+
49
+ # Binary data encoding preferences per table
50
+ binary_encoding:
51
+ default: hex
52
+ DSIG: base64 # Signatures are typically base64
53
+
54
+ # Pretty-print settings
55
+ pretty_print:
56
+ yaml:
57
+ line_width: 80
58
+ indent: 2
59
+ json:
60
+ indent: 2
61
+ space: " "
62
+
63
+ # Export optimization
64
+ optimization:
65
+ compress_binary: false # Compress binary data (future)
66
+ deduplicate_tables: false # Deduplicate identical tables (future)
@@ -0,0 +1,100 @@
1
+ # Font Subsetting Profiles Configuration
2
+ #
3
+ # This file defines predefined subsetting profiles that specify which
4
+ # font tables should be included in the subset. Each profile is optimized
5
+ # for a specific use case.
6
+ #
7
+ # Profile Format:
8
+ # profile_name:
9
+ # description: Human-readable description of the profile
10
+ # tables: Array of table tags to include in the subset
11
+ #
12
+ # Common Table Tags:
13
+ # - cmap: Character to glyph mapping
14
+ # - head: Font header
15
+ # - hhea: Horizontal header
16
+ # - hmtx: Horizontal metrics
17
+ # - maxp: Maximum profile
18
+ # - name: Naming table
19
+ # - post: PostScript information
20
+ # - loca: Glyph location index (TrueType)
21
+ # - glyf: Glyph data (TrueType)
22
+ # - OS/2: OS/2 and Windows metrics
23
+ # - CFF : Compact Font Format (OpenType)
24
+ # - GSUB: Glyph Substitution
25
+ # - GPOS: Glyph Positioning
26
+ # - GDEF: Glyph Definition
27
+
28
+ # PDF Profile: Minimal tables required for PDF embedding
29
+ pdf:
30
+ description: Minimal tables required for PDF font embedding
31
+ tables:
32
+ - cmap
33
+ - head
34
+ - hhea
35
+ - hmtx
36
+ - maxp
37
+ - name
38
+ - post
39
+ - loca
40
+ - glyf
41
+
42
+ # Web Profile: Tables required for web font usage
43
+ web:
44
+ description: Tables required for web browsers and modern rendering
45
+ tables:
46
+ - cmap
47
+ - head
48
+ - hhea
49
+ - hmtx
50
+ - maxp
51
+ - name
52
+ - OS/2
53
+ - post
54
+ - loca
55
+ - glyf
56
+ - GSUB
57
+ - GPOS
58
+
59
+ # Minimal Profile: Absolute minimum tables for font rendering
60
+ minimal:
61
+ description: Absolute minimum tables for basic font rendering
62
+ tables:
63
+ - cmap
64
+ - head
65
+ - hhea
66
+ - hmtx
67
+ - maxp
68
+ - name
69
+ - OS/2
70
+ - post
71
+
72
+ # Full Profile: All standard tables (for comprehensive subsetting)
73
+ full:
74
+ description: All standard TrueType/OpenType tables
75
+ tables:
76
+ - cmap
77
+ - head
78
+ - hhea
79
+ - hmtx
80
+ - maxp
81
+ - name
82
+ - OS/2
83
+ - post
84
+ - loca
85
+ - glyf
86
+ - cvt
87
+ - fpgm
88
+ - prep
89
+ - gasp
90
+ - GSUB
91
+ - GPOS
92
+ - GDEF
93
+ - BASE
94
+ - JSTF
95
+ - CFF
96
+ - CFF2
97
+ - VORG
98
+ - kern
99
+ - vhea
100
+ - vmtx
@@ -0,0 +1,60 @@
1
+ ---
2
+ # SVG Font Generation Settings
3
+ #
4
+ # Configuration for SVG font generation, following external configuration
5
+ # principle. These settings control SVG output formatting and glyph selection.
6
+
7
+ # Output formatting
8
+ formatting:
9
+ # Pretty print XML with indentation
10
+ pretty_print: true
11
+ # Number of spaces for indentation
12
+ indent_spaces: 2
13
+ # Include XML declaration
14
+ xml_declaration: true
15
+
16
+ # Coordinate precision
17
+ coordinates:
18
+ # Number of decimal places for coordinates
19
+ decimal_places: 2
20
+ # Round coordinates to integers
21
+ round_to_integer: true
22
+
23
+ # Glyph selection
24
+ glyphs:
25
+ # Maximum number of glyphs to include (null = all)
26
+ max_glyphs: null
27
+ # Include .notdef glyph
28
+ include_notdef: true
29
+ # Include only glyphs with unicode mappings
30
+ unicode_only: false
31
+
32
+ # Font metadata
33
+ metadata:
34
+ # Include font-face element
35
+ include_font_face: true
36
+ # Include bounding box in font-face
37
+ include_bbox: true
38
+ # Include underline position/thickness
39
+ include_underline: true
40
+ # Include x-height and cap-height
41
+ include_heights: true
42
+
43
+ # Default values for missing data
44
+ defaults:
45
+ # Default advance width for missing-glyph
46
+ missing_glyph_advance: 500
47
+ # Default units per em
48
+ units_per_em: 1000
49
+ # Default ascent
50
+ ascent: 800
51
+ # Default descent
52
+ descent: -200
53
+
54
+ # Limitations and warnings
55
+ limitations:
56
+ # Note: SVG fonts are deprecated in favor of WOFF/WOFF2
57
+ # Limited browser support (mostly Safari)
58
+ # Useful for: fallback, conversion, inspection
59
+ # Modern web should use WOFF2
60
+ warn_deprecated: true
@@ -0,0 +1,149 @@
1
+ # Font Validation Rules Configuration
2
+ #
3
+ # This file defines validation rules for different font types and validation levels.
4
+ # The rules determine which checks are performed and their severity thresholds.
5
+
6
+ # Required tables for different font types
7
+ required_tables:
8
+ # Tables required for all fonts
9
+ all:
10
+ - head
11
+ - name
12
+ - cmap
13
+ - maxp
14
+ - hhea
15
+ - hmtx
16
+ - post
17
+ - OS/2
18
+
19
+ # Additional tables required for TrueType fonts (.ttf)
20
+ truetype:
21
+ - glyf
22
+ - loca
23
+
24
+ # Additional tables required for OpenType/CFF fonts (.otf)
25
+ opentype_cff:
26
+ - CFF # or CFF2 for CFF2 format
27
+
28
+ # Additional tables required for variable fonts
29
+ variable:
30
+ - fvar
31
+ - gvar # For TrueType variable fonts
32
+ - HVAR # Horizontal metrics variations (optional but recommended)
33
+ - MVAR # Metrics variations (optional)
34
+
35
+ # Validation levels define which checks to perform
36
+ validation_levels:
37
+ # Strict: All checks must pass, no warnings allowed
38
+ strict:
39
+ check_required_tables: true
40
+ check_table_checksums: true
41
+ check_head_checksum_adjustment: true
42
+ check_glyph_consistency: true
43
+ check_cmap_references: true
44
+ check_hmtx_consistency: true
45
+ check_name_consistency: true
46
+ check_variable_consistency: true
47
+ check_table_offsets: true
48
+ check_table_ordering: false # Not critical for correctness
49
+ allow_warnings: false
50
+ allow_info: true
51
+
52
+ # Standard: Most checks enabled, warnings allowed
53
+ standard:
54
+ check_required_tables: true
55
+ check_table_checksums: true
56
+ check_head_checksum_adjustment: true
57
+ check_glyph_consistency: true
58
+ check_cmap_references: true
59
+ check_hmtx_consistency: true
60
+ check_name_consistency: true
61
+ check_variable_consistency: true
62
+ check_table_offsets: true
63
+ check_table_ordering: false
64
+ allow_warnings: true
65
+ allow_info: true
66
+
67
+ # Lenient: Basic checks only, many warnings allowed
68
+ lenient:
69
+ check_required_tables: true
70
+ check_table_checksums: false # Skip checksum validation
71
+ check_head_checksum_adjustment: false
72
+ check_glyph_consistency: true
73
+ check_cmap_references: false # Skip cmap validation
74
+ check_hmtx_consistency: true
75
+ check_name_consistency: false
76
+ check_variable_consistency: false
77
+ check_table_offsets: true
78
+ check_table_ordering: false
79
+ allow_warnings: true
80
+ allow_info: true
81
+
82
+ # Error messages templates
83
+ error_messages:
84
+ missing_table: "Missing required table: %{table}"
85
+ invalid_table_checksum: "Table '%{table}' checksum mismatch (expected: %{expected}, got: %{actual})"
86
+ invalid_head_checksum: "Invalid head table checksum adjustment"
87
+ glyph_count_mismatch: "Glyph count mismatch: maxp=%{maxp}, actual=%{actual}"
88
+ invalid_cmap_reference: "cmap references non-existent glyph ID %{glyph_id}"
89
+ hmtx_count_mismatch: "hmtx entries (%{hmtx}) don't match glyph count (%{glyph_count})"
90
+ invalid_table_offset: "Table '%{table}' has invalid offset: %{offset}"
91
+ variable_table_missing: "Variable font missing required table: %{table}"
92
+ fvar_gvar_mismatch: "fvar axis count (%{fvar}) doesn't match gvar axis count (%{gvar})"
93
+
94
+ # Warning messages templates
95
+ warning_messages:
96
+ table_checksum_mismatch: "Table '%{table}' checksum mismatch"
97
+ suboptimal_table_order: "Tables not in optimal order for performance"
98
+ missing_optional_table: "Optional table '%{table}' not present (recommended for %{reason})"
99
+ name_inconsistency: "Name table inconsistency: %{issue}"
100
+ large_font_size: "Font file size (%{size} bytes) is unusually large"
101
+
102
+ # Info messages templates
103
+ info_messages:
104
+ optimization_opportunity: "Font could benefit from %{optimization}"
105
+ subsetting_recommended: "Font contains %{glyph_count} glyphs; subsetting may reduce size"
106
+ compression_recommended: "Font could benefit from WOFF2 compression"
107
+
108
+ # Checksum validation settings
109
+ checksum_validation:
110
+ # Magic number for checksum adjustment calculation
111
+ magic: 0xB1B0AFBA
112
+
113
+ # Tables exempt from checksum validation (some tables have dynamic content)
114
+ skip_tables:
115
+ - DSIG # Digital signature table (changes with signing)
116
+
117
+ # Consistency checks configuration
118
+ consistency_checks:
119
+ # Maximum acceptable glyph ID for cmap validation
120
+ max_glyph_id_multiplier: 2.0 # Allow up to 2x maxp.numGlyphs for safety
121
+
122
+ # Minimum acceptable glyph count
123
+ min_glyph_count: 1
124
+
125
+ # Maximum acceptable glyph count (sanity check)
126
+ max_glyph_count: 65536
127
+
128
+ # Structure validation settings
129
+ structure_validation:
130
+ # Minimum valid offset (after header and directory)
131
+ min_table_offset: 12
132
+
133
+ # Table alignment requirement (4-byte alignment)
134
+ table_alignment: 4
135
+
136
+ # Maximum reasonable table size (100MB)
137
+ max_table_size: 104857600
138
+
139
+ # Variable font specific validation
140
+ variable_validation:
141
+ # Check that all required variation tables are consistent
142
+ check_axis_consistency: true
143
+
144
+ # Check that variation regions are valid
145
+ check_region_validity: true
146
+
147
+ # Check that deltas are within reasonable bounds
148
+ max_delta_value: 32767
149
+ min_delta_value: -32768
@@ -0,0 +1,99 @@
1
+ # Configuration for variable font delta application
2
+ #
3
+ # These settings control how deltas are calculated and applied when
4
+ # instancing variable fonts at specific design space coordinates.
5
+
6
+ # Delta Application Settings
7
+ delta_application:
8
+ # Rounding mode for accumulated deltas
9
+ # Options: round, floor, ceil, truncate
10
+ rounding_mode: round
11
+
12
+ # Interpolation quality
13
+ # Options: fast, normal, high
14
+ interpolation_quality: normal
15
+
16
+ # Whether to validate coordinates against axis ranges
17
+ validate_coordinates: true
18
+
19
+ # Whether to clamp out-of-range coordinates
20
+ clamp_coordinates: true
21
+
22
+ # Minimum scalar threshold below which deltas are ignored
23
+ # (Performance optimization: regions with very low contribution)
24
+ min_scalar_threshold: 0.0001
25
+
26
+ # Coordinate Normalization Settings
27
+ coordinate_normalization:
28
+ # Whether to normalize coordinates to -1.0 to 1.0 range
29
+ normalize: true
30
+
31
+ # Default axis values if not specified
32
+ use_axis_defaults: true
33
+
34
+ # Precision for normalized values (decimal places)
35
+ normalized_precision: 6
36
+
37
+ # Region Matching Settings
38
+ region_matching:
39
+ # Algorithm: standard (OpenType spec compliant)
40
+ algorithm: standard
41
+
42
+ # Whether to use multi-axis region matching
43
+ multi_axis: true
44
+
45
+ # Cache region scalars for reuse
46
+ cache_scalars: true
47
+
48
+ # Glyph Delta Processing
49
+ glyph_deltas:
50
+ # Apply deltas to simple glyphs
51
+ apply_to_simple: true
52
+
53
+ # Apply deltas to compound glyphs
54
+ apply_to_compound: true
55
+
56
+ # Process phantom points (metrics)
57
+ process_phantom_points: true
58
+
59
+ # Number of phantom points (standard: 4)
60
+ phantom_point_count: 4
61
+
62
+ # Metric Delta Processing
63
+ metric_deltas:
64
+ # Apply horizontal metric deltas (HVAR)
65
+ apply_hvar: true
66
+
67
+ # Apply vertical metric deltas (VVAR)
68
+ apply_vvar: true
69
+
70
+ # Apply font-level metric deltas (MVAR)
71
+ apply_mvar: true
72
+
73
+ # Update dependent metrics automatically
74
+ update_dependent_metrics: true
75
+
76
+ # Performance Settings
77
+ performance:
78
+ # Parallel processing for multiple glyphs
79
+ parallel_processing: false
80
+
81
+ # Maximum number of threads (if parallel)
82
+ max_threads: 4
83
+
84
+ # Cache parsed variation tables
85
+ cache_variation_tables: true
86
+
87
+ # Validation Settings
88
+ validation:
89
+ # Validate variation table consistency
90
+ validate_tables: true
91
+
92
+ # Check for required tables
93
+ check_required_tables: true
94
+
95
+ # Validate coordinate ranges
96
+ validate_ranges: true
97
+
98
+ # Strict mode (fail on any error)
99
+ strict_mode: false