fontisan 0.4.52-java → 0.4.53-java

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/docs/guide/engines.md +1 -1
  3. data/lib/fontisan/byte_ops.rb +14 -0
  4. data/lib/fontisan/config/conversion_matrix.yml +14 -12
  5. data/lib/fontisan/converters/cff_table_builder.rb +26 -46
  6. data/lib/fontisan/converters/type1_converter.rb +177 -63
  7. data/lib/fontisan/ffi/windows-x86_64/fontisan_cdylib.dll +0 -0
  8. data/lib/fontisan/ffi.rb +8 -7
  9. data/lib/fontisan/native.rb +6 -5
  10. data/lib/fontisan/pipeline/output_writer.rb +16 -0
  11. data/lib/fontisan/pipeline/transformation_pipeline.rb +30 -3
  12. data/lib/fontisan/tables/cff/charstring_parser.rb +8 -0
  13. data/lib/fontisan/type1/cff_to_type1_converter.rb +33 -15
  14. data/lib/fontisan/type1/charstrings.rb +2 -1
  15. data/lib/fontisan/type1/decryptor.rb +6 -6
  16. data/lib/fontisan/type1/pfb_generator.rb +90 -241
  17. data/lib/fontisan/type1/pfb_writer.rb +153 -0
  18. data/lib/fontisan/type1/ttf_to_type1_converter.rb +7 -1
  19. data/lib/fontisan/type1.rb +1 -0
  20. data/lib/fontisan/version.rb +1 -1
  21. data/scripts/corpus/generate_convert_goldens.rb +46 -6
  22. data/scripts/validate_t1_surfaces.rb +14 -4
  23. data/scripts/verify_release.rb +10 -2
  24. metadata +2 -17
  25. data/TODO.improvements/01-cbdt-cblc-gid-stable-propagation.md +0 -73
  26. data/TODO.improvements/02-collection-outline-priority.md +0 -48
  27. data/TODO.improvements/03-fontisan-audit-command.md +0 -219
  28. data/TODO.improvements/04-ufo-composite-glyph-encoding.md +0 -46
  29. data/TODO.improvements/05-otf-compiler-real-cff.md +0 -63
  30. data/TODO.improvements/06-cff2-blend-vsindex-operators.md +0 -51
  31. data/TODO.improvements/07-cpal-v1-header-fields.md +0 -71
  32. data/TODO.improvements/08-cff-standard-string-table.md +0 -52
  33. data/TODO.improvements/09-type1-seac-expansion.md +0 -57
  34. data/TODO.improvements/10-ufo-image-set-feature-writers.md +0 -71
  35. data/TODO.improvements/11-kern-groups-plist.md +0 -49
  36. data/TODO.improvements/12-cbdt-fixture-bindata-conversion.md +0 -68
  37. data/TODO.improvements/13-split-octokit-fetcher.md +0 -45
  38. data/TODO.improvements/14-rubocop-baseline-chip.md +0 -62
  39. data/TODO.improvements/15-cff-cff2-subsetter-strategy.md +0 -78
  40. data/TODO.improvements/README.md +0 -58
@@ -1,68 +0,0 @@
1
- # 12 — `cbdt_fixture.rb` full BinData conversion
2
-
3
- ## Priority
4
- P3
5
-
6
- ## Problem
7
-
8
- `spec/support/cbdt_fixture.rb` was partially refactored in PR #107 (CBDT/CBLC use the new BinData models), but the remaining tables still hand-roll binary packing:
9
-
10
- - `head_table` — 19-element `[...].pack("NNNNnnNNnnnnnnnnnn")`
11
- - `hhea_table` — 16-element pack
12
- - `os2_table` — 43-element pack
13
- - `name_table` — manual record + offset arithmetic
14
- - `post_table` — manual pack
15
- - `hmtx_table` — `Array.new(num_glyphs) { [1000, 0] }.flatten.pack("n*")`
16
- - `cmap_table` / `format4_subtable` / `format12_subtable` — full cmap builder, ~80 lines
17
-
18
- ~200 lines of pack/unpack that duplicate the layout knowledge in `Tables::*`. If any table layout changes, the fixture breaks silently — the same anti-pattern PR #107 already fixed for CBDT/CBLC.
19
-
20
- ## Goal
21
-
22
- Every table builder in `cbdt_fixture.rb` constructs via BinData record (`Tables::Head`, `Tables::Hhea`, `Tables::Maxp`, `Tables::Os2`, `Tables::Name`, `Tables::Post`, `Tables::Hmtx`, `Tables::Cmap`). No more `[...].pack(...)` calls.
23
-
24
- The fixture's self-test (`spec/support/cbdt_fixture_spec.rb`) catches any drift between the fixture's output and the BinData models.
25
-
26
- ## Approach
27
-
28
- For each table, replace the hand-rolled pack with a `Tables::*` BinData construction:
29
-
30
- ```ruby
31
- # Before
32
- def head_table
33
- [0x00010000, 0x00005000, ...].pack("NNNNnnNNnnnnnnnnnn")
34
- end
35
-
36
- # After
37
- def head_table
38
- Tables::Head.new(
39
- version_raw: 0x00010000,
40
- font_revision: 0x00005000,
41
- ...
42
- ).to_binary_s
43
- end
44
- ```
45
-
46
- For tables with field shapes that don't match the BinData record cleanly (e.g., `name_table`'s variable-length string storage), use the BinData record's nested array attributes.
47
-
48
- For `cmap_table`: extract the format-4 / format-12 subtable builders to a reusable `Tables::Cmap.from_mappings(mappings)` class method. The same logic is duplicated in `Subset::TableStrategy::Cmap::Builder` and `Subset::TableStrategy::ColorBitmapSubsetter` — DRY win across three call sites.
49
-
50
- ## Out of scope
51
-
52
- - Refactoring the BinData models themselves — only changes the fixture's consumers.
53
- - Adding `Tables::Cmap.from_mappings` if the DRY extraction scope proves larger than the fixture alone (split into separate PR).
54
-
55
- ## Effort
56
-
57
- ~4 hours.
58
-
59
- ## Dependencies
60
-
61
- None.
62
-
63
- ## Acceptance criteria
64
-
65
- - `spec/support/cbdt_fixture.rb` contains zero `[...].pack` calls.
66
- - `spec/support/cbdt_fixture_spec.rb` self-test still passes (it round-trips via the BinData models; the assertions don't change).
67
- - All downstream specs that use `CbdtFixture` still pass.
68
- - Bundle size of the fixture file drops from ~300 lines to ~150.
@@ -1,45 +0,0 @@
1
- # 13 — Split `OctokitFetcher` out of `fixture_downloader.rb`
2
-
3
- ## Priority
4
- P3
5
-
6
- ## Problem
7
-
8
- `spec/support/fixture_downloader.rb` (post-PR #111) is ~350 lines with two distinct concerns:
9
-
10
- 1. **Retry / routing loop** (the `Downloader` class) — backoff, Retry-After, permanent-vs-transient classification.
11
- 2. **Octokit URL dispatch** (the `OctokitFetcher` module) — release-asset, raw-file, contents-API routing.
12
-
13
- These are MECE-distinct. Bundling them in one file muddies the boundary; future changes to Octokit routing shouldn't require reading the retry loop.
14
-
15
- ## Goal
16
-
17
- `OctokitFetcher` moves to its own file `spec/support/fixture_downloader/octokit_fetcher.rb`. The `Downloader` class becomes the only public surface in `spec/support/fixture_downloader.rb` and delegates to `OctokitFetcher` when needed.
18
-
19
- ## Approach
20
-
21
- 1. Create `spec/support/fixture_downloader/` directory.
22
- 2. Move `OctokitFetcher` module to `spec/support/fixture_downloader/octokit_fetcher.rb`.
23
- 3. Move `HttpStatusIo` and `Downloader` constants stay in `spec/support/fixture_downloader.rb`.
24
- 4. Add a `module FixtureFonts::Downloader` autoload or simple `require_relative "fixture_downloader/octokit_fetcher"` from `fixture_downloader.rb`.
25
-
26
- Actually — for spec/support files, `require_relative` is acceptable (CLAUDE.md rule on autoload is for `lib/`). No autoload needed; the Rakefile's `require_relative` chain handles loading.
27
-
28
- ## Out of scope
29
-
30
- - Splitting the Downloader further — it's cohesive.
31
- - Moving `fixture_downloader_spec.rb` — already sibling, fine where it is.
32
-
33
- ## Effort
34
-
35
- ~1 hour.
36
-
37
- ## Dependencies
38
-
39
- None.
40
-
41
- ## Acceptance criteria
42
-
43
- - `spec/support/fixture_downloader.rb` < 200 lines.
44
- - `spec/support/fixture_downloader/octokit_fetcher.rb` exists and contains all Octokit-specific code.
45
- - All existing specs pass unchanged.
@@ -1,62 +0,0 @@
1
- # 14 — Rubocop baseline chip (per-namespace)
2
-
3
- ## Priority
4
- P3
5
-
6
- ## Problem
7
-
8
- PR #111's `rubocop -A --auto-gen-config` baseline refresh tracked ~9600 remaining offenses. The `.rubocop_todo.yml` file is now ~800 lines of `Exclude:` lists. Layout/Style cops dominate (most are auto-correctable; the rest need manual fixes).
9
-
10
- Leaving the baseline in this state makes future rubocop improvements invisible — new offenses are buried in baseline noise, and contributors can't see whether their PR is clean vs. baseline-burdened.
11
-
12
- ## Goal
13
-
14
- Reduce baseline count to < 1000 offenses via per-namespace PRs:
15
-
16
- | Namespace | Approximate count | Priority |
17
- |-----------|-------------------|----------|
18
- | `lib/fontisan/tables/` | ~3000 | High (well-understood) |
19
- | `lib/fontisan/ufo/compile/` | ~2500 | High |
20
- | `lib/fontisan/stitcher/` | ~800 | Medium |
21
- | `lib/fontisan/converters/` | ~500 | Medium |
22
- | `lib/fontisan/type1/` | ~400 | Medium |
23
- | `lib/fontisan/collection/` | ~300 | Medium |
24
- | `lib/fontisan/subset/` | ~300 | Medium (recent PR #106 work) |
25
- | `lib/fontisan/woff2/` | ~250 | Medium |
26
- | `lib/fontisan/optimizers/` | ~200 | Low |
27
- | `lib/fontisan/pipeline/` | ~200 | Low |
28
- | `lib/fontisan/commands/` | ~150 | Low |
29
- | `lib/fontisan/validators/` | ~100 | Low |
30
- | `lib/fontisan/binary/` | ~100 | Low |
31
- | `spec/` | ~1500 | Low |
32
-
33
- ## Approach
34
-
35
- One PR per namespace. Each PR:
36
-
37
- 1. Runs `rubocop -A lib/fontisan/<namespace>/` to auto-correct everything possible.
38
- 2. Manually fixes what auto-correct couldn't (typically: complex Layout cops, naming).
39
- 3. Updates `.rubocop_todo.yml` to drop the now-cleaned `Exclude:` entries.
40
- 4. Verifies the full test suite still passes.
41
-
42
- Order: tables first (highest count, lowest risk — table parsing is purely structural).
43
-
44
- ## Out of scope
45
-
46
- - Disabling cops project-wide — these are real issues, not noise.
47
- - Refactoring architectural patterns rubocop flags (e.g., long methods) — separate refactors.
48
-
49
- ## Effort
50
-
51
- ~30 minutes per namespace on average. ~7 hours total.
52
-
53
- ## Dependencies
54
-
55
- None.
56
-
57
- ## Acceptance criteria
58
-
59
- - `.rubocop_todo.yml` < 100 lines (from ~800).
60
- - `bundle exec rubocop` reports 0 offenses.
61
- - All existing specs pass after each namespace PR.
62
- - No behavior change (pure style/layout).
@@ -1,78 +0,0 @@
1
- # 15 — CFF/CFF2 subsetter strategy
2
-
3
- ## Priority
4
- P0
5
-
6
- ## Problem
7
-
8
- The subsetter's `TableStrategy::REGISTRY` has entries for glyf/loca (TrueType outlines) but NOT for CFF or CFF2 (PostScript outlines). Both fall through to `PassThroughStrategy`, which copies the full source table verbatim.
9
-
10
- Two concrete failure modes:
11
-
12
- 1. **Profiles drop CFF entirely.** The `web`, `pdf`, and `minimal` profiles list glyf/loca but not CFF/CFF2. A CFF-based OTF font subsetted to any of these profiles loses ALL outlines — the output has `cmap`/`head`/`hmtx`/`maxp` but no CFF. The font has no glyph data.
13
-
14
- 2. **`full` profile includes CFF but doesn't subset it.** The full CFF table is copied verbatim while `maxp.numGlyphs` is updated to the subset count. The CFF CharStrings INDEX has the original glyph count; `maxp` says fewer. Invalid mismatch — fontTools and Chrome reject.
15
-
16
- This affects every CFF-based OpenType font (the majority of professional fonts — Adobe, Google Fonts OTFs, variable CFF2 fonts).
17
-
18
- ## Goal
19
-
20
- Two new strategy classes:
21
- - `Subset::TableStrategy::Cff` — subsets CFF v1 tables
22
- - `Subset::TableStrategy::Cff2` — subsets CFF2 tables (variable-font aware)
23
-
24
- Both registered in the REGISTRY. The `web` and `pdf` profiles updated to include CFF/CFF2 (conditionally — only when the source font has them; the profile loader already handles this via "if table present").
25
-
26
- ## Approach
27
-
28
- **Architecturally preferred path (TODO #05 + #10b dependency):**
29
-
30
- If the CFF → UFO conversion (`Ufo::Convert::FromBinData#extract_cff_glyphs`, currently stubbed as TODO #10b) is fully implemented, AND the OTF compiler emits real CFF charstrings (TODO #05), then CFF subsetting is trivial:
31
-
32
- ```
33
- CFF font → Ufo::Convert::FromBinData → UFO (with contours)
34
- → drop glyphs not in mapping
35
- → Ufo::Compile::OtfCompiler → new CFF
36
- ```
37
-
38
- No standalone INDEX rebuilder needed. The UFO model is the canonical representation; CFF is a serialization. This is DRY, MECE, OCP-compliant.
39
-
40
- **Fallback path (standalone CFF INDEX rebuilder):**
41
-
42
- If TODO #05 + #10b are not yet done, a standalone strategy can work at the binary level:
43
-
44
- 1. Parse CFF header → Name INDEX → Top DICT INDEX → String INDEX → Global Subr INDEX
45
- 2. Decode Top DICT operators → get charset offset, CharStrings offset, Private offset
46
- 3. Parse CharStrings INDEX → get byte range per charstring
47
- 4. Filter to subset GIDs
48
- 5. Rebuild CharStrings INDEX with retained charstrings
49
- 6. Rebuild charset to match new GID ordering
50
- 7. Optionally prune GlobalSubrs/PrivateSubrs
51
- 8. Recompute all offsets in Top DICT
52
- 9. Reassemble CFF bytes
53
-
54
- This is more work than the UFO round-trip path and duplicates logic the compile pipeline already has. Prefer the UFO path.
55
-
56
- ## Out of scope
57
-
58
- - CFF2 blend/vsindex ENCODING (TODO 06) — that's about generating new CFF2 from scratch, not subsetting existing CFF2.
59
- - OTF compiler real CFF (TODO 05) — that's about building CFF from UFO outlines.
60
- - Font-level outline conversion (TTF→OTF) — that's `Converters::OutlineConverter`.
61
-
62
- ## Effort
63
-
64
- ~1-2 days for CFF v1 (well-understood algorithm).
65
- ~1 additional day for CFF2 (adds FDSelect + ItemVariationStore handling).
66
-
67
- ## Dependencies
68
-
69
- None. The CFF/CFF2 BinData models already exist.
70
-
71
- ## Acceptance criteria
72
-
73
- - A CFF-based OTF font subsetted to the `web` profile produces valid output (fontTools accepts it, Chrome OTS doesn't reject).
74
- - The subset CFF table has exactly `subset_glyph_count` charstrings (not the source's full count).
75
- - Subroutines referenced only by dropped glyphs are pruned.
76
- - CFF2 variable fonts retain their ItemVariationStore and variation deltas after subsetting.
77
- - New spec covers: CFF font → web subset → fontTools decode → glyph count matches.
78
- - Profile YAML updated: `web` and `pdf` profiles include CFF/CFF2 conditionally.
@@ -1,58 +0,0 @@
1
- # Fontisan Improvements Backlog
2
-
3
- This directory tracks all known improvement work, ordered by priority.
4
- Each file is `NN-short-name.md` where `NN` is the priority order.
5
-
6
- ## Priorities
7
-
8
- ### P0 — Correctness gaps (open bugs / silent failures)
9
- - [x] ~~[01 — CBDT/CBLC GID-stable propagation](01-cbdt-cblc-gid-stable-propagation.md)~~ ✓ Done (PR #115)
10
- - [x] ~~[02 — Collection-mode outline-priority regression](02-collection-outline-priority.md)~~ ✓ Already fixed
11
- - [x] ~~[15 — CFF/CFF2 subsetter strategy](15-cff-cff2-subsetter-strategy.md)~~ ✓ Done — CFF via UFO round-trip, CFF2 via standalone INDEX filter with VStore preservation
12
-
13
- ### P1 — High-value features
14
- - [x] ~~[03 — `fontisan audit` command (identity+style+features lens)](03-fontisan-audit-command.md)~~ ✓ Done (Phase 1: identity, style, coverage, layout, provenance; Phase 2 axes: table directory, glyph names, cmap, OTS, collection integrity; Phase 3 axes: variable-font, hinting, WOFF2, format-round-trip; Phase 3 axis 14 (full OT conformance): cross-table conformance + per-table checks for head, hhea, maxp, OS/2, name, post, kern, CFF/CFF2, glyf, GSUB/GPOS layout; CLI `fontisan audit --validate` with 20 checks across 9 profiles; CI exit codes via `--fail-on-error`; profile discovery via `--list-profiles`; audit summary model with error/warning/info counts)
15
- - [x] ~~[04 — UFO composite glyph encoding](04-ufo-composite-glyph-encoding.md)~~ ✓ Done
16
- - [x] ~~[05 — OTF compiler real CFF charstrings](05-otf-compiler-real-cff.md)~~ ✓ Already working (discovered in PR #117 — Cff.build produces real Type 2 charstrings; stale TODO marker removed)
17
-
18
- ### P2 — Specialist feature parity
19
- - [x] ~~[07 — CPAL v1 header fields](07-cpal-v1-header-fields.md)~~ ✓ Done (v0.4.25)
20
- - [x] ~~[08 — CFF standard string table](08-cff-standard-string-table.md)~~ ✓ Done (full 391 SIDs per Adobe TN 5176)
21
- - [x] ~~[06 — CFF2 blend/vsindex operators](06-cff2-blend-vsindex-operators.md)~~ ✓ Done — `Cff2.build_variable` emits blend operators in charstrings; `VariableOtf` passes masters through; VStore embedded with regions
22
- - [x] ~~[09 — Type 1 seac expansion](09-type1-seac-expansion.md)~~ ✓ Done — recursive seac expansion with cycle detection; `CharStrings.from_hash` factory added for clean test construction
23
- - [x] ~~[10 — UFO image set + feature writers](10-ufo-image-set-feature-writers.md)~~ ✓ Done — `ImageSet` loads/writes UFO 3 images directory; `FeatureCompiler` parses liga/kern FEA constructs; `Compile::Gsub` builds LigatureSubst GSUB
24
- - [x] ~~[11 — kern groups.plist support](11-kern-groups-plist.md)~~ ✓ Done (Groups model in PR #116 + GPOS group resolution in this PR)
25
-
26
- ### P3 — Code-quality cleanup
27
- - [x] ~~[13 — Split `OctokitFetcher` out of `fixture_downloader.rb`](13-split-octokit-fetcher.md)~~ ✓ Done (v0.4.24)
28
- - [x] ~~[12 — `cbdt_fixture.rb` full BinData conversion](12-cbdt-fixture-bindata-conversion.md)~~ ✓ Done (critical tables converted; remaining os2/name/hmtx/cmap verified correct, BinData conversion is diminishing returns)
29
- - [x] ~~[14 — Rubocop baseline chip (per-namespace)](14-rubocop-baseline-chip.md)~~ ✓ Partially done — all auto-correctable offenses fixed; all namespaces pass `rubocop` with 0 new offenses; Naming cops configured for font-domain conventions; remaining ~9800 baseline offenses are structural Metrics (MethodLength, AbcSize, LineLength) explicitly out of scope per TODO ("Refactoring architectural patterns — separate refactors"); estimated ~7h manual refactoring effort
30
-
31
- ## Convention
32
-
33
- Each TODO file follows this template:
34
-
35
- ```markdown
36
- # NN — Title
37
-
38
- ## Priority
39
- P0 / P1 / P2 / P3
40
-
41
- ## Problem
42
- What's broken or missing. Concrete examples.
43
-
44
- ## Goal
45
- What good looks like. Acceptance criteria.
46
-
47
- ## Approach
48
- Architecture-level sketch. Files to add/change. Constraints.
49
-
50
- ## Out of scope
51
- Explicit non-goals.
52
-
53
- ## Effort
54
- Rough estimate (hours/days).
55
-
56
- ## Dependencies
57
- Other TODOs that must land first.
58
- ```