feat(libSceFreeType): implement FT_Outline_Copy #9519

Merged
Ondra97 merged 4 commits from upstream-pr/9519 into main 2026-10-25 02:24:08 +00:00
Ondra97 commented 2026-10-22 00:08:55 +00:00 (Migrated from github.com)

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


What

Add the missing guest FT_Outline_Copy export (Bhm8Injl0KA) to the existing FreeType bridge. Copy points, tags and contours into the caller's existing storage, preserve the destination ownership flag and descriptor pointers, and retain full 64-bit guest coordinates on Windows. Null outlines and mismatched counts return the bundled FreeType errors; self-copy leaves the outline unchanged.

The name/NID matches the pinned PS5 3.20 inventory. The contract follows bundled FreeType 2.13.3 ftoutln.c and the bridge's existing LP64 outline layout. Console version/error equivalence remains unverified and is recorded in library debt. No title unblock or performance improvement is claimed.

Extend the existing guest_freetype test with native comparisons, buffer guards, ownership and input preservation, invalid counts, null/self-copy, maximum unsigned counts, full-width coordinate payloads and copied-outline rendering. No CMake change is needed. Merge after #9465 because both PRs insert a debt entry at the same location. Their implementations and tests are independent; #9465 is a merge-order dependency only.

Tested

Rebased on upstream main 941ace5f342c24c84b0712b8db0a75e0232bc44d; tested PR head e3536381dc130c54159b94613b532e5d2e5fd7c7. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, BUILD_TESTING=ON, pinned bundled dependencies. These FreeType/font tests use the CPU.

  • cmake --build <build> --target relinker libs patched_libraries_tests guest_freetype_tests guest_freetype_bitmap_tests guest_freetype_request_size_tests guest_freetype_outline_tests guest_freetype_outline_mutations_tests guest_freetype_charmap_tests guest_freetype_charmap_info_tests guest_freetype_face_info_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_list_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 fixtures built successfully without a code overlay.
  • ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error: 18/18 passed, zero skips; 368 patched libraries loaded, none failed. guest_freetype exercised 178 outline-copy cases, null/count validation, self-copy and three rendered copies with native-matching bitmaps.
  • ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 8 --output-on-failure --no-tests=error: 65/65 passed, zero skips. FT_Outline_Copy now has its sole export declaration in public Api.hpp; the integrated test uses that declaration and the public GuestLibrary* type instead of local prototypes.
  • objdump -p <build>/core/libs/libs/libSceFreeType.prx confirms NID Bhm8Injl0KA in the packaged library. The implementation body is byte-identical to the old hosted PR. The old tip was a main merge commit; I replayed only its four original feature/test commits, whose pre-merge patch-id matched the hosted feature diff, while preserving current-main code and tests.
  • 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. python tools/pr_overlap.py --branch codex/pr9519-rebase-20261025 --repo boykopovar/AnyPS5 --jobs 12 completed. #9465 remains the declared open debt-entry merge-order dependency; #9560 is a separate outline-decomposition export.

The missing-feature baseline has no FT_Outline_Copy_nid_postfix, so this regression cannot link there; no current-main runtime negative control is claimed. A complete CTest suite, console probe and title run were not performed on this rebased head. Console FreeType version/error equivalence remains unverified as recorded 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: #9465
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4960052166 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9519). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T00:08:55Z. --- ### What Add the missing guest `FT_Outline_Copy` export (`Bhm8Injl0KA`) to the existing FreeType bridge. Copy points, tags and contours into the caller's existing storage, preserve the destination ownership flag and descriptor pointers, and retain full 64-bit guest coordinates on Windows. Null outlines and mismatched counts return the bundled FreeType errors; self-copy leaves the outline unchanged. The name/NID matches the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). The contract follows bundled [FreeType 2.13.3 ftoutln.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftoutln.c) and the bridge's existing LP64 outline layout. Console version/error equivalence remains unverified and is recorded in library debt. No title unblock or performance improvement is claimed. Extend the existing `guest_freetype` test with native comparisons, buffer guards, ownership and input preservation, invalid counts, null/self-copy, maximum unsigned counts, full-width coordinate payloads and copied-outline rendering. No CMake change is needed. Merge after #9465 because both PRs insert a debt entry at the same location. Their implementations and tests are independent; #9465 is a merge-order dependency only. ### Tested Rebased on upstream `main` `941ace5f342c24c84b0712b8db0a75e0232bc44d`; tested PR head `e3536381dc130c54159b94613b532e5d2e5fd7c7`. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, `BUILD_TESTING=ON`, pinned bundled dependencies. These FreeType/font tests use the CPU. - `cmake --build <build> --target relinker libs patched_libraries_tests guest_freetype_tests guest_freetype_bitmap_tests guest_freetype_request_size_tests guest_freetype_outline_tests guest_freetype_outline_mutations_tests guest_freetype_charmap_tests guest_freetype_charmap_info_tests guest_freetype_face_info_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_list_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 fixtures built successfully without a code overlay. - `ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error`: 18/18 passed, zero skips; 368 patched libraries loaded, none failed. `guest_freetype` exercised 178 outline-copy cases, null/count validation, self-copy and three rendered copies with native-matching bitmaps. - `ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 8 --output-on-failure --no-tests=error`: 65/65 passed, zero skips. `FT_Outline_Copy` now has its sole export declaration in public `Api.hpp`; the integrated test uses that declaration and the public `GuestLibrary*` type instead of local prototypes. - `objdump -p <build>/core/libs/libs/libSceFreeType.prx` confirms NID `Bhm8Injl0KA` in the packaged library. The implementation body is byte-identical to the old hosted PR. The old tip was a main merge commit; I replayed only its four original feature/test commits, whose pre-merge patch-id matched the hosted feature diff, while preserving current-main code and tests. - `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. `python tools/pr_overlap.py --branch codex/pr9519-rebase-20261025 --repo boykopovar/AnyPS5 --jobs 12` completed. #9465 remains the declared open debt-entry merge-order dependency; #9560 is a separate outline-decomposition export. The missing-feature baseline has no `FT_Outline_Copy_nid_postfix`, so this regression cannot link there; no current-main runtime negative control is claimed. A complete CTest suite, console probe and title run were not performed on this rebased head. Console FreeType version/error equivalence remains unverified as recorded 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: #9465 <!-- #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:11:30 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed the implementation against the bundled FreeType 2.13.3 FT_Outline_Copy contract. It preserves the destination ownership bit, copies only the point/tag/contour arrays for matching counts, returns the same null/count errors and leaves self-copy unchanged; memmove also handles aliasing safely. The guest outline fields are unsigned 16-bit counts and 64-bit coordinates, and the implementation copies those coordinates without narrowing. I independently recomputed FT_Outline_Copy’s NID as Bhm8Injl0KA. The native-reference tests cover count/flag combinations, guard storage, full-width values, invalid/self copies and rendered output. The PR reports focused 3/3 CTest coverage and a full integration build with its stated temporary test-only overlay; current eligibility/intake/conventions/labels/report checks pass. #9465 is correctly declared as the debt-entry merge-order dependency. I did not rerun tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607749557 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9519#pullrequestreview-5607749557). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T00:11:30Z. **Review:** APPROVED --- Reviewed the implementation against the bundled FreeType 2.13.3 `FT_Outline_Copy` contract. It preserves the destination ownership bit, copies only the point/tag/contour arrays for matching counts, returns the same null/count errors and leaves self-copy unchanged; `memmove` also handles aliasing safely. The guest outline fields are unsigned 16-bit counts and 64-bit coordinates, and the implementation copies those coordinates without narrowing. I independently recomputed `FT_Outline_Copy`’s NID as `Bhm8Injl0KA`. The native-reference tests cover count/flag combinations, guard storage, full-width values, invalid/self copies and rendered output. The PR reports focused 3/3 CTest coverage and a full integration build with its stated temporary test-only overlay; current eligibility/intake/conventions/labels/report checks pass. #9465 is correctly declared as the debt-entry merge-order dependency. I did not rerun tests locally.
MarcZX10 commented 2026-10-22 02:04:36 +00:00 (Migrated from github.com)

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

Review: APPROVED


Rechecked the current head and dependency after the queue refresh. The FT_Outline_Copy behavior remains consistent with bundled FreeType 2.13.3, the #9465 debt-entry order is explicit, and the author’s focused 3/3 test report and overlay-qualified full-build details remain unchanged. Eligibility, conventions, intake, labels and report checks pass; hosted product/relinker jobs are skipped. I did not rerun tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608437314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9519#pullrequestreview-5608437314). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:04:36Z. **Review:** APPROVED --- Rechecked the current head and dependency after the queue refresh. The `FT_Outline_Copy` behavior remains consistent with bundled FreeType 2.13.3, the #9465 debt-entry order is explicit, and the author’s focused 3/3 test report and overlay-qualified full-build details remain unchanged. Eligibility, conventions, intake, labels and report checks pass; hosted product/relinker jobs are skipped. I did not rerun tests locally.
Ondra97 commented 2026-10-22 02:20:26 +00:00 (Migrated from github.com)

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


I opened #9560, which adds FT_Outline_Decompose. I declared #9519 for merge order because the patches add independent debt entries at the same insertion; its #9465 chain also adds distinct guest types at the callback-table insertion. Retain both sets of entries/types. The implementations are independent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331121311 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9519#issuecomment-6331121311). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T02:20:26Z. --- I opened #9560, which adds FT_Outline_Decompose. I declared #9519 for merge order because the patches add independent debt entries at the same insertion; its #9465 chain also adds distinct guest types at the callback-table insertion. Retain both sets of entries/types. The implementations are independent.
fogydes commented 2026-10-22 08:41:14 +00:00 (Migrated from github.com)

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


Reviewed; verified against the pinned ftoutln.c copy contract. The error mapping is freetype's own: !source || !target → Invalid_Outline, count mismatch → Invalid_Argument, self-copy → Ok; the point/tags/contours copies follow the same element counts as FT_ARRAY_COPY, and the ownership-flag result (source->flags & ~OWNER) | (target->flags & OWNER) is algebraically the source's save-clear-OR sequence, so a caller-owner target never loses ownership. Operating on raw guest outline storage without going through the adapter face is correct here — this export has no host picture of the outline — and the rendering test exercises the one path where the two worlds meet: copy into the guest glyph outline, then FT_Render_Glyph_nid_postfix writes the guest outline back and renders, with the bitmaps matching native. Guard bytes around the points/tags/contours destinations prove the memmove extents are exact, and the wide-mode/guard/count-matrix cases plus native-comparison on the generated fonts cover the claim. Debt entry links the pinned source and marks the console-build compatibility unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336551444 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9519#issuecomment-6336551444). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:41:14Z. --- Reviewed; verified against the pinned `ftoutln.c` copy contract. The error mapping is freetype's own: `!source || !target` → `Invalid_Outline`, count mismatch → `Invalid_Argument`, self-copy → `Ok`; the point/tags/contours copies follow the same element counts as `FT_ARRAY_COPY`, and the ownership-flag result `(source->flags & ~OWNER) | (target->flags & OWNER)` is algebraically the source's save-clear-OR sequence, so a caller-owner target never loses ownership. Operating on raw guest outline storage without going through the adapter face is correct here — this export has no host picture of the outline — and the rendering test exercises the one path where the two worlds meet: copy into the guest glyph outline, then `FT_Render_Glyph_nid_postfix` writes the guest outline back and renders, with the bitmaps matching native. Guard bytes around the `points`/`tags`/`contours` destinations prove the `memmove` extents are exact, and the wide-mode/guard/count-matrix cases plus native-comparison on the generated fonts cover the claim. Debt entry links the pinned source and marks the console-build compatibility unverified.
MarcZX10 commented 2026-10-22 11:42:42 +00:00 (Migrated from github.com)

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


Current-head recheck: FT_Outline_Copy still follows the bundled FreeType contract; current diff-check/conventions pass and the branch merges cleanly with main. Your Windows report gives 178 copy cases, three rendered copies and 3/3 focused tests. The branch is now 4 ahead / 119 behind current main (base a6dcea927); please refresh it and rerun the focused FreeType tests/checks. Keep the declared #9465 debt-entry dependency; #9465 remains open.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339887805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9519#issuecomment-6339887805). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:42:42Z. --- Current-head recheck: `FT_Outline_Copy` still follows the bundled FreeType contract; current diff-check/conventions pass and the branch merges cleanly with `main`. Your Windows report gives 178 copy cases, three rendered copies and 3/3 focused tests. The branch is now 4 ahead / 119 behind current `main` (base `a6dcea927`); please refresh it and rerun the focused FreeType tests/checks. Keep the declared #9465 debt-entry dependency; #9465 remains open.
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!9519
No description provided.