feat(libSceFreeType): support per-face x-height limits #12668

Merged
Queuse merged 1 commit from upstream-pr/12668 into main 2026-10-29 04:33:48 +00:00
Queuse commented 2026-10-29 01:09:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Queuse on 2026-10-29T01:09:58Z.


What

Implement autofitter/increase-x-height in the existing FT_Property_Get/FT_Property_Set bridge. These calls currently throw despite the bundled backend supporting the property. Translate the carrier's guest face through the existing face bridge, forward to native FreeType, and copy only the 32-bit limit back after a successful getter.

The carrier and behavior follow bundled FreeType 2.13.3. This lets callers configure auto-hinter x-height rounding per face. Other unsupported properties still throw; console ABI and property availability remain documented as unverified.

Tested

Windows, GCC 15.2.0, Release full-runtime configuration:

  • Built libSceFreeType and nid_patcher; rebuilt the dynamic guest test executable and required runtime artifacts with their CMake-generated recipes.
  • ctest --test-dir build -R '^guest_freetype_module_properties(_nid)?$' --output-on-failure: 2/2 passed, using normal symbols and NIDs.
  • Generated-font cases compare initial/read/write results with native FreeType, including limits 0, 6, 20, 42 and UINT32_MAX, per-face isolation, valid cross-library access, null-face errors, and preservation of the face pointer, padding and setter input.
  • The new guest regression reproduced the existing FT_Property_Get_nid_postfix not implemented exception before the adapter was added.
  • Conventions, test-registration audit and diff checks passed.
  • pr_overlap.py --branch codex/freetype-increase-x-height checked 1,392 open PRs. Manually checked shared headers/debt for #9419, #9465 and #10897, whose unrelated conflicts prevent automatic comparison; those shared files merge cleanly with this change and contain no duplicate property implementation.

No title or console hardware validation.

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:5060313574 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12668). Originally posted by [Queuse](https://github.com/Queuse) on 2026-10-29T01:09:58Z. --- ### What Implement `autofitter/increase-x-height` in the existing `FT_Property_Get`/`FT_Property_Set` bridge. These calls currently throw despite the bundled backend supporting the property. Translate the carrier's guest face through the existing face bridge, forward to native FreeType, and copy only the 32-bit limit back after a successful getter. The carrier and behavior follow bundled [FreeType 2.13.3](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/autofit/afmodule.c). This lets callers configure auto-hinter x-height rounding per face. Other unsupported properties still throw; console ABI and property availability remain documented as unverified. ### Tested Windows, GCC 15.2.0, Release full-runtime configuration: - Built `libSceFreeType` and `nid_patcher`; rebuilt the dynamic guest test executable and required runtime artifacts with their CMake-generated recipes. - `ctest --test-dir build -R '^guest_freetype_module_properties(_nid)?$' --output-on-failure`: 2/2 passed, using normal symbols and NIDs. - Generated-font cases compare initial/read/write results with native FreeType, including limits 0, 6, 20, 42 and UINT32_MAX, per-face isolation, valid cross-library access, null-face errors, and preservation of the face pointer, padding and setter input. - The new guest regression reproduced the existing `FT_Property_Get_nid_postfix not implemented` exception before the adapter was added. - Conventions, test-registration audit and diff checks passed. - `pr_overlap.py --branch codex/freetype-increase-x-height` checked 1,392 open PRs. Manually checked shared headers/debt for #9419, #9465 and #10897, whose unrelated conflicts prevent automatic comparison; those shared files merge cleanly with this change and contain no duplicate property implementation. No title or console hardware validation. <!-- 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 -->
rooklz commented 2026-10-29 03:58:50 +00:00 (Migrated from github.com)

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

Review: APPROVED


Checked d2ce672d13 on macOS arm64 (Apple clang, ASan+UBSan). This is the first run outside Windows.

Differential against bundled FreeType. I built FreeType from the submodule commit 42608f77f2 and linked the PR's ModuleProperties.cpp unmodified into a standalone harness, with a real FaceOf and a GuestFace wrapping a host face. For each of the 370 system faces in /System/Library/Fonts and /Library/Fonts:

  • an initial get;
  • a set and get for limits 0, 1, 6, 20, 42, 0x7fffffff, 0x80000000 and 0xffffffff;
  • after each set, FT_LOAD_FORCE_AUTOHINT on the first 64 glyphs at 16 px, comparing the error, height/bearing and outline points against a native face given the same property.

Across those faces the harness also checks byte-exact carrier buffers (0xA5/0xCC fill, so only bytes 8..11 change on a successful get, and the setter input is untouched), plus null-face and orphan-face (internal == nullptr) gets. Result: 185,021 calls, 0 diffs, 0 sanitizer reports, 3.9 s. Main's ModuleProperties.cpp stops at FT_Property_Get_nid_postfix not implemented, as the body says.

Mutants (applied to the PR source):

mutant result
setter forces face = nullptr killed (5,550 diffs)
setter truncates limit to 16 bits killed (1,110 diffs)
setter skips limit 0 killed
getter copies 8 bytes instead of 4 killed by ASan (stack-buffer-overflow at L61)
getter copies on error survives my harness (its null-face row compares errors only); from reading the code, your QueryIncreaseXHeight(nullptr) storage comparison should catch it, but I did not run the guest test

The forwarding matches afmodule.c L185/L334: af_property_get_face_globals returns Invalid_Face_Handle for a null face and builds the globals lazily, so passing face->host and copying back only on !error is right. merge-tree against main b433c40f2f is clean, and check_conventions --base upstream/main passes.

Non-blocking: FaceOf trusts internal, as the other face-taking exports do, so a stale guest face behaves the same here as it does elsewhere.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692673714 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12668#pullrequestreview-5692673714). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T03:58:50Z. **Review:** APPROVED --- Checked d2ce672d13 on macOS arm64 (Apple clang, ASan+UBSan). This is the first run outside Windows. **Differential against bundled FreeType.** I built FreeType from the submodule commit 42608f77f2 and linked the PR's `ModuleProperties.cpp` unmodified into a standalone harness, with a real `FaceOf` and a `GuestFace` wrapping a host face. For each of the 370 system faces in `/System/Library/Fonts` and `/Library/Fonts`: - an initial get; - a set and get for limits 0, 1, 6, 20, 42, 0x7fffffff, 0x80000000 and 0xffffffff; - after each set, `FT_LOAD_FORCE_AUTOHINT` on the first 64 glyphs at 16 px, comparing the error, height/bearing and outline points against a native face given the same property. Across those faces the harness also checks byte-exact carrier buffers (0xA5/0xCC fill, so only bytes 8..11 change on a successful get, and the setter input is untouched), plus null-face and orphan-face (`internal == nullptr`) gets. Result: 185,021 calls, **0 diffs**, 0 sanitizer reports, 3.9 s. Main's `ModuleProperties.cpp` stops at `FT_Property_Get_nid_postfix` not implemented, as the body says. **Mutants** (applied to the PR source): | mutant | result | |---|---| | setter forces `face = nullptr` | killed (5,550 diffs) | | setter truncates limit to 16 bits | killed (1,110 diffs) | | setter skips limit 0 | killed | | getter copies 8 bytes instead of 4 | killed by ASan (stack-buffer-overflow at L61) | | getter copies on error | survives my harness (its null-face row compares errors only); from reading the code, your `QueryIncreaseXHeight(nullptr)` storage comparison should catch it, but I did not run the guest test | The forwarding matches `afmodule.c` L185/L334: `af_property_get_face_globals` returns Invalid_Face_Handle for a null face and builds the globals lazily, so passing `face->host` and copying back only on `!error` is right. `merge-tree` against main b433c40f2f is clean, and `check_conventions --base upstream/main` passes. Non-blocking: `FaceOf` trusts `internal`, as the other face-taking exports do, so a stale guest face behaves the same here as it does elsewhere.
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!12668
No description provided.