feat(libSceFreeType): support memory fonts and face cleanup #8247
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8247"
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 santhoshkumar-dev on 2026-10-20T06:51:06Z.
What
libSceFreeTypecan load file-backed fonts but cannot load embedded font bytes or release any of its libraries and faces. AddFT_New_Memory_Face,FT_Done_FaceandFT_Done_FreeTypethrough the existing LP64 guest adapter.Each library owns its guest face records. Face deletion releases the native face and its wrapper; library deletion lets FreeType close every remaining native face before releasing the wrappers. Face creation keeps a native face under RAII until guest setup succeeds. File and memory faces share this path, while memory faces borrow the caller's font buffer.
Guest face, size and glyph-slot generic finalizers run with the guest ABI and guest object addresses. They follow bundled FreeType's destruction order, including the face's glyph/size fields visible during callbacks. Negative-index font probes retain null glyph and size pointers when the native probe has none.
Behavior follows the bundled FreeType 2.13.3 face APIs and object destruction. The console's version, options, errors and finalizer ordering are unverified. The debt file records that gap and removes the now-resolved leak entry. Buffer sizes outside the host
FT_Longrange throw, including sizes of 2 GiB or more on Windows.Tested
Windows 11 x64, WinLibs MinGW-w64 GCC 15.2.0 r7, Release, full project configured with
BUILD_TESTING=ON.cmake --build build --target guest_freetype_tests --parallel 8: passed.ctest --test-dir build -R '^guest_freetype$' --output-on-failure: passed (0.06 s).-std=c++20 -Wall -Wextra -Werror -fsyntax-only: passed.python tools/check_conventions.py --base origin/main: passed.git diff --cached --check: passed before committing.The regression compares memory-font records, outlines and rendered bitmaps with native FreeType; checks null arguments, invalid font/index inputs, negative-index probes and Windows size limits; compares face/size/slot finalizers with native callbacks during explicit face deletion and library shutdown; checks an independent library remains usable; and exercises empty-library destruction. Existing file-backed loading/rendering checks still pass.
No title, Linux runtime or console hardware tested. The full test suite was not run.
Refresh on 2026-10-21: rebased onto upstream
1381826358, clarified the Windows memory-size limit under Functional, and retained only the remaining gaps in the debt entry. Rebuilt the FreeType library and both test executables;guest_freetypeandguest_freetype_charmappass (0.08 s / 0.06 s), along with conventions. Production behavior is unchanged.Compatibility validation (2026-10-21): temporarily combined this PR with #8286, #8289, #9045, #9054, #9064 and the charmap-metadata follow-up on main
3e91c8edf5. All system libraries built and all seven FreeType tests passed. The C++ changes merged cleanly; temporary CMake/debt resolutions were used only for this local compatibility check and are not published.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 github-actions[bot] on 2026-10-20T06:51:43Z.
Progress report (
1381826→303f15c)📈 System libraries: 50.99% (+0.02%, +3 implemented functions)
✅ 3 implemented
FT_Done_Face_nid_postfixFT_Done_FreeType_nid_postfixFT_New_Memory_Face_nid_postfixImported from boykopovar/AnyPS5. Originally posted by vittoriosalvadore on 2026-10-20T07:42:39Z.
@santhoshkumar-dev Thank you for the lifecycle work. FT_Get_Kerning is now covered by #8558, so I will leave that API to its author and keep any future PR limited to point sizing. For the remaining debt overlap, may #8247 merge first?
Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T22:04:26Z.
One wording issue in the new debt entry at docs/dev/debt/libSceFreeType.md#L7:
Read normally, "excluding" means "except", so this says a buffer of 2 GiB or more does not throw on Windows. The code does the opposite. FreeType's
FT_Longissigned long(fttypes.h#L245), which is 32 bits with MinGW. So on Windows,FT_New_Memory_Face(library, buf, 0x80000000, 0, &face)fails the range check at Export.cpp#L127 and throws. The test asserts that throw (GuestFreeType.cpp#L268), and the PR description says "including sizes of 2 GiB or more on Windows". On Linux and macOSFT_Longis 64 bits, so the check never fires there.I'd suggest this wording, which matches the code and the existing
FT_New_Facenote at libSceFreeType.md#L11:This is a host limit rather than unknown console behaviour, so it may fit better in the Functional entry next to that
FT_New_Facenote.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T12:04:58Z.
Checked the memory/file face lifecycle (ownership per library, finalizer order for size/slot/face against native FreeType 2.13.3, null glyph/size on negative-index probes), the FT_Long range throw and the debt entries (the Windows wording fix is in); the new test needs the new exports and compares against native FreeType; merged.