feat(libSceFreeType): implement advance queries #9399

Merged
Felipebmaitan merged 4 commits from upstream-pr/9399 into main 2026-10-28 08:21:17 +00:00
Felipebmaitan commented 2026-10-21 20:38:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-21T20:38:30Z.


What

The FreeType guest bridge lacks FT_Get_Advance and FT_Get_Advances. Add both exports using the bundled FreeType 2.13.3, with 32-bit glyph indices/flags and 64-bit guest FT_Fixed outputs.

Preserve validation order, empty ranges, fast-only failures, scaling and partial results on LP64 hosts. Synchronize glyph-slot snapshots when the fallback loads glyphs and when the CFF fast path loads glyphs without SFNT metrics; leave unrelated guest outline edits intact on paths that do not load glyphs. Publish outputs after synchronization so an output aliased to the guest slot is retained.

On Windows, successful native 32-bit FT_Fixed results are widened. Backend errors other than Unimplemented_Feature throw because the native buffer does not identify which results were written. This restriction, host overflow behavior and the unverified console ABI/version are recorded in debt.

Export names are in the PS5 3.20 FreeType inventory. Behavior follows bundled ftadvanc.c and cffdrivr.c. No open PR implementing these two functions was found in the refreshed search.

Merge ordering: #9398 goes first because both PRs insert a debt note at the same location. This is a documentation ordering dependency; the advance-query implementation does not require its code. After #9398 merges, rebase this PR onto updated upstream main, retain both debt notes, and rerun conventions and overlap checks before pushing.

Both advance exports are declared once in include/Api.hpp, reachable through prx/libSceFreeType/libSceFreeType.hpp. The implementation and advance test include the umbrella header; the test uses GuestLibrary* and has no local export declarations. Upstream main through 86fb985abb has been merged.

The refreshed overlap check also reports #9588 at the CMake source-list insertion point. It adds glyph APIs, not advance queries; neither implementation requires the other. Comparisons for several stale FreeType PRs remain incomplete because they conflict with main.

Tested

2026-10-28 update, after merging upstream main: Ubuntu 24.04 x86-64 Docker on Apple Silicon, GCC 13.3, Release, bundled dependencies.

  • Rebuilt libSceFreeType, libc/libkernel dependencies and the three focused FreeType test targets.
  • ctest --test-dir /tmp/anyps5-build -R '^public_headers' --output-on-failure -j 4: 65/65 passed, including the export declaration audit and all standalone-header compilation batches.
  • ctest --test-dir /tmp/anyps5-build -R '^guest_freetype(_charmap|_advances)?$' --output-on-failure -V: 3/3 passed.
  • python3 tools/check_conventions.py --base origin/main and git diff --check: passed. Refreshed the branch overlap check against upstream main.
  • Windows runtime and titles were not rerun for this update. The original validation follows.

Ubuntu 24.04 x86-64 Docker container on an Apple Silicon Mac, GCC 13.3, Release, bundled dependencies, base 0c6a5bd5938fde7bbc0bf720927c4584bd3e4700.

  • Configured the full project with BUILD_TESTING=ON; built the actual FreeType shared library, its libc/libkernel dependencies, all three registered FreeType test targets and nid_patcher.
  • ctest --test-dir /tmp/anyps5-build -R "^guest_freetype(_charmap|_advances)?$" --output-on-failure -V: 3/3 passed (guest_freetype_advances, guest_freetype, guest_freetype_charmap; total 0.16 s).
  • Generated TrueType, standalone CFF, OpenType CFF and malformed glyph fixtures exercise horizontal/vertical and scaled/unscaled advances, fast-only and fallback paths, negative advances, range overflow, zero counts, null-argument precedence, output guards, slot synchronization, preserved outline edits, aliased outputs and partial failure. Expected results and slot state are compared with native bundled FreeType.
  • Strict -Wall -Wextra -Werror compilation passed. Compiled mutations that suppress CFF synchronization or copy 32-bit output slots fail the regression.
  • The packaged FreeType target built successfully, including its broader system-library dependencies. NID transformation succeeded; the packaged module exports dMSDtQsYuJM and l55oKq6zmrA.
  • Repository convention and whitespace checks passed before pushing.
  • The pre-opening overlap check passed at the time. A subsequent bot report and local git merge-tree check confirmed a documentation conflict with #9398 in docs/dev/debt/libSceFreeType.md; the implementations do not overlap.

Windows runtime, PS5 hardware, commercial titles and the full test suite were not tested.

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: #9398
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4958032069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9399). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-21T20:38:30Z. --- ### What The FreeType guest bridge lacks `FT_Get_Advance` and `FT_Get_Advances`. Add both exports using the bundled FreeType 2.13.3, with 32-bit glyph indices/flags and 64-bit guest `FT_Fixed` outputs. Preserve validation order, empty ranges, fast-only failures, scaling and partial results on LP64 hosts. Synchronize glyph-slot snapshots when the fallback loads glyphs and when the CFF fast path loads glyphs without SFNT metrics; leave unrelated guest outline edits intact on paths that do not load glyphs. Publish outputs after synchronization so an output aliased to the guest slot is retained. On Windows, successful native 32-bit `FT_Fixed` results are widened. Backend errors other than `Unimplemented_Feature` throw because the native buffer does not identify which results were written. This restriction, host overflow behavior and the unverified console ABI/version are recorded in debt. Export names are in the [PS5 3.20 FreeType inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). Behavior follows bundled [ftadvanc.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftadvanc.c) and [cffdrivr.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/cff/cffdrivr.c). No open PR implementing these two functions was found in the refreshed search. Merge ordering: #9398 goes first because both PRs insert a debt note at the same location. This is a documentation ordering dependency; the advance-query implementation does not require its code. After #9398 merges, rebase this PR onto updated upstream `main`, retain both debt notes, and rerun conventions and overlap checks before pushing. Both advance exports are declared once in `include/Api.hpp`, reachable through `prx/libSceFreeType/libSceFreeType.hpp`. The implementation and advance test include the umbrella header; the test uses `GuestLibrary*` and has no local export declarations. Upstream `main` through `86fb985abb` has been merged. The refreshed overlap check also reports #9588 at the CMake source-list insertion point. It adds glyph APIs, not advance queries; neither implementation requires the other. Comparisons for several stale FreeType PRs remain incomplete because they conflict with `main`. ### Tested 2026-10-28 update, after merging upstream `main`: Ubuntu 24.04 x86-64 Docker on Apple Silicon, GCC 13.3, Release, bundled dependencies. - Rebuilt `libSceFreeType`, libc/libkernel dependencies and the three focused FreeType test targets. - `ctest --test-dir /tmp/anyps5-build -R '^public_headers' --output-on-failure -j 4`: 65/65 passed, including the export declaration audit and all standalone-header compilation batches. - `ctest --test-dir /tmp/anyps5-build -R '^guest_freetype(_charmap|_advances)?$' --output-on-failure -V`: 3/3 passed. - `python3 tools/check_conventions.py --base origin/main` and `git diff --check`: passed. Refreshed the branch overlap check against upstream `main`. - Windows runtime and titles were not rerun for this update. The original validation follows. Ubuntu 24.04 x86-64 Docker container on an Apple Silicon Mac, GCC 13.3, Release, bundled dependencies, base `0c6a5bd5938fde7bbc0bf720927c4584bd3e4700`. - Configured the full project with `BUILD_TESTING=ON`; built the actual FreeType shared library, its libc/libkernel dependencies, all three registered FreeType test targets and `nid_patcher`. - `ctest --test-dir /tmp/anyps5-build -R "^guest_freetype(_charmap|_advances)?$" --output-on-failure -V`: 3/3 passed (`guest_freetype_advances`, `guest_freetype`, `guest_freetype_charmap`; total 0.16 s). - Generated TrueType, standalone CFF, OpenType CFF and malformed glyph fixtures exercise horizontal/vertical and scaled/unscaled advances, fast-only and fallback paths, negative advances, range overflow, zero counts, null-argument precedence, output guards, slot synchronization, preserved outline edits, aliased outputs and partial failure. Expected results and slot state are compared with native bundled FreeType. - Strict `-Wall -Wextra -Werror` compilation passed. Compiled mutations that suppress CFF synchronization or copy 32-bit output slots fail the regression. - The packaged FreeType target built successfully, including its broader system-library dependencies. NID transformation succeeded; the packaged module exports `dMSDtQsYuJM` and `l55oKq6zmrA`. - Repository convention and whitespace checks passed before pushing. - The pre-opening overlap check passed at the time. A subsequent bot report and local `git merge-tree` check confirmed a documentation conflict with #9398 in `docs/dev/debt/libSceFreeType.md`; the implementations do not overlap. Windows runtime, PS5 hardware, commercial titles and the full test suite were not tested. <!-- 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: <!-- #PR, or none --> #9398 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
Felipebmaitan commented 2026-10-21 22:13:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-21T22:13:56Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9398 docs/dev/debt/libSceFreeType.md L7

Marked as dependent on #9398 .

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6327714855 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9399#issuecomment-6327714855). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-21T22:13:56Z. --- > Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. > > Pull request Conflicting files (lines on `main`) Same exports Same new files > [PR 9398](https://www.github.com/boykopovar/AnyPS5/pull/9398) `docs/dev/debt/libSceFreeType.md` [L7](https://github.com/boykopovar/AnyPS5/blob/0c6a5bd5938fde7bbc0bf720927c4584bd3e4700/docs/dev/debt/libSceFreeType.md#L7) Marked as dependent on #9398 .
ycbuzi commented 2026-10-21 22:41:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T22:41:44Z.


Windows run of 59d661a231 merged onto main a6dcea9279 (821d56531c, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceFreeType and guest_freetype_advances_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_freetype_advances: passes on both repeats. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328163635 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9399#issuecomment-6328163635). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T22:41:44Z. --- Windows run of 59d661a231 merged onto `main` a6dcea9279 (821d56531c, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceFreeType` and `guest_freetype_advances_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `guest_freetype_advances`: passes on both repeats. Not run: a title.
MarcZX10 commented 2026-10-22 05:41:58 +00:00 (Migrated from github.com)

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

Review: DISMISSED


The adapters follow the bundled FreeType 2.13.3 implementation and preserve the documented partial-result and slot-synchronization behavior. The fixture coverage is strong, including malformed glyph data, aliased outputs, fast-only failures, CFF paths, and platform-specific FT_Fixed handling. The reported full target build and focused 3/3 test run, plus the independent Windows focused run, are useful evidence. git diff --check passes and the current head merges cleanly with main.

The declared Depends on: #9398 matches the shared debt-entry conflict. Once #9398 lands, please rebase this branch onto then-current main (currently 4a17c71757) and rerun the focused FreeType tests, conventions, and overlap checks. The recorded Linux tests use base 0c6a5bd593; hosted product build jobs are skipped. I did not run a local FreeType build or test in this environment.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609736341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9399#pullrequestreview-5609736341). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T05:41:58Z. **Review:** DISMISSED --- The adapters follow the bundled FreeType 2.13.3 implementation and preserve the documented partial-result and slot-synchronization behavior. The fixture coverage is strong, including malformed glyph data, aliased outputs, fast-only failures, CFF paths, and platform-specific `FT_Fixed` handling. The reported full target build and focused 3/3 test run, plus the independent Windows focused run, are useful evidence. `git diff --check` passes and the current head merges cleanly with `main`. The declared `Depends on: #9398` matches the shared debt-entry conflict. Once #9398 lands, please rebase this branch onto then-current `main` (currently `4a17c71757`) and rerun the focused FreeType tests, conventions, and overlap checks. The recorded Linux tests use base `0c6a5bd593`; hosted product build jobs are skipped. I did not run a local FreeType build or test in this environment.
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!9399
No description provided.