feat(libSceFreeType): expose CID font metadata #9545

Merged
Ondra97 merged 2 commits from upstream-pr/9545 into main 2026-10-24 19:24:53 +00:00
Ondra97 commented 2026-10-22 01:16:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T01:16:06Z.


What

Expose the three CID-font metadata queries through the existing guest-to-native face bridge:

Export NID
FT_Get_CID_Registry_Ordering_Supplement Pr3eI2uGgvU
FT_Get_CID_Is_Internally_CID_Keyed p-LFZYbDPDU
FT_Get_CID_From_Glyph_Index NLwiYXdX5WU

Return the native registry/ordering/supplement, CID-keyed status and character-string-index/CID mapping, including the native errors and output initialization for unsupported or null faces. Optional and aliased output pointers retain the native behavior. Compile-time checks establish a one-byte FT_Bool and four-byte FT_Int/FT_UInt; registry and ordering strings remain owned by the corresponding native face.

The names/NIDs match the pinned PS5 3.20 inventory. The contracts come from bundled ftcid.c, its CFF metadata service and the public CID API. Console ABI/version and metadata equivalence remain unverified and are recorded in library debt.

The regression creates its own small raw CFF fonts from INDEX/DICT primitives: Adobe / Identity / 7 maps character-string index 1 to CID 41; a second CID font uses different registry/ordering names, supplement 9 and CID 65535. Name-keyed CFF and TrueType fonts exercise the distinct unsupported/non-CID paths. No external font asset or new dependency is needed.

The former merge-order predecessor #9538 is merged, together with #9309. The branch retains their outline-orientation and character-size implementation and tests. #9530 and #9574 are also merged; their Gasp and trigonometry implementations and tests remain preserved alongside the newer kerning implementation. No title unblock or performance improvement is claimed.

Tested

Rebased on upstream main dc9f1ef656367272f8485b8ed1e11378adf45a2e; tested PR head e3a69bc1c6feff671965c2fb9610b27753ff5d3d. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, BUILD_TESTING=ON, pinned bundled dependencies. The FreeType/font tests use the CPU.

  • cmake --build <build> --target relinker libs patched_libraries_tests guest_freetype_tests guest_freetype_bitmap_tests guest_freetype_request_size_tests guest_freetype_outline_tests guest_freetype_outline_mutations_tests guest_freetype_charmap_tests guest_freetype_charmap_info_tests guest_freetype_face_info_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_list_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests --parallel 8: production relinker, patched libraries and all selected fixtures built on the rebased source.
  • ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error: 18/18 passed, zero skips; 368 patched libraries loaded, zero failures. CID regression: 115 query scenarios across four fonts, four rendered glyphs. Main's merged trigonometry regression also ran (4,226 scalar cases, 1,764 angle differences and 68 LP64 tangent goldens).
  • Export.cpp is byte-identical to the previous submitted head. git range-diff retained both commits; the sole conflict resolution preserved upstream FT_TRIGONOMETRY_H beside this PR's FT_CID_H in the test includes. The existing orientation, Gasp, bitmap and trigonometry fixtures remained registered and executed.
  • python tools/check_conventions.py --base origin/main, python tools/check_main_sync.py --base origin/main --strict, git diff origin/main...HEAD --check and python tools/check_test_registration.py <build>: passed. python tools/pr_overlap.py --branch codex/pr9545-rebase-20261024 --repo boykopovar/AnyPS5 --jobs 12 completed; #9550 adds separate size exports at a shared header insertion, and the old #9545 branch is the expected self-match.

No title/homebrew run or complete CTest suite is claimed on this rebased head. Console ABI/version and metadata equivalence remain unverified as recorded in debt.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4960591680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T01:16:06Z. --- ### What Expose the three CID-font metadata queries through the existing guest-to-native face bridge: | Export | NID | |---|---| | `FT_Get_CID_Registry_Ordering_Supplement` | `Pr3eI2uGgvU` | | `FT_Get_CID_Is_Internally_CID_Keyed` | `p-LFZYbDPDU` | | `FT_Get_CID_From_Glyph_Index` | `NLwiYXdX5WU` | Return the native registry/ordering/supplement, CID-keyed status and character-string-index/CID mapping, including the native errors and output initialization for unsupported or null faces. Optional and aliased output pointers retain the native behavior. Compile-time checks establish a one-byte `FT_Bool` and four-byte `FT_Int`/`FT_UInt`; registry and ordering strings remain owned by the corresponding native face. The names/NIDs match the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). The contracts come from bundled [ftcid.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftcid.c), its [CFF metadata service](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/cff/cffdrivr.c) and the [public CID API](https://freetype.org/freetype2/docs/reference/ft2-cid_fonts.html). Console ABI/version and metadata equivalence remain unverified and are recorded in library debt. The regression creates its own small raw CFF fonts from INDEX/DICT primitives: `Adobe / Identity / 7` maps character-string index 1 to CID 41; a second CID font uses different registry/ordering names, supplement 9 and CID 65535. Name-keyed CFF and TrueType fonts exercise the distinct unsupported/non-CID paths. No external font asset or new dependency is needed. The former merge-order predecessor #9538 is merged, together with #9309. The branch retains their outline-orientation and character-size implementation and tests. #9530 and #9574 are also merged; their Gasp and trigonometry implementations and tests remain preserved alongside the newer kerning implementation. No title unblock or performance improvement is claimed. ### Tested Rebased on upstream `main` `dc9f1ef656367272f8485b8ed1e11378adf45a2e`; tested PR head `e3a69bc1c6feff671965c2fb9610b27753ff5d3d`. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, `BUILD_TESTING=ON`, pinned bundled dependencies. The FreeType/font tests use the CPU. - `cmake --build <build> --target relinker libs patched_libraries_tests guest_freetype_tests guest_freetype_bitmap_tests guest_freetype_request_size_tests guest_freetype_outline_tests guest_freetype_outline_mutations_tests guest_freetype_charmap_tests guest_freetype_charmap_info_tests guest_freetype_face_info_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_list_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests --parallel 8`: production relinker, patched libraries and all selected fixtures built on the rebased source. - `ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error`: 18/18 passed, zero skips; 368 patched libraries loaded, zero failures. CID regression: 115 query scenarios across four fonts, four rendered glyphs. Main's merged trigonometry regression also ran (4,226 scalar cases, 1,764 angle differences and 68 LP64 tangent goldens). - `Export.cpp` is byte-identical to the previous submitted head. `git range-diff` retained both commits; the sole conflict resolution preserved upstream `FT_TRIGONOMETRY_H` beside this PR's `FT_CID_H` in the test includes. The existing orientation, Gasp, bitmap and trigonometry fixtures remained registered and executed. - `python tools/check_conventions.py --base origin/main`, `python tools/check_main_sync.py --base origin/main --strict`, `git diff origin/main...HEAD --check` and `python tools/check_test_registration.py <build>`: passed. `python tools/pr_overlap.py --branch codex/pr9545-rebase-20261024 --repo boykopovar/AnyPS5 --jobs 12` completed; #9550 adds separate size exports at a shared header insertion, and the old #9545 branch is the expected self-match. No title/homebrew run or complete CTest suite is claimed on this rebased head. Console ABI/version and metadata equivalence remain unverified as recorded in debt. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-22 01:17:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:17:00Z.

Review: APPROVED


Reviewed the full adapter and regression diff against the pinned bundled FreeType 2.13.3 CID API. The wrappers preserve the native functions’ null-face, output initialization, optional/aliased output and per-font metadata behavior through the existing guest-face ownership map; the tests construct CID and non-CID fonts and compare each result/error against native FreeType, including output guards and rendering checks. The PR is based on current main, declares its shared-insertion order after #9538, and the branch overlap scan found no additional code overlap. Hosted eligibility, conventions, intake, labels and report checks pass; build jobs were skipped by path policy. The Windows builds/tests and syntax/registration checks in the PR description are author-reported; I did not run a local build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608155511 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545#pullrequestreview-5608155511). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:17:00Z. **Review:** APPROVED --- Reviewed the full adapter and regression diff against the pinned bundled FreeType 2.13.3 CID API. The wrappers preserve the native functions’ null-face, output initialization, optional/aliased output and per-font metadata behavior through the existing guest-face ownership map; the tests construct CID and non-CID fonts and compare each result/error against native FreeType, including output guards and rendering checks. The PR is based on current main, declares its shared-insertion order after #9538, and the branch overlap scan found no additional code overlap. Hosted eligibility, conventions, intake, labels and report checks pass; build jobs were skipped by path policy. The Windows builds/tests and syntax/registration checks in the PR description are author-reported; I did not run a local build.
Ondra97 commented 2026-10-22 01:56:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T01:56:22Z.


I opened #9550 to add FT_New_Size, FT_Activate_Size and FT_Done_Size. I declared #9545 for merge order because both patches add FreeType API header includes at the same Export.cpp insertion. Retain both FT_CID_H and FT_SIZES_H; the implementations are independent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330815522 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545#issuecomment-6330815522). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T01:56:22Z. --- I opened #9550 to add FT_New_Size, FT_Activate_Size and FT_Done_Size. I declared #9545 for merge order because both patches add FreeType API header includes at the same Export.cpp insertion. Retain both FT_CID_H and FT_SIZES_H; the implementations are independent.
MarcZX10 commented 2026-10-22 01:58:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:58:35Z.

Review: APPROVED


Rechecked the unchanged head and the declared #9538 merge-order dependency. The three CID adapters match the pinned FreeType behavior, and the generated CFF/native-comparison coverage addresses CID, named-CFF and TrueType paths, including optional and aliased outputs. Eligibility, conventions, intake, labels and report checks pass; product/relinker jobs were skipped. I did not run local tests. Approval remains conditional on merging #9538 first as declared.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608401690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545#pullrequestreview-5608401690). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:58:35Z. **Review:** APPROVED --- Rechecked the unchanged head and the declared #9538 merge-order dependency. The three CID adapters match the pinned FreeType behavior, and the generated CFF/native-comparison coverage addresses CID, named-CFF and TrueType paths, including optional and aliased outputs. Eligibility, conventions, intake, labels and report checks pass; product/relinker jobs were skipped. I did not run local tests. Approval remains conditional on merging #9538 first as declared.
fogydes commented 2026-10-22 08:41:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:41:10Z.


Reviewed; verified against the pinned freetype source. The three CID wrappers delegate to the host FreeType through the existing face bridge (FaceOf + null host through), so every answer — including the null-face path, where the host initializes the outputs and then answers Invalid_Argument — is the pinned 2.13.3 build's own behavior from ftcid.c/cffdrivr.c rather than anything written down here; the test's three input classes (name-keyed CFF, keyed-CFF, naked-CFF/TrueType) map onto exactly those driver implementations. The static_assert pinning FT_Bool at 1 byte, FT_Int/FT_UInt at 4 matches the guest ABI those exports promise, so no re-wrapping of the FT_Bool return is needed. The debt entry honestly scopes what's unverified and links the pinned ftcid.c blob, and the native-face lifetime of the returned registry/ordering strings is called out. Existing guest_freetype test stays under its budget; no registration change needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336550174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545#issuecomment-6336550174). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:41:10Z. --- Reviewed; verified against the pinned freetype source. The three CID wrappers delegate to the host FreeType through the existing face bridge (`FaceOf` + null host through), so every answer — including the null-face path, where the host initializes the outputs and then answers `Invalid_Argument` — is the pinned 2.13.3 build's own behavior from `ftcid.c`/`cffdrivr.c` rather than anything written down here; the test's three input classes (name-keyed CFF, keyed-CFF, naked-CFF/TrueType) map onto exactly those driver implementations. The `static_assert` pinning `FT_Bool` at 1 byte, `FT_Int`/`FT_UInt` at 4 matches the guest ABI those exports promise, so no re-wrapping of the FT_Bool return is needed. The debt entry honestly scopes what's unverified and links the pinned `ftcid.c` blob, and the native-face lifetime of the returned registry/ordering strings is called out. Existing `guest_freetype` test stays under its budget; no registration change needed.
MarcZX10 commented 2026-10-22 11:32:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:32:14Z.


The detailed CID/native comparison and independent source review support the implementation; the declared #9538-before-#9545 insertion order remains correct while #9538 is open. I refreshed checks against upstream/main 4777caca34: diff-check and conventions pass, and the merge is clean, but this head is 2 ahead/119 behind (merge base a6dcea927). No intervening main commits changed the CID adapter, its tests or debt file. Please update to current main and rerun the focused FreeType tests/convention/overlap checks on the resulting head. The Windows tests remain author-reported; product/relinker jobs are skipped. I did not run local C++ tests because the root filesystem is full.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339697799 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545#issuecomment-6339697799). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:32:14Z. --- The detailed CID/native comparison and independent source review support the implementation; the declared #9538-before-#9545 insertion order remains correct while #9538 is open. I refreshed checks against upstream/main 4777caca34: diff-check and conventions pass, and the merge is clean, but this head is 2 ahead/119 behind (merge base a6dcea927). No intervening main commits changed the CID adapter, its tests or debt file. Please update to current main and rerun the focused FreeType tests/convention/overlap checks on the resulting head. The Windows tests remain author-reported; product/relinker jobs are skipped. I did not run local C++ tests because the root filesystem is full.
MarcZX10 commented 2026-10-22 11:32:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:32:16Z.

Review: DISMISSED


The CID wrappers and generated-font tests remain sound on review, and the declared dependency on #9538 accurately records the insertion order. I am requesting only the repository freshness follow-up: this head is 2 ahead/119 behind current upstream/main 4777caca34 (merge base a6dcea927). Please update and rerun the focused FreeType tests and checks before merge, preserving the #9538 dependency and the follow-up chain. Diff-check, conventions and merge-tree pass on the current head; product/relinker jobs are skipped. I did not run local C++ tests due to the full filesystem.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613481091 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9545#pullrequestreview-5613481091). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:32:16Z. **Review:** DISMISSED --- The CID wrappers and generated-font tests remain sound on review, and the declared dependency on #9538 accurately records the insertion order. I am requesting only the repository freshness follow-up: this head is 2 ahead/119 behind current upstream/main 4777caca34 (merge base a6dcea927). Please update and rerun the focused FreeType tests and checks before merge, preserving the #9538 dependency and the follow-up chain. Diff-check, conventions and merge-tree pass on the current head; product/relinker jobs are skipped. I did not run local C++ tests due to the full filesystem.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9545
No description provided.