feat(libfreetype): implement bitmap and outline glyph creation #16497

Merged
Noxy-HNR merged 16 commits from upstream-pr/16497 into main 2026-11-15 04:31:50 +00:00
Noxy-HNR commented 2026-11-06 22:40:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Noxy-HNR on 2026-11-06T22:40:27Z.


What

Implement FT_New_Glyph (sZq9oSwMGSs) in libfreetype for bitmap and outline glyphs. The typed LP64 export calls the bundled FreeType through the existing libSceFreeType glyph registry, so new objects also work with the existing glyph copy and destruction APIs. Argument and unsupported-format errors preserve the output, native allocation failures clear it, and refused guest output writes return FT_Err_Invalid_Argument before allocating.

The contract follows FreeType 2.15.0 ftglyph.c and the NID matches the public name database. Console ABI, version and allocation equivalence remain unverified. Accepted SVG/custom renderer classes remain unsupported and are recorded in the debt entry linked to Glyph.cpp; no title unblock is claimed.

The new native bridge and the existing bitmap-unregistration helper use C linkage so their _nid_no_patch suffix survives NID patching. A suffix inside an Itanium-mangled C++ name did not preserve the bridge export. Native clients rebuild against the updated declaration.

Merge ordering follows #16394 and #16399. After those land, merge main, move the link/test registrations from NewGlyph.cmake into the module CMakeLists added by #16394, preserve their independent implementations and rerun the affected tests. No unmerged code from those branches is included here. #9848 touches the same internal bridge declarations; preserve its other renames and this new helper when resolving that header. It does not implement FT_New_Glyph.

Tested

Current verification (2026-11-07), head 0721e96fe3, merging main eed8517b31: Windows 11 x86-64, WinLibs MinGW GCC 15.2, Ninja, Release, full project configuration with BUILD_TESTING=ON, -j 18. Built guest_legacy_freetype_new_glyph_fixture, guest_freetype_glyph_tests, guest_freetype_bitmap_init_tests and guest_freetype_bitmap_embolden_tests. Raw and NID new-glyph tests plus the glyph and bitmap regressions: 5/5 passed in each of three runs, none skipped. Final build confirmation exited 0. Current conventions, whitespace and public-header audit passed (407 libraries, 30,874 exports). The private patched fixture now separates configurations, regenerates its executable when the patcher changes and publishes patched outputs only after successful patching.

Manual full-build dispatch for this head returned HTTP 403 (repository admin rights required). Automatic checks are tracked separately; skipped jobs are not passes. No new Linux, macOS, console or title runtime result is claimed.

Historical verification follows; older results retain their original heads and do not establish validation of the current head.

Windows 11 x86-64, WinLibs GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON, -j 18. Current head includes main ee0d1204e3 through a regular merge.

  • Built the actual raw modules, the test-private NID-patched libfreetype/libSceFreeType/kernel/libc context, and its patched test executable. The focused targets avoid an unrelated all-library dependency.
  • guest_legacy_freetype_new_glyph, its NID variant, guest_freetype_glyph (including current main's glyph-box cases), guest_freetype_bitmap_init and guest_freetype_bitmap_embolden: 5/5 passed in each of 3 runs.
  • A separate source-built native FreeType oracle checks null/invalid arguments, unchanged error outputs, zeroed bitmap/outline records, independent objects, modified payload deep copies, copy/destruction interoperability, allocation failure/recovery and balanced native allocations. Real guest pages cover logical read-only/host-writable assertion controls and actual read-only output pages, with full-page preservation and writable recovery.
  • The same raw/NID test executable reaches the original FT_New_Glyph throwing body in unmodified main 6bf3a19b81; both variants fail at the explicit supported-behavior assertion, not module/symbol lookup.
  • Four temporary mutation controls each fail both variants by assertion: wrong format dispatch, missing allocation-failure clearing, wrong published advance and bypassed output refusal. Production source was restored and rebuilt; the restored tests pass.
  • Public-header audit, current conventions and whitespace checks pass. Author and committer identities were checked before push.

No standalone Linux, macOS, console or title run was performed for this final head. Earlier reviewer-supplied Linux/Windows combined-branch results are supplemental, not substituted for a final-head run.

Overlap preflight is recorded below before submission; shared declaration/debt/build edits require preserving each independent contribution. The checker fails closed on other unmergeable PRs, so those comparisons are reviewed manually rather than called a clean automatic pass.

Final pre-open pr_overlap.py run: 1,834 open PR heads, 75 shared-file candidates, base 1080643b1e. Exit 2 came from 27 unmergeable external comparisons; all were manually inspected from their merge bases: #5021, #7275, #8650, #9156, #9161, #9293, #9297, #9302, #9383, #10609, #10611, #10613, #10616, #10897, #12004, #12373, #12642, #13486, #14212, #14429, #14798, #15111, #15363, #15365, #15630, #15836, #15838. None adds FT_New_Glyph, its NID, the new helper or its test/fragment. The shared changes are independent test registrations, other FreeType APIs, debt entries or formatting. Explicit adjacent edits in #15408, #15439, #15442, #15444, #15447, #15468, #16394 and #16399 remain integration work; #9848 includes the same unregistration-linkage correction and broader bridge renames. Combined integration with those unmerged branches was not performed here.

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: #16394, #16399
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5195712248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16497). Originally posted by [Noxy-HNR](https://github.com/Noxy-HNR) on 2026-11-06T22:40:27Z. --- ### What Implement `FT_New_Glyph` (`sZq9oSwMGSs`) in libfreetype for bitmap and outline glyphs. The typed LP64 export calls the bundled FreeType through the existing libSceFreeType glyph registry, so new objects also work with the existing glyph copy and destruction APIs. Argument and unsupported-format errors preserve the output, native allocation failures clear it, and refused guest output writes return `FT_Err_Invalid_Argument` before allocating. The contract follows [FreeType 2.15.0 ftglyph.c](https://github.com/freetype/freetype/blob/37515cf56ba3349656049edbed89ffc6f6466f2d/src/base/ftglyph.c) and the NID matches the [public name database](https://github.com/zecoxao/sce_symbols/blob/2883963a0a514ba6e77407a08ef4730a65e88254/aerolib.csv). Console ABI, version and allocation equivalence remain unverified. Accepted SVG/custom renderer classes remain unsupported and are recorded in the debt entry linked to `Glyph.cpp`; no title unblock is claimed. The new native bridge and the existing bitmap-unregistration helper use C linkage so their `_nid_no_patch` suffix survives NID patching. A suffix inside an Itanium-mangled C++ name did not preserve the bridge export. Native clients rebuild against the updated declaration. Merge ordering follows #16394 and #16399. After those land, merge main, move the link/test registrations from `NewGlyph.cmake` into the module CMakeLists added by #16394, preserve their independent implementations and rerun the affected tests. No unmerged code from those branches is included here. #9848 touches the same internal bridge declarations; preserve its other renames and this new helper when resolving that header. It does not implement `FT_New_Glyph`. ### 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. --> Current verification (2026-11-07), head `0721e96fe3`, merging main `eed8517b31`: Windows 11 x86-64, WinLibs MinGW GCC 15.2, Ninja, Release, full project configuration with `BUILD_TESTING=ON`, `-j 18`. Built `guest_legacy_freetype_new_glyph_fixture`, `guest_freetype_glyph_tests`, `guest_freetype_bitmap_init_tests` and `guest_freetype_bitmap_embolden_tests`. Raw and NID new-glyph tests plus the glyph and bitmap regressions: **5/5 passed in each of three runs**, none skipped. Final build confirmation exited 0. Current conventions, whitespace and public-header audit passed (407 libraries, 30,874 exports). The private patched fixture now separates configurations, regenerates its executable when the patcher changes and publishes patched outputs only after successful patching. Manual full-build dispatch for this head returned HTTP 403 (repository admin rights required). Automatic checks are tracked separately; skipped jobs are not passes. No new Linux, macOS, console or title runtime result is claimed. Historical verification follows; older results retain their original heads and do not establish validation of the current head. Windows 11 x86-64, WinLibs GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`, `-j 18`. Current head includes main `ee0d1204e3` through a regular merge. - Built the actual raw modules, the test-private NID-patched libfreetype/libSceFreeType/kernel/libc context, and its patched test executable. The focused targets avoid an unrelated all-library dependency. - `guest_legacy_freetype_new_glyph`, its NID variant, `guest_freetype_glyph` (including current main's glyph-box cases), `guest_freetype_bitmap_init` and `guest_freetype_bitmap_embolden`: **5/5 passed in each of 3 runs**. - A separate source-built native FreeType oracle checks null/invalid arguments, unchanged error outputs, zeroed bitmap/outline records, independent objects, modified payload deep copies, copy/destruction interoperability, allocation failure/recovery and balanced native allocations. Real guest pages cover logical read-only/host-writable assertion controls and actual read-only output pages, with full-page preservation and writable recovery. - The same raw/NID test executable reaches the original `FT_New_Glyph` throwing body in unmodified main `6bf3a19b81`; both variants fail at the explicit supported-behavior assertion, not module/symbol lookup. - Four temporary mutation controls each fail both variants by assertion: wrong format dispatch, missing allocation-failure clearing, wrong published advance and bypassed output refusal. Production source was restored and rebuilt; the restored tests pass. - Public-header audit, current conventions and whitespace checks pass. Author and committer identities were checked before push. No standalone Linux, macOS, console or title run was performed for this final head. Earlier reviewer-supplied Linux/Windows combined-branch results are supplemental, not substituted for a final-head run. Overlap preflight is recorded below before submission; shared declaration/debt/build edits require preserving each independent contribution. The checker fails closed on other unmergeable PRs, so those comparisons are reviewed manually rather than called a clean automatic pass. Final pre-open `pr_overlap.py` run: 1,834 open PR heads, 75 shared-file candidates, base `1080643b1e`. Exit 2 came from 27 unmergeable external comparisons; all were manually inspected from their merge bases: #5021, #7275, #8650, #9156, #9161, #9293, #9297, #9302, #9383, #10609, #10611, #10613, #10616, #10897, #12004, #12373, #12642, #13486, #14212, #14429, #14798, #15111, #15363, #15365, #15630, #15836, #15838. None adds `FT_New_Glyph`, its NID, the new helper or its test/fragment. The shared changes are independent test registrations, other FreeType APIs, debt entries or formatting. Explicit adjacent edits in #15408, #15439, #15442, #15444, #15447, #15468, #16394 and #16399 remain integration work; #9848 includes the same unregistration-linkage correction and broader bridge renames. Combined integration with those unmerged branches was not performed here. ### 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: #16394, #16399 <!-- #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 -->
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!16497
No description provided.