fontisan 0.2.2 → 0.2.4

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +94 -48
  3. data/README.adoc +293 -3
  4. data/Rakefile +20 -7
  5. data/lib/fontisan/base_collection.rb +296 -0
  6. data/lib/fontisan/commands/base_command.rb +2 -19
  7. data/lib/fontisan/commands/convert_command.rb +16 -13
  8. data/lib/fontisan/commands/info_command.rb +156 -50
  9. data/lib/fontisan/config/conversion_matrix.yml +58 -20
  10. data/lib/fontisan/converters/outline_converter.rb +6 -3
  11. data/lib/fontisan/converters/svg_generator.rb +45 -0
  12. data/lib/fontisan/converters/woff2_encoder.rb +106 -13
  13. data/lib/fontisan/font_loader.rb +109 -26
  14. data/lib/fontisan/formatters/text_formatter.rb +72 -19
  15. data/lib/fontisan/models/bitmap_glyph.rb +123 -0
  16. data/lib/fontisan/models/bitmap_strike.rb +94 -0
  17. data/lib/fontisan/models/collection_brief_info.rb +6 -0
  18. data/lib/fontisan/models/collection_info.rb +6 -1
  19. data/lib/fontisan/models/color_glyph.rb +57 -0
  20. data/lib/fontisan/models/color_layer.rb +53 -0
  21. data/lib/fontisan/models/color_palette.rb +60 -0
  22. data/lib/fontisan/models/font_info.rb +26 -0
  23. data/lib/fontisan/models/svg_glyph.rb +89 -0
  24. data/lib/fontisan/open_type_collection.rb +17 -220
  25. data/lib/fontisan/open_type_font.rb +6 -0
  26. data/lib/fontisan/optimizers/charstring_rewriter.rb +19 -8
  27. data/lib/fontisan/optimizers/pattern_analyzer.rb +4 -2
  28. data/lib/fontisan/optimizers/subroutine_builder.rb +6 -5
  29. data/lib/fontisan/optimizers/subroutine_optimizer.rb +5 -2
  30. data/lib/fontisan/pipeline/output_writer.rb +2 -2
  31. data/lib/fontisan/tables/cbdt.rb +169 -0
  32. data/lib/fontisan/tables/cblc.rb +290 -0
  33. data/lib/fontisan/tables/cff.rb +6 -12
  34. data/lib/fontisan/tables/colr.rb +291 -0
  35. data/lib/fontisan/tables/cpal.rb +281 -0
  36. data/lib/fontisan/tables/glyf/glyph_builder.rb +5 -1
  37. data/lib/fontisan/tables/sbix.rb +379 -0
  38. data/lib/fontisan/tables/svg.rb +301 -0
  39. data/lib/fontisan/true_type_collection.rb +29 -113
  40. data/lib/fontisan/true_type_font.rb +6 -0
  41. data/lib/fontisan/validation/woff2_header_validator.rb +278 -0
  42. data/lib/fontisan/validation/woff2_table_validator.rb +270 -0
  43. data/lib/fontisan/validation/woff2_validator.rb +248 -0
  44. data/lib/fontisan/version.rb +1 -1
  45. data/lib/fontisan/woff2/directory.rb +40 -11
  46. data/lib/fontisan/woff2/table_transformer.rb +506 -73
  47. data/lib/fontisan/woff2_font.rb +29 -9
  48. data/lib/fontisan/woff_font.rb +17 -4
  49. data/lib/fontisan.rb +12 -0
  50. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f52b19a1d943c0e079127e9699e517b6832a30d46bab88454ae8471a398886d2
4
- data.tar.gz: 8395db7eef4bb2bed2169a08f54208e5119209f3336dcf17bf6d27b602e7fd5f
3
+ metadata.gz: efdc28872530847f76e7d586ed2ac859d0860275a9289936e742a467f6139799
4
+ data.tar.gz: b1af1580a3ef2d2b1dbb449c3c7295194497b358d8819d5f18496282b7730ed5
5
5
  SHA512:
6
- metadata.gz: 65003981ab35b7ff61c6f7524e9552278cfff918f0bbbfeb9a28271042e91033aa4623f8f301b66e1b6a171bea423ae30c644c32b4d111ce10a1d8bd6a82b61e
7
- data.tar.gz: 7ff760af226e26a619cce271e505c92c8c6a3f21e6ec9c3c6582571e8944352ae7ff6be448c9236e11c5f6f023550f492716db5945980ac0607eaee700c9318e
6
+ metadata.gz: 533a181937b1b46ea380a14a9c108ba19678f9bf1c0fcb8a5b51f0e0fb43630c69180c74679ad91da49fa73d136ec783e69b460ce8f031834e3fc500ca666139
7
+ data.tar.gz: '09e9d4ff6a4694df5d6756dc9f4dc056f1951d66ca456079ad40336a41e32b804b15aa597f4089d20a20474a75faf680782c6cca2bf5ee8c2d5c30eb41e12623'
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2025-12-29 12:26:25 UTC using RuboCop version 1.81.7.
3
+ # on 2026-01-03 02:11:10 UTC using RuboCop version 1.81.7.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -12,6 +12,14 @@ Gemspec/RequiredRubyVersion:
12
12
  Exclude:
13
13
  - 'fontisan.gemspec'
14
14
 
15
+ # Offense count: 1
16
+ # This cop supports safe autocorrection (--autocorrect).
17
+ # Configuration parameters: EnforcedStyle, IndentationWidth.
18
+ # SupportedStyles: with_first_argument, with_fixed_indentation
19
+ Layout/ArgumentAlignment:
20
+ Exclude:
21
+ - 'lib/fontisan/converters/woff2_encoder.rb'
22
+
15
23
  # Offense count: 1
16
24
  # This cop supports safe autocorrection (--autocorrect).
17
25
  Layout/EmptyLineAfterGuardClause:
@@ -24,29 +32,32 @@ Layout/EmptyLinesAroundExceptionHandlingKeywords:
24
32
  Exclude:
25
33
  - 'lib/fontisan/hints/hint_validator.rb'
26
34
 
27
- # Offense count: 2
35
+ # Offense count: 23
28
36
  # This cop supports safe autocorrection (--autocorrect).
29
37
  # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
30
38
  Layout/ExtraSpacing:
31
39
  Exclude:
40
+ - 'lib/fontisan/commands/info_command.rb'
32
41
  - 'lib/fontisan/hints/truetype_instruction_analyzer.rb'
42
+ - 'lib/fontisan/tables/sbix.rb'
43
+ - 'spec/fontisan/tables/sbix_spec.rb'
44
+ - 'spec/integration/color_emoji_fonts_spec.rb'
33
45
 
34
- # Offense count: 1101
46
+ # Offense count: 1270
35
47
  # This cop supports safe autocorrection (--autocorrect).
36
48
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
37
49
  # URISchemes: http, https
38
50
  Layout/LineLength:
39
51
  Enabled: false
40
52
 
41
- # Offense count: 1
53
+ # Offense count: 18
42
54
  # This cop supports safe autocorrection (--autocorrect).
43
- # Configuration parameters: EnforcedStyle.
44
- # SupportedStyles: final_newline, final_blank_line
45
- Layout/TrailingEmptyLines:
55
+ # Configuration parameters: AllowInHeredoc.
56
+ Layout/TrailingWhitespace:
46
57
  Exclude:
47
- - 'spec/fontisan_spec.rb'
58
+ - 'spec/fontisan/converters/woff2_encoder_integration_spec.rb'
48
59
 
49
- # Offense count: 26
60
+ # Offense count: 27
50
61
  # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
51
62
  Lint/DuplicateBranch:
52
63
  Enabled: false
@@ -87,17 +98,26 @@ Lint/StructNewOverride:
87
98
  Exclude:
88
99
  - 'lib/fontisan/optimizers/pattern_analyzer.rb'
89
100
 
90
- # Offense count: 5
101
+ # Offense count: 1
102
+ # This cop supports safe autocorrection (--autocorrect).
103
+ # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
104
+ Lint/UnusedBlockArgument:
105
+ Exclude:
106
+ - 'spec/fontisan/tables/sbix_spec.rb'
107
+
108
+ # Offense count: 8
91
109
  # This cop supports safe autocorrection (--autocorrect).
92
110
  # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions.
93
111
  # NotImplementedExceptions: NotImplementedError
94
112
  Lint/UnusedMethodArgument:
95
113
  Exclude:
96
114
  - 'lib/fontisan/font_loader.rb'
115
+ - 'lib/fontisan/optimizers/charstring_rewriter.rb'
97
116
  - 'lib/fontisan/tables/cff2/private_dict_blend_handler.rb'
98
117
  - 'lib/fontisan/utilities/brotli_wrapper.rb'
99
118
  - 'lib/fontisan/variation/table_accessor.rb'
100
119
  - 'lib/fontisan/woff2/glyf_transformer.rb'
120
+ - 'lib/fontisan/woff_font.rb'
101
121
 
102
122
  # Offense count: 3
103
123
  # This cop supports safe autocorrection (--autocorrect).
@@ -106,39 +126,39 @@ Lint/UselessAssignment:
106
126
  - 'lib/fontisan/hints/truetype_instruction_analyzer.rb'
107
127
  - 'spec/fontisan/hints/hint_round_trip_spec.rb'
108
128
 
109
- # Offense count: 431
129
+ # Offense count: 462
110
130
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
111
131
  Metrics/AbcSize:
112
132
  Enabled: false
113
133
 
114
- # Offense count: 27
134
+ # Offense count: 29
115
135
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
116
136
  # AllowedMethods: refine
117
137
  Metrics/BlockLength:
118
- Max: 80
138
+ Max: 91
119
139
 
120
140
  # Offense count: 8
121
141
  # Configuration parameters: CountBlocks, CountModifierForms.
122
142
  Metrics/BlockNesting:
123
143
  Max: 5
124
144
 
125
- # Offense count: 220
145
+ # Offense count: 240
126
146
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
127
147
  Metrics/CyclomaticComplexity:
128
148
  Enabled: false
129
149
 
130
- # Offense count: 648
150
+ # Offense count: 699
131
151
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
132
152
  Metrics/MethodLength:
133
153
  Max: 135
134
154
 
135
- # Offense count: 17
155
+ # Offense count: 18
136
156
  # Configuration parameters: CountKeywordArgs.
137
157
  Metrics/ParameterLists:
138
158
  Max: 39
139
159
  MaxOptionalParameters: 4
140
160
 
141
- # Offense count: 154
161
+ # Offense count: 174
142
162
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
143
163
  Metrics/PerceivedComplexity:
144
164
  Enabled: false
@@ -153,29 +173,14 @@ Naming/MethodParameterName:
153
173
  - 'lib/fontisan/tables/glyf/curve_converter.rb'
154
174
  - 'lib/fontisan/variation/optimizer.rb'
155
175
 
156
- # Offense count: 71
176
+ # Offense count: 84
157
177
  # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
158
178
  # SupportedStyles: snake_case, normalcase, non_integer
159
179
  # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
160
180
  Naming/VariableNumber:
161
- Exclude:
162
- - 'lib/fontisan/models/ttx/tables/os2_table.rb'
163
- - 'lib/fontisan/subset/table_subsetter.rb'
164
- - 'lib/fontisan/tables/cff/charset.rb'
165
- - 'lib/fontisan/tables/cff/encoding.rb'
166
- - 'lib/fontisan/tables/cmap.rb'
167
- - 'lib/fontisan/tables/glyf.rb'
168
- - 'lib/fontisan/tables/glyf/compound_glyph.rb'
169
- - 'lib/fontisan/tables/glyf/glyph_builder.rb'
170
- - 'lib/fontisan/tables/glyf/simple_glyph.rb'
171
- - 'spec/fontisan/collection/table_deduplicator_spec.rb'
172
- - 'spec/fontisan/tables/cff/charset_spec.rb'
173
- - 'spec/fontisan/tables/glyf/glyph_builder_spec.rb'
174
- - 'spec/fontisan/tables/glyf_spec.rb'
175
- - 'spec/fontisan/tables/hmtx_spec.rb'
176
- - 'spec/fontisan/tables/maxp_spec.rb'
181
+ Enabled: false
177
182
 
178
- # Offense count: 22
183
+ # Offense count: 25
179
184
  # Configuration parameters: MinSize.
180
185
  Performance/CollectionLiteralInLoop:
181
186
  Exclude:
@@ -185,17 +190,20 @@ Performance/CollectionLiteralInLoop:
185
190
  - 'lib/fontisan/tables/cff/private_dict_writer.rb'
186
191
  - 'lib/fontisan/tables/cff2.rb'
187
192
  - 'lib/fontisan/tables/cff2/region_matcher.rb'
193
+ - 'lib/fontisan/tables/sbix.rb'
188
194
  - 'lib/fontisan/true_type_font.rb'
189
195
  - 'lib/fontisan/variation/validator.rb'
196
+ - 'lib/fontisan/woff2/table_transformer.rb'
190
197
  - 'spec/fontisan/cli_spec.rb'
191
198
  - 'spec/fontisan/commands/glyphs_command_spec.rb'
192
199
  - 'spec/fontisan/commands/info_command_spec.rb'
193
200
  - 'spec/fontisan/commands/tables_command_spec.rb'
194
201
 
195
- # Offense count: 1
202
+ # Offense count: 3
196
203
  # This cop supports unsafe autocorrection (--autocorrect-all).
197
204
  Performance/TimesMap:
198
205
  Exclude:
206
+ - 'lib/fontisan/font_loader.rb'
199
207
  - 'lib/fontisan/tables/cff2.rb'
200
208
 
201
209
  # Offense count: 24
@@ -209,36 +217,40 @@ RSpec/AnyInstance:
209
217
  - 'spec/fontisan/variation/parallel_generator_spec.rb'
210
218
  - 'spec/integration/format_conversion_spec.rb'
211
219
 
212
- # Offense count: 100
220
+ # Offense count: 105
213
221
  # Configuration parameters: Prefixes, AllowedPatterns.
214
222
  # Prefixes: when, with, without
215
223
  RSpec/ContextWording:
216
224
  Enabled: false
217
225
 
218
- # Offense count: 17
226
+ # Offense count: 21
219
227
  # Configuration parameters: IgnoredMetadata.
220
228
  RSpec/DescribeClass:
221
229
  Enabled: false
222
230
 
223
- # Offense count: 1
231
+ # Offense count: 2
224
232
  RSpec/DescribeMethod:
225
233
  Exclude:
226
234
  - 'spec/fontisan/collection/variable_font_builder_spec.rb'
235
+ - 'spec/fontisan/converters/woff2_encoder_integration_spec.rb'
227
236
 
228
- # Offense count: 1152
237
+ # Offense count: 1263
229
238
  # Configuration parameters: CountAsOne.
230
239
  RSpec/ExampleLength:
231
240
  Max: 66
232
241
 
233
- # Offense count: 4
242
+ # Offense count: 7
234
243
  # This cop supports safe autocorrection (--autocorrect).
235
244
  RSpec/ExpectActual:
236
245
  Exclude:
237
246
  - '**/spec/routing/**/*'
238
247
  - 'spec/fontisan/commands/subset_command_spec.rb'
248
+ - 'spec/fontisan/converters/extended_woff2_spec.rb'
249
+ - 'spec/fontisan/converters/woff2_round_trip_spec.rb'
239
250
  - 'spec/fontisan/subset/builder_spec.rb'
240
251
  - 'spec/fontisan/utils/thread_pool_spec.rb'
241
252
  - 'spec/fontisan/variation/validator_spec.rb'
253
+ - 'spec/fontisan/woff2/table_transformer_spec.rb'
242
254
 
243
255
  # Offense count: 1
244
256
  RSpec/IdenticalEqualityAssertion:
@@ -287,19 +299,20 @@ RSpec/MessageSpies:
287
299
  - 'spec/fontisan/variation/instance_writer_spec.rb'
288
300
  - 'spec/fontisan/woff2_font_spec.rb'
289
301
 
290
- # Offense count: 4
302
+ # Offense count: 5
291
303
  RSpec/MultipleDescribes:
292
304
  Exclude:
293
305
  - 'spec/fontisan/loading_modes_spec.rb'
294
306
  - 'spec/fontisan/models/table_info_spec.rb'
295
307
  - 'spec/fontisan/utils/thread_pool_spec.rb'
308
+ - 'spec/fontisan/validation/woff2_validator_spec.rb'
296
309
  - 'spec/fontisan/variation/cache_spec.rb'
297
310
 
298
- # Offense count: 1488
311
+ # Offense count: 1606
299
312
  RSpec/MultipleExpectations:
300
313
  Max: 22
301
314
 
302
- # Offense count: 132
315
+ # Offense count: 135
303
316
  # Configuration parameters: AllowSubject.
304
317
  RSpec/MultipleMemoizedHelpers:
305
318
  Max: 13
@@ -382,7 +395,7 @@ Security/Open:
382
395
  Exclude:
383
396
  - 'Rakefile'
384
397
 
385
- # Offense count: 3
398
+ # Offense count: 9
386
399
  # This cop supports safe autocorrection (--autocorrect).
387
400
  # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
388
401
  # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
@@ -391,8 +404,11 @@ Security/Open:
391
404
  # AllowedMethods: lambda, proc, it
392
405
  Style/BlockDelimiters:
393
406
  Exclude:
407
+ - 'spec/fontisan/converters/extended_woff2_spec.rb'
394
408
  - 'spec/fontisan/hints/hint_validator_spec.rb'
395
409
  - 'spec/fontisan/hints/truetype_instruction_analyzer_spec.rb'
410
+ - 'spec/fontisan/tables/colr_spec.rb'
411
+ - 'spec/fontisan/tables/cpal_spec.rb'
396
412
 
397
413
  # Offense count: 1
398
414
  # This cop supports unsafe autocorrection (--autocorrect-all).
@@ -400,7 +416,7 @@ Style/CombinableLoops:
400
416
  Exclude:
401
417
  - 'lib/fontisan/woff2_font.rb'
402
418
 
403
- # Offense count: 1
419
+ # Offense count: 2
404
420
  # This cop supports safe autocorrection (--autocorrect).
405
421
  # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
406
422
  # SupportedStyles: assign_to_condition, assign_inside_condition
@@ -434,13 +450,21 @@ Style/HashLikeCase:
434
450
  - 'lib/fontisan/commands/unpack_command.rb'
435
451
  - 'lib/fontisan/models/validation_report.rb'
436
452
 
437
- # Offense count: 4
453
+ # Offense count: 1
454
+ # This cop supports safe autocorrection (--autocorrect).
455
+ # Configuration parameters: AllowIfModifier.
456
+ Style/IfInsideElse:
457
+ Exclude:
458
+ - 'Rakefile'
459
+
460
+ # Offense count: 6
438
461
  # This cop supports unsafe autocorrection (--autocorrect-all).
439
462
  # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
440
463
  # SupportedStyles: predicate, comparison
441
464
  Style/NumericPredicate:
442
465
  Exclude:
443
466
  - 'spec/**/*'
467
+ - 'lib/fontisan/font_loader.rb'
444
468
  - 'lib/fontisan/hints/hint_converter.rb'
445
469
  - 'lib/fontisan/hints/hint_validator.rb'
446
470
  - 'lib/fontisan/hints/truetype_instruction_analyzer.rb'
@@ -460,6 +484,13 @@ Style/SoleNestedConditional:
460
484
  Exclude:
461
485
  - 'lib/fontisan/hints/hint_validator.rb'
462
486
 
487
+ # Offense count: 4
488
+ # This cop supports unsafe autocorrection (--autocorrect-all).
489
+ # Configuration parameters: Mode.
490
+ Style/StringConcatenation:
491
+ Exclude:
492
+ - 'spec/fontisan/tables/cbdt_spec.rb'
493
+
463
494
  # Offense count: 2
464
495
  # This cop supports safe autocorrection (--autocorrect).
465
496
  # Configuration parameters: .
@@ -468,13 +499,28 @@ Style/SymbolArray:
468
499
  EnforcedStyle: percent
469
500
  MinSize: 3
470
501
 
471
- # Offense count: 3
502
+ # Offense count: 53
503
+ # This cop supports safe autocorrection (--autocorrect).
504
+ # Configuration parameters: EnforcedStyleForMultiline.
505
+ # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
506
+ Style/TrailingCommaInArguments:
507
+ Exclude:
508
+ - 'lib/fontisan/commands/info_command.rb'
509
+ - 'spec/fontisan/converters/woff2_encoder_integration_spec.rb'
510
+ - 'spec/fontisan/optimizers/charstring_rewriter_spec.rb'
511
+ - 'spec/fontisan/tables/cblc_spec.rb'
512
+ - 'spec/fontisan/tables/sbix_spec.rb'
513
+ - 'spec/integration/color_emoji_fonts_spec.rb'
514
+
515
+ # Offense count: 12
472
516
  # This cop supports safe autocorrection (--autocorrect).
473
517
  # Configuration parameters: EnforcedStyleForMultiline.
474
518
  # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
475
519
  Style/TrailingCommaInArrayLiteral:
476
520
  Exclude:
477
521
  - 'spec/fontisan/hints/truetype_instruction_analyzer_spec.rb'
522
+ - 'spec/fontisan/tables/colr_spec.rb'
523
+ - 'spec/fontisan/tables/cpal_spec.rb'
478
524
  - 'spec/fontisan/variation/parallel_generator_spec.rb'
479
525
 
480
526
  # Offense count: 1