feat(libSceFreeType): implement FT_Get_Gasp #9530

Merged
Ondra97 merged 2 commits from upstream-pr/9530 into main 2026-10-23 14:22:41 +00:00
Ondra97 commented 2026-10-22 00:24:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T00:24:58Z.


What

Implement the missing guest FT_Get_Gasp query (l4azYkX86Ds). Resolve the existing guest face to its native FreeType face and return the font's rasterizer-advice flags for the complete 32-bit ppem argument. This lets guest clients choose hinting and grayscale/monochrome rendering from the font's gasp table.

The name/NID is in the pinned PS5 3.20 inventory; the ABI follows the existing face bridge and public FT_Int(FT_Face, FT_UInt) signature. Behavior comes directly from bundled FreeType 2.13.3 ftgasp.c and its gasp table loader. Console version/result compatibility remains unverified and is recorded in debt. No title unblock or performance improvement is claimed.

Extend the existing font fixture with an optional, correctly indexed gasp table and exercise the query through the existing guest_freetype test. All eight synthetic fonts are checked against native FreeType and independently specified range results; rendering choices made from the returned flags also produce matching glyph bitmaps. There is no new CMake target or third-party dependency.

The former merge-order predecessor #9309 is merged; the branch includes its character-size implementation and current transform and naming tests.

Tested

Rebased on upstream main 0db47b263d1019043f7d28fad4e7ee0a1ea5ec6a; tested head ac06b871a9299345e55f64f7fa6e632bf02262ef. Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, BUILD_TESTING=ON, bundled dependencies. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER. Font rendering uses the CPU.

  • cmake --build ../build --target relinker libs guest_freetype_tests guest_freetype_charmap_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_request_size_tests patched_libraries_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests --parallel 8: production relinker, all patched libraries and selected runtime fixtures built successfully with submitted sources only.
  • ctest --test-dir ../build -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error: 12/12 passed, no skips, 1.80 s total; 367 patched libraries loaded, 0 failed.
  • Gasp regression: 8 synthetic fonts, 524,304 range/extreme-size queries, null-face checks and 14 rendered glyph comparisons against native FreeType. Current upstream coverage includes 1,555 outline-orientation cases, 2 rendered glyph comparisons, character-size, size requests, naming and font lifetimes.
  • 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; 1,209 test executables, none built and unregistered.
  • python tools/pr_overlap.py --branch codex/pr9530-rebase-20261023b --repo boykopovar/AnyPS5 --jobs 8: reviewed. The old #9530 head is the expected self-match; #9453 adds a throwing same-NID stub in the separate libSceFreeTypeOl library. #9560 and #9574 add independent functions at shared test/include insertions; their merge order is separate from this implementation. Remaining conflicting shared debt entries describe independent bitmap, bounding-box, PostScript or platform-export work. #9545 and #9550 add separate CID/size functions and test helpers. No other open PR implements this guest query in libSceFreeType.

The include conflict preserves main's <algorithm>/<bit> imports for outline orientation alongside FT_GASP_H. git range-diff confirms unchanged query and regression behavior. The original missing-feature baseline cannot link this regression because it lacks FT_Get_Gasp_nid_postfix. Console compatibility and title-level impact remain unverified.

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:4960181451 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T00:24:58Z. --- ### What Implement the missing guest `FT_Get_Gasp` query (`l4azYkX86Ds`). Resolve the existing guest face to its native FreeType face and return the font's rasterizer-advice flags for the complete 32-bit ppem argument. This lets guest clients choose hinting and grayscale/monochrome rendering from the font's `gasp` table. The name/NID is in the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c); the ABI follows the existing face bridge and public `FT_Int(FT_Face, FT_UInt)` signature. Behavior comes directly from bundled [FreeType 2.13.3 ftgasp.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftgasp.c) and its [gasp table loader](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/sfnt/ttload.c). Console version/result compatibility remains unverified and is recorded in debt. No title unblock or performance improvement is claimed. Extend the existing font fixture with an optional, correctly indexed `gasp` table and exercise the query through the existing `guest_freetype` test. All eight synthetic fonts are checked against native FreeType and independently specified range results; rendering choices made from the returned flags also produce matching glyph bitmaps. There is no new CMake target or third-party dependency. The former merge-order predecessor #9309 is merged; the branch includes its character-size implementation and current transform and naming tests. ### Tested Rebased on upstream main `0db47b263d1019043f7d28fad4e7ee0a1ea5ec6a`; tested head `ac06b871a9299345e55f64f7fa6e632bf02262ef`. Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, `BUILD_TESTING=ON`, bundled dependencies. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER. Font rendering uses the CPU. - `cmake --build ../build --target relinker libs guest_freetype_tests guest_freetype_charmap_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_request_size_tests patched_libraries_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests --parallel 8`: production relinker, all patched libraries and selected runtime fixtures built successfully with submitted sources only. - `ctest --test-dir ../build -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error`: **12/12 passed, no skips, 1.80 s total; 367 patched libraries loaded, 0 failed**. - Gasp regression: 8 synthetic fonts, 524,304 range/extreme-size queries, null-face checks and 14 rendered glyph comparisons against native FreeType. Current upstream coverage includes 1,555 outline-orientation cases, 2 rendered glyph comparisons, character-size, size requests, naming and font lifetimes. - `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; 1,209 test executables, none built and unregistered. - `python tools/pr_overlap.py --branch codex/pr9530-rebase-20261023b --repo boykopovar/AnyPS5 --jobs 8`: reviewed. The old #9530 head is the expected self-match; #9453 adds a throwing same-NID stub in the separate `libSceFreeTypeOl` library. #9560 and #9574 add independent functions at shared test/include insertions; their merge order is separate from this implementation. Remaining conflicting shared debt entries describe independent bitmap, bounding-box, PostScript or platform-export work. #9545 and #9550 add separate CID/size functions and test helpers. No other open PR implements this guest query in `libSceFreeType`. The include conflict preserves main's `<algorithm>`/`<bit>` imports for outline orientation alongside `FT_GASP_H`. `git range-diff` confirms unchanged query and regression behavior. The original missing-feature baseline cannot link this regression because it lacks `FT_Get_Gasp_nid_postfix`. Console compatibility and title-level impact remain unverified. <!-- 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 00:31:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:31:09Z.

Review: APPROVED


The wrapper delegates to the bundled FreeType 2.13.3 FT_Get_Gasp using the mapped native face; I checked the source's null/non-SFNT, range-boundary, no-table and version-0 masking behavior against the regression's expectations. The fixture computes the SFNT search parameters from its table count, and the tests compare both the guest adapter and native FreeType across the documented range and rendering cases. The declared #9309 dependency is accurate: a direct merge conflicts only in the shared debt file. Current eligibility, conventions, intake, labels and report checks pass; product/relinker jobs are skipped. The extensive build/test evidence in the PR is author-reported; I did not run a local build or tests.'

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607872156 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530#pullrequestreview-5607872156). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T00:31:09Z. **Review:** APPROVED --- The wrapper delegates to the bundled FreeType 2.13.3 `FT_Get_Gasp` using the mapped native face; I checked the source's null/non-SFNT, range-boundary, no-table and version-0 masking behavior against the regression's expectations. The fixture computes the SFNT search parameters from its table count, and the tests compare both the guest adapter and native FreeType across the documented range and rendering cases. The declared #9309 dependency is accurate: a direct merge conflicts only in the shared debt file. Current eligibility, conventions, intake, labels and report checks pass; product/relinker jobs are skipped. The extensive build/test evidence in the PR is author-reported; I did not run a local build or tests.'
Ondra97 commented 2026-10-22 00:49:56 +00:00 (Migrated from github.com)

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


I am preparing FT_Outline_Get_Orientation as an independent follow-up. It shares include/debt insertion points with this PR, but no exported function implementation. I will list #9530 as the merge-order dependency (which already orders #9309 first), then rebase those insertions after this PR merges. No changes to this branch are needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6329951681 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530#issuecomment-6329951681). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T00:49:56Z. --- I am preparing `FT_Outline_Get_Orientation` as an independent follow-up. It shares include/debt insertion points with this PR, but no exported function implementation. I will list #9530 as the merge-order dependency (which already orders #9309 first), then rebase those insertions after this PR merges. No changes to this branch are needed.
MarcZX10 commented 2026-10-22 02:01:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:01:03Z.

Review: APPROVED


Rechecked the unchanged FT_Get_Gasp adapter against bundled FreeType 2.13.3, including null/no-table results, range boundaries, version-0 masking and preservation of guest slot state. The regression and reported rendered-glyph comparisons cover the public behavior; #9309 remains open as the declared debt insertion predecessor. Eligibility, conventions, intake, labels and report checks pass; platform/product jobs were skipped. I did not rerun local tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608417051 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530#pullrequestreview-5608417051). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:01:03Z. **Review:** APPROVED --- Rechecked the unchanged `FT_Get_Gasp` adapter against bundled FreeType 2.13.3, including null/no-table results, range boundaries, version-0 masking and preservation of guest slot state. The regression and reported rendered-glyph comparisons cover the public behavior; #9309 remains open as the declared debt insertion predecessor. Eligibility, conventions, intake, labels and report checks pass; platform/product jobs were skipped. I did not rerun local tests.
Ondra97 commented 2026-10-22 02:20:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T02:20:27Z.


I opened #9560, which adds FT_Outline_Decompose. I declared #9530 for merge order because the regression calls share an insertion, and its #9309 dependency adds separate helpers at the decomposition test-helper insertion. Retain both tests and their helpers. The implementations are independent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331121594 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530#issuecomment-6331121594). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T02:20:27Z. --- I opened #9560, which adds FT_Outline_Decompose. I declared #9530 for merge order because the regression calls share an insertion, and its #9309 dependency adds separate helpers at the decomposition test-helper insertion. Retain both tests and their helpers. The implementations are independent.
fogydes commented 2026-10-22 08:21:49 +00:00 (Migrated from github.com)

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


Reviewed; no issues found. The wrapper keeps the sibling pattern (FaceOf + null host through to FT_Get_Gasp, which answers FT_GASP_NO_TABLE for a null face — the test pins that for both null ppems). The test's oracle is the host FreeType itself: 524304 guest/native query pairs over the full ppem range plus malformed and version-0 gasp tables, and the version-zero flags & 3 expectation matches the freetype source, so nothing in the answer space is invented. The fixture's font-table builder computes the table-directory searchRange/entrySelector correctly for the now-eight-table font (largest power of two at or below the entry count); the old hard-coded 4-table values stay byte-identical for fonts of that size, so existing tests are unaffected. Debt entry added with the exact freetype source link. Runtime stays inside the 30 s budget.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336199434 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530#issuecomment-6336199434). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:21:49Z. --- Reviewed; no issues found. The wrapper keeps the sibling pattern (`FaceOf` + null host through to `FT_Get_Gasp`, which answers `FT_GASP_NO_TABLE` for a null face — the test pins that for both null ppems). The test's oracle is the host FreeType itself: 524304 guest/native query pairs over the full ppem range plus malformed and version-0 gasp tables, and the version-zero `flags & 3` expectation matches the freetype source, so nothing in the answer space is invented. The fixture's font-table builder computes the table-directory `searchRange`/`entrySelector` correctly for the now-eight-table font (largest power of two at or below the entry count); the old hard-coded 4-table values stay byte-identical for fonts of that size, so existing tests are unaffected. Debt entry added with the exact freetype source link. Runtime stays inside the 30 s budget.
MarcZX10 commented 2026-10-22 11:37:52 +00:00 (Migrated from github.com)

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


I rechecked current head c6c78bf28c2a: it merges cleanly with today’s main, and current diff-check/conventions pass. The reported 524,304 query comparisons, 14 rendered-glyph checks and 3/3 FreeType CTest selection are strong author-reported evidence. This branch is 2 ahead / 119 behind current main (merge base a6dcea927); please refresh it and rerun the focused FreeType tests/checks. Keep the declared #9309 debt-file order; #9538 also uses this PR as its declared predecessor for a shared test insertion.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339800362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9530#issuecomment-6339800362). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:37:52Z. --- I rechecked current head `c6c78bf28c2a`: it merges cleanly with today’s `main`, and current diff-check/conventions pass. The reported 524,304 query comparisons, 14 rendered-glyph checks and 3/3 FreeType CTest selection are strong author-reported evidence. This branch is 2 ahead / 119 behind current `main` (merge base `a6dcea927`); please refresh it and rerun the focused FreeType tests/checks. Keep the declared #9309 debt-file order; #9538 also uses this PR as its declared predecessor for a shared test insertion.
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!9530
No description provided.