feat(freetype): implement font table validation #10897

Open
HSNADM wants to merge 11 commits from upstream-pr/10897 into main
HSNADM commented 2026-10-25 08:15:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HSNADM on 2026-10-25T08:15:25Z.


What

Add FT_OpenType_Validate/Free, FT_TrueTypeGX_Validate/Free and FT_ClassicKern_Validate/Free through the existing guest face adapter. Enable the bundled FreeType gxvalid and otvalid modules so validation checks the tables and returns allocated table copies that the matching Free calls release.

The six exports are listed in the PS5 3.20 libfreetype symbol table. Signatures and behavior follow bundled FreeType 2.13.3; console equivalence remains unverified and is recorded in technical debt. No game compatibility is claimed.

The four identified validator helpers in libSceFreeTypeOt retain their explicit inventory NIDs and throwing provider-specific placeholder behavior, with one declaration each in the provider umbrella.

Tested

Latest revision 53011a03a74955e229f6f6350818c71e0f72cd5d, merged with main at 1f2c1da1fb:

  • Resolved the libSceFreeTypeOt umbrella and debt-file conflicts by preserving all upstream public-header includes and entries, retaining the four identified validator declarations, and recounting unidentified exports from the merged source.
  • Windows GCC 15.2, C++20, -Wall -Wextra -Werror: repeated umbrella inclusion, the four actual provider definitions with -Wmissing-declarations, and the complete provider translation unit with its umbrella included all pass. Each of the four names has exactly one public-header declaration. Their no-argument int placeholder signatures are preserved.
  • Direct public-header audit passes: 398 libraries, 26,112 exports. That audit skips _nid_no_patch helpers, so the explicit count and compiler checks above cover these four functions.
  • Latest upstream conventions checker and git diff --check origin/main...HEAD pass. Hosted conventions and labels checks pass on this revision.

Earlier runtime evidence, before subsequent main merges:

  • Windows x86-64, GCC 15.2, original implementation f8a3347: full library build and NID patching; 368 patched libraries loaded; all 13 focused FreeType/loader tests passed. Validator fixtures cover valid, malformed and missing OpenType, GX and classic kern tables, flags, null inputs, output lengths and matching deallocation, compared with native FreeType. System builds without validator modules check Unimplemented_Feature.
  • Linux exact-head run on 689971fa6c: Ubuntu 24.04, GCC 14, bundled recursive submodules; full libs target and guest_freetype_validation_tests built, and guest_freetype_validation passed. Source/toolchain and configure/build/CTest logs are in the linux-freetype-evidence artifact. This does not claim the complete CTest suite passed.
  • Independent reviewer run reports 31 focused tests passing three times on the PR merged into main at 427dd36164; removing the validator module configuration makes the validation test fail in all three control runs.

The latest main-merge revision has compiler/header validation, not a new full runtime build. No PS5 hardware or title testing; no game compatibility claim. Console signatures and behavior remain unverified 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:5003026264 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10897). Originally posted by [HSNADM](https://github.com/HSNADM) on 2026-10-25T08:15:25Z. --- ### What Add FT_OpenType_Validate/Free, FT_TrueTypeGX_Validate/Free and FT_ClassicKern_Validate/Free through the existing guest face adapter. Enable the bundled FreeType gxvalid and otvalid modules so validation checks the tables and returns allocated table copies that the matching Free calls release. The six exports are listed in the PS5 3.20 libfreetype symbol table. Signatures and behavior follow bundled FreeType 2.13.3; console equivalence remains unverified and is recorded in technical debt. No game compatibility is claimed. The four identified validator helpers in libSceFreeTypeOt retain their explicit inventory NIDs and throwing provider-specific placeholder behavior, with one declaration each in the provider umbrella. ### Tested Latest revision `53011a03a74955e229f6f6350818c71e0f72cd5d`, merged with `main` at `1f2c1da1fb`: - Resolved the libSceFreeTypeOt umbrella and debt-file conflicts by preserving all upstream public-header includes and entries, retaining the four identified validator declarations, and recounting unidentified exports from the merged source. - Windows GCC 15.2, C++20, `-Wall -Wextra -Werror`: repeated umbrella inclusion, the four actual provider definitions with `-Wmissing-declarations`, and the complete provider translation unit with its umbrella included all pass. Each of the four names has exactly one public-header declaration. Their no-argument `int` placeholder signatures are preserved. - Direct public-header audit passes: 398 libraries, 26,112 exports. That audit skips `_nid_no_patch` helpers, so the explicit count and compiler checks above cover these four functions. - Latest upstream conventions checker and `git diff --check origin/main...HEAD` pass. Hosted conventions and labels checks pass on this revision. Earlier runtime evidence, before subsequent main merges: - Windows x86-64, GCC 15.2, original implementation `f8a3347`: full library build and NID patching; 368 patched libraries loaded; all 13 focused FreeType/loader tests passed. Validator fixtures cover valid, malformed and missing OpenType, GX and classic kern tables, flags, null inputs, output lengths and matching deallocation, compared with native FreeType. System builds without validator modules check Unimplemented_Feature. - [Linux exact-head run on `689971fa6c`](https://github.com/HSNADM/AnyPS5/actions/runs/40289242129): Ubuntu 24.04, GCC 14, bundled recursive submodules; full `libs` target and `guest_freetype_validation_tests` built, and `guest_freetype_validation` passed. Source/toolchain and configure/build/CTest logs are in the linux-freetype-evidence artifact. This does not claim the complete CTest suite passed. - [Independent reviewer run](https://github.com/boykopovar/AnyPS5/pull/10897#issuecomment-6421713595) reports 31 focused tests passing three times on the PR merged into main at `427dd36164`; removing the validator module configuration makes the validation test fail in all three control runs. The latest main-merge revision has compiler/header validation, not a new full runtime build. No PS5 hardware or title testing; no game compatibility claim. Console signatures and behavior remain unverified 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 10:19:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T10:19:46Z.

Review: APPROVED


I reviewed the exact head f8a3347ae8c321ff72b8976ec18ffe8c265a98be, including the six wrappers, bundled FreeType module registration, error/output ownership paths, regression cases, and debt entry. The wrappers delegate to the corresponding FreeType validators and free functions using the host face associated with the guest face. The bundled build includes gxvalid and otvalid and registers both; the system-dependency path explicitly tests the absent-module behavior. The exact-head diff check and python3 tools/check_conventions.py --base upstream/main --head upstream/pr-10897 pass. The PR reports a native Windows guest_freetype_validation run; no Linux runtime was reported or independently run here, and the hosted checks shown are policy checks rather than runtime builds. The remaining console signatures and behavior are appropriately recorded as unverified in the debt entry. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5642714996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10897#pullrequestreview-5642714996). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T10:19:46Z. **Review:** APPROVED --- I reviewed the exact head `f8a3347ae8c321ff72b8976ec18ffe8c265a98be`, including the six wrappers, bundled FreeType module registration, error/output ownership paths, regression cases, and debt entry. The wrappers delegate to the corresponding FreeType validators and free functions using the host face associated with the guest face. The bundled build includes `gxvalid` and `otvalid` and registers both; the system-dependency path explicitly tests the absent-module behavior. The exact-head diff check and `python3 tools/check_conventions.py --base upstream/main --head upstream/pr-10897` pass. The PR reports a native Windows `guest_freetype_validation` run; no Linux runtime was reported or independently run here, and the hosted checks shown are policy checks rather than runtime builds. The remaining console signatures and behavior are appropriately recorded as unverified in the debt entry. I found no blocking issue.
CnRJay commented 2026-11-01 20:01:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:01:22Z.

Review: COMMENTED


Correction (2026-11-01): this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows Unblocks: none; a title is only required when the PR fixes a title. The technical points below are unaffected.

No title evidence, and it widens the bundled FreeType build. The template says Unblocks: none, and the body says "No PS5 hardware or title testing; no game compatibility claim". There is no title ID and no log line showing a title reaching FT_OpenType_Validate, FT_TrueTypeGX_Validate or FT_ClassicKern_Validate on main. That is the shape that gets closed.

It also compiles gxvalid.c and otvalid.c into the bundled freetype target and generates a replacement ftmodule.h via FT_CONFIG_MODULES_H (file(GENERATE ...) in the CMake change), which changes the module list of the bundled library, not just these six exports. Please show a title that needs them before taking on that build surface.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729961806 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10897#pullrequestreview-5729961806). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T20:01:22Z. **Review:** COMMENTED --- **Correction (2026-11-01):** this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows `Unblocks: none`; a title is only required when the PR fixes a title. The technical points below are unaffected. **No title evidence, and it widens the bundled FreeType build.** The template says `Unblocks: none`, and the body says "No PS5 hardware or title testing; no game compatibility claim". There is no title ID and no log line showing a title reaching `FT_OpenType_Validate`, `FT_TrueTypeGX_Validate` or `FT_ClassicKern_Validate` on main. That is the shape that gets closed. It also compiles `gxvalid.c` and `otvalid.c` into the bundled `freetype` target and generates a replacement `ftmodule.h` via `FT_CONFIG_MODULES_H` (`file(GENERATE ...)` in the CMake change), which changes the module list of the bundled library, not just these six exports. Please show a title that needs them before taking on that build surface.
MarcZX10 commented 2026-11-17 09:02:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T09:02:22Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head: 254b59f30085d6961ee15ea57518cbdc945056f4, base main.
  • Read the description, commit list, manifest and the full diff of the 11 changed files.
  • Searched the head with the reader (repo_read.py search, repo_read.py cat) for the face helper, the GX header macro and the NotImplemented_nid_no_patch uses.
  • No build and no test run in this review.

Results

Check Result Note
Diff of the 11 changed files passed No blocking defect in the hunks
Four validator names and declarations passed One declaration each in libSceFreeTypeOt.hpp
Build and CTest on this head not run No build here
Author-reported runs on 53011a03 not run Taken from the description, not repeated

Findings

Blocking

  • None.

Non-blocking

  • docs/dev/debt/libSceFreeTypeOt.md:3: the list reads FT_Vector_Polarize FT_Vector_From_Polar, FT_OpenType_Validate/Free. The word "and" is missing before FT_Vector_From_Polar, as it was in the previous line.
  • core/libs/prx/libSceFreeType/CMakeLists.txt:55: the new if(BUILD_TESTING) block sits between target_link_libraries and the remaining target_sources calls. Moving it below them would keep the file easier to scan.

Sources

  • The description links FreeType 2.13.3 and the PS5 3.20 inventories. I did not open them, so the behavior claims are not checked here.

Not verified

  • The FreeType submodule is not readable through the reader, so I could not check how FT_OpenType_Free, FT_TrueTypeGX_Free and FT_ClassicKern_Free behave when the owner face is null. Validation.cpp:18 passes a null host in that case. The test Invalid calls them with a null face; the author reports it passes.
  • The description's runs were on 53011a03. The head is 254b59f3, which the author describes as having compiler and header validation only.
  • Whether the generated freetype-validation-modules.h (root CMakeLists.txt, lines 690–696) includes ftmodule.h correctly in a bundled build. Not verified without the submodule.
  • Console signatures, validation results and game behaviour remain unverified, as the debt files say.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5935583183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10897#pullrequestreview-5935583183). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T09:02:22Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. **What I ran** - Head: `254b59f30085d6961ee15ea57518cbdc945056f4`, base `main`. - Read the description, commit list, manifest and the full diff of the 11 changed files. - Searched the head with the reader (`repo_read.py search`, `repo_read.py cat`) for the face helper, the GX header macro and the `NotImplemented_nid_no_patch` uses. - No build and no test run in this review. **Results** | Check | Result | Note | |---|---|---| | Diff of the 11 changed files | passed | No blocking defect in the hunks | | Four validator names and declarations | passed | One declaration each in `libSceFreeTypeOt.hpp` | | Build and CTest on this head | not run | No build here | | Author-reported runs on `53011a03` | not run | Taken from the description, not repeated | **Findings** **Blocking** - None. **Non-blocking** - `docs/dev/debt/libSceFreeTypeOt.md:3`: the list reads `FT_Vector_Polarize FT_Vector_From_Polar, FT_OpenType_Validate/Free`. The word "and" is missing before `FT_Vector_From_Polar`, as it was in the previous line. - `core/libs/prx/libSceFreeType/CMakeLists.txt:55`: the new `if(BUILD_TESTING)` block sits between `target_link_libraries` and the remaining `target_sources` calls. Moving it below them would keep the file easier to scan. **Sources** - The description links FreeType 2.13.3 and the PS5 3.20 inventories. I did not open them, so the behavior claims are not checked here. **Not verified** - The FreeType submodule is not readable through the reader, so I could not check how `FT_OpenType_Free`, `FT_TrueTypeGX_Free` and `FT_ClassicKern_Free` behave when the owner face is null. `Validation.cpp:18` passes a null host in that case. The test `Invalid` calls them with a null face; the author reports it passes. - The description's runs were on `53011a03`. The head is `254b59f3`, which the author describes as having compiler and header validation only. - Whether the generated `freetype-validation-modules.h` (root `CMakeLists.txt`, lines 690–696) includes `ftmodule.h` correctly in a bundled build. Not verified without the submodule. - Console signatures, validation results and game behaviour remain unverified, as the debt files say. **To get this to a good state** Nothing is required.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/10897:upstream-pr/10897'
git switch 'upstream-pr/10897'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/10897'
git switch 'upstream-pr/10897'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/10897'
git switch 'upstream-pr/10897'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/10897'
git switch 'main'
git merge --squash 'upstream-pr/10897'
git switch 'main'
git merge --ff-only 'upstream-pr/10897'
git switch 'main'
git merge 'upstream-pr/10897'
git push origin 'main'
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!10897
No description provided.