feat(libSceFreeType): expose raw SFNT table access #9420
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9420"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-21T21:21:22Z.
What
Add
FT_Sfnt_Table_InfoandFT_Load_Sfnt_Tableto the guest FreeType bridge. Callers can enumerate the SFNT directory, query table/file lengths, and read raw table or whole-font bytes. The adapter preserves LP64 tags, lengths and offsets, including high-bit table tags, aliased outputs and partially written buffers on short-read errors.The length field is written only for zero-length queries, so an aliased destination is not overwritten after reading. Each successful
FT_Sfnt_Table_Infometadata output and the zero-length table query now openGuestArena::HostWritefor the exact eight-byte output before storing; separate scopes preserve native tag-then-length ordering when the pointers alias. Data reads continue to holdHostWriteover the possible destination writes. A requested length of zero queries metadata without touching the data buffer. On 32-bit-longhosts, memory-backed tagged reads recover the absolute table position with a native one-byte probe, restore the original cursor, then read at the validated absolute file position. This prevents 32-bit offset wrap without rejecting positions above signed 32 bits. Tagged reads through native stream callbacks throw on those hosts because probing could change callback state; the limitation is in debt.The SFNT declarations live in the public
include/Api.hppreached bylibSceFreeType.hpp. The regression test includes that umbrella and uses its typedGuestLibrary*API without local export declarations. Supported wide-stream reads and error/output checks remain covered.Names/NIDs
oiRP-fp3SN4and09vKaCuNyqIare in the PS5 3.20 inventory. Signatures, errors and stream behavior follow bundled FreeType 2.13.3: public entry points, table access and stream reads. Console equivalence remains unverified. No matching implementation was found in main. The current open-PR overlap scan reports only conflicted #9848; manual inspection of its shared CMake and debt changes confirms that it addresses macOS symbol visibility and separate import tests, without duplicating SFNT access.Tested
Current revision: base
af49a0788576ca8878a5bcd8a8e6eac01316b81f, headb58440f8b1980ba2fd2befa81e41cb126983123c. Windows 11 Pro x64, WinLibs MinGW-w64 GCC 15.2.0 r7, Release,BUILD_TESTING=ON; Ryzen 9 7900X, 32 GB RAM, RTX 4070 Ti SUPER (CPU tests).cmake --build ../build --parallel 10: complete default all-target build passed, without a source overlay. The build uses the repository-pinned dependencies built from source.ctest --test-dir ../build -R '^public_headers($|_compile_)' -j 4 --output-on-failure: 65/65 passed, no skips, 55.22 s. The audit verifies 368 library umbrellas and 12,177 exports, and all registered header compilation batches passed.5839f54a7cb4dec9a0d04cbbe498cacd46733bbafailed on the four duplicate declarations and two SFNT declarations found only in the test. The corrected revision passes the same audit and includes the library umbrella in the SFNT runtime test.ctest --test-dir ../build -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V: 19/19 passed, no skips, 1.24 s. All 368 patched libraries loaded, with 0 failures. The SFNT fixture retains 44 directory comparisons and 479 read comparisons, memory-backed tagged reads, whole-file callback reads above 2 GiB, canaries, error/output checks, alias handling and watched metadata cases. The test no longer requires tagged callback reads to throw on hosts with a 32-bitlong; the production limitation and debt remain unchanged.python tools/check_compile.py --build ../build core/libs/prx/libSceFreeType/src/Sfnt.cpp core/libs/tests/GuestFreeTypeSfnt.cpp: both translation units passed.python tools/check_test_registration.py ../build: 1,328 test executables, none built and unregistered.python tools/check_conventions.py --base origin/mainandgit diff --checkpassed.python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/pr9420-review-20261025: the sole unresolved automated comparison is conflicted #9848, sharing CMake and debt files. Manual comparison confirms independent macOS visibility/import-test changes, with no duplicate SFNT implementation or required merge order.The full CTest suite was not run. Linux, macOS, games and PS5 hardware were not tested here.
Earlier controls for the original SFNT implementation: at
0c6a5bd5938fde7bbc0bf720927c4584bd3e4700, omittingsrc/Sfnt.cppwhile keeping the expanded test registered failed to link the missing guest functions. An earlier compiled mutation that wrote the requested length back after reading corrupted an overlapping destination and failed the regression; restoring the adapter passed. These controls were not repeated for this declaration/test cleanup.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:59:12Z.
Code review location:
core/libs/prx/libSceFreeType/src/Sfnt.cpp; line 37These guest output stores bypass
GuestArena::HostWrite, which is used for the data buffer below. On the Apple write-watch path,GuestWriteWatch::BeginHostWriteopens protected guest pages and records the host write; a direct store totag/lengthin a watched guest page can instead fault or miss that write tracking. The zero-length query also writes*lengthdirectly at line 51. Please guard the metadata output ranges withHostWrite(handling aliased outputs) and add a regression that places the outputs in a write-watched GuestArena region; the current stack-array fixtures do not exercise this case.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:59:12Z.
Review: DISMISSED
The fixtures exercise a broad set of FreeType edge cases, but the current branch is 417 commits behind current
main524398151f1e(merge base0c6a5bd5938f). The repository requires PRs to stay current withmain; please rebase and rerun the focused font tests, conventions check and overlap scan on the rebased result. The current hosted checks are policy checks only; the Windows build/test results in the description are author-run on the old base. I did not run local tests for this head because there is no matching configured build here.