feat(libSceFreeType): expose glyph-to-script maps #12680

Merged
SnekPolylepis merged 4 commits from upstream-pr/12680 into main 2026-10-30 06:16:57 +00:00
SnekPolylepis commented 2026-10-29 01:44:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SnekPolylepis on 2026-10-29T01:44:23Z.


What

Implement FT_Property_Get for the autofitter's glyph-to-script-map property. The adapter translates the guest face to its native face and returns the 16-bit glyph map allocated by the bundled FreeType backend. Its lifetime is tied to the face. The setter returns the bundled backend's missing-property error. This replaces an unimplemented exception for callers that query the property.

The carrier layout and behavior follow bundled FreeType 2.13.3. Console ABI, property availability and exact glyph classification are unverified and documented as debt.

Tested

  • Windows, WinLibs GCC 15.2: built a standalone harness against the changed adapter and the existing build's bundled FreeType static library. A generated font's map matched native FreeType; setter error, null-face error, preserved output and unaligned carrier cases passed. The harness supplies the existing face bridge and is not a full guest-library build.
  • The changed adapter and GuestFreeType.cpp compile in a syntax-only check. Added a guest regression that compares the map and error behavior against native FreeType, but the complete CMake guest test has not been run on this branch.
  • python tools/check_conventions.py --base origin/main and git diff --check pass.
  • tools/pr_overlap.py checked 1,404 open PRs. A merge simulation with #12668 is clean. Three PRs (#9419, #9465, #10897) could not be automatically compared because their branches conflict with main; their shared debt file was manually checked and merges cleanly. The final debt-note placement changed after the scan.
  • No console or title test.

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:5060628575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12680). Originally posted by [SnekPolylepis](https://github.com/SnekPolylepis) on 2026-10-29T01:44:23Z. --- ### What Implement `FT_Property_Get` for the autofitter's `glyph-to-script-map` property. The adapter translates the guest face to its native face and returns the 16-bit glyph map allocated by the bundled FreeType backend. Its lifetime is tied to the face. The setter returns the bundled backend's missing-property error. This replaces an unimplemented exception for callers that query the property. The carrier layout and behavior follow bundled [FreeType 2.13.3](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/autofit/afmodule.c). Console ABI, property availability and exact glyph classification are unverified and documented as debt. ### Tested - Windows, WinLibs GCC 15.2: built a standalone harness against the changed adapter and the existing build's bundled FreeType static library. A generated font's map matched native FreeType; setter error, null-face error, preserved output and unaligned carrier cases passed. The harness supplies the existing face bridge and is not a full guest-library build. - The changed adapter and `GuestFreeType.cpp` compile in a syntax-only check. Added a guest regression that compares the map and error behavior against native FreeType, but the complete CMake guest test has not been run on this branch. - `python tools/check_conventions.py --base origin/main` and `git diff --check` pass. - `tools/pr_overlap.py` checked 1,404 open PRs. A merge simulation with #12668 is clean. Three PRs (#9419, #9465, #10897) could not be automatically compared because their branches conflict with main; their shared debt file was manually checked and merges cleanly. The final debt-note placement changed after the scan. - No console or title test. <!-- 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
rooklz commented 2026-10-29 03:37:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T03:37:44Z.

Review: APPROVED


Independent check on macOS arm64 (Apple clang, ASan+UBSan), head cf9b7c6b39. This covers the macOS gap: the Linux lane was skipped and the body only lists Windows.

Setup: a standalone harness that compiles this PR's src/ModuleProperties.cpp unchanged. It links against FreeType built from source at the submodule commit 42608f77f2 (2.13.3, ASan/UBSan). It reuses the real FaceOf (face->internal) and builds a minimal GuestFace around each host face. A second, independent FT_Library serves as the native oracle.

Differential: every face in every .ttf/.ttc/.otf under /System/Library/Fonts{,/Supplemental} was checked: 787 faces, 2,385,223 glyphs, 15,740 calls, 0 diffs. For each face:

  • Get is called twice: once to make FreeType compute the globals, once to read the cached ones. The error codes match native, face is left unchanged, and map[0..num_glyphs) equals native.
  • Set matches native's error, and the carrier is left untouched.
  • A null face returns native's error and keeps the output map (7).
  • A null value or null library falls through to native with the same result.
  • Changing the module name to truetype, cff, Autofitter or autofitte still throws NotImplemented. The match is exact and case-sensitive.

Mutants (run on 5 fonts):

  • killed: copy on error · guest face passed through untranslated · autofitter module check dropped · map written at offset 0 · setter returns 0
  • equivalent: setter forwards the guest carrier instead of {}. af_property_set has no glyph-to-script-map branch, so it returns Missing_Property before it reads value.

Also checked: check_conventions --base upstream/main is clean, and git merge-tree with the sibling #12668 (increase-x-height, same file) is clean.

Nit, not blocking: #12668 puts its carrier in GuestFreeType.hpp with static_asserts on size and offsets. This PR declares GuestGlyphToScriptMap locally in the .cpp, and the test declares its own GuestMap. Moving the struct into the header next to GuestPropIncreaseXHeight, with static_assert(sizeof == 16 && offsetof(map) == 8), would let the test share the layout and keep the two carriers consistent.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692555595 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12680#pullrequestreview-5692555595). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T03:37:44Z. **Review:** APPROVED --- Independent check on macOS arm64 (Apple clang, ASan+UBSan), head cf9b7c6b39. This covers the macOS gap: the Linux lane was skipped and the body only lists Windows. **Setup:** a standalone harness that compiles this PR's `src/ModuleProperties.cpp` unchanged. It links against FreeType built from source at the submodule commit 42608f77f2 (2.13.3, ASan/UBSan). It reuses the real `FaceOf` (`face->internal`) and builds a minimal `GuestFace` around each host face. A second, independent `FT_Library` serves as the native oracle. **Differential:** every face in every `.ttf/.ttc/.otf` under `/System/Library/Fonts{,/Supplemental}` was checked: 787 faces, 2,385,223 glyphs, 15,740 calls, **0 diffs**. For each face: - Get is called twice: once to make FreeType compute the globals, once to read the cached ones. The error codes match native, `face` is left unchanged, and `map[0..num_glyphs)` equals native. - Set matches native's error, and the carrier is left untouched. - A null face returns native's error and keeps the output map (`7`). - A null value or null library falls through to native with the same result. - Changing the module name to `truetype`, `cff`, `Autofitter` or `autofitte` still throws `NotImplemented`. The match is exact and case-sensitive. **Mutants** (run on 5 fonts): - killed: copy on error · guest face passed through untranslated · `autofitter` module check dropped · map written at offset 0 · setter returns 0 - equivalent: setter forwards the guest carrier instead of `{}`. `af_property_set` has no `glyph-to-script-map` branch, so it returns `Missing_Property` before it reads `value`. Also checked: `check_conventions --base upstream/main` is clean, and `git merge-tree` with the sibling #12668 (increase-x-height, same file) is clean. Nit, not blocking: #12668 puts its carrier in `GuestFreeType.hpp` with `static_assert`s on size and offsets. This PR declares `GuestGlyphToScriptMap` locally in the .cpp, and the test declares its own `GuestMap`. Moving the struct into the header next to `GuestPropIncreaseXHeight`, with `static_assert(sizeof == 16 && offsetof(map) == 8)`, would let the test share the layout and keep the two carriers consistent. AI-assisted: yes
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!12680
No description provided.