feat(libSceFreeTypeOt): implement the FreeType glyph loader #15052
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15052"
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 noamroger on 2026-11-02T12:34:46Z.
What
Ten libSceFreeTypeOt exports listed as
sceFreeTypeOtUnknown_*carry the NIDs of FreeType's glyph loader (tools/nid_names.py):PvCNusrp9xQFT_GlyphLoader_New,vTZ34rw1sfgDone,Ev3BqJ-U1FgReset,ZhtAXOoLNyoRewind,m18bTUNF-0gCreateExtra,2T7lbS+CSzACheckPoints,MGEIQsujKaYCheckSubGlyphs,dlM4ASZdcjkPrepare,UD7IFu7ML2UAdd andmkmgcRnAJogCopyPoints. This PR ports them insrc/GlyphLoader.cppand removes the ten throwing stubs.FT_Sqrt32,FT_Property_Set).FT_GlyphLoader_CopyPoints, removed in 2.10.0, is also in the export list. All allocation goes through the module's existingft_mem_*helpers and the guestFT_MemoryRec.include/GlyphLoader.hppadds the LP64FT_SubGlyphRec(48 bytes),FT_GlyphLoadRec(72) andFT_GlyphLoaderRec(176) with offsetstatic_asserts, reusingGuestOutline,GuestVectorandGuestMatrix.CopyPointssource) throws where FreeType would dereference it.DoneandAddignore it, as the source does.CreateExtra, noReseton error, and signed 16-bit outline counts.Tested
Linux x86-64, full build with GCC 13. The new
guest_freetype_ot_glyph_loadertest drives every export through a recording guest allocator. It covers allocation size and zeroing, Out_Of_Memory on New and on failed resizes (tables kept), padding to 8 points, 4 contours and 2 subglyphs, growth from the old maximum, the 0x7FFF Array_Too_Large limits, the extra point tables and the move of the second one, Add contour offsets, Rewind, Prepare, Reset, CopyPoints with extra tables, and Done freeing every block. It also passes standalone under AddressSanitizer and UndefinedBehaviorSanitizer. All 14guest_freetype_(ot|corner|stream|outline_border)tests pass, raw and patched. The patchedlibSceFreeTypeOt.prxexports the ten NIDs.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pycannot run from my environment (no GraphQL access), so I checked overlap by hand: I diffed every open PR against its merge base for these ten NIDs and forGlyphLoader, and none touches them. Not tested on a PS5.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)Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:22:51Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The unsigned count arithmetic in the new glyph loader can wrap and report success without allocating the requested capacity, so changes are required before merge: reject oversized counts before adding them.
What I ran
Reviewed head
0fe71880236dfc2f3730bb634d71497f3b68b4b8using the prepared review bundle and the pinnedrepo_read.pyreader. No build or tests were run.Results
Findings
Blocking
core/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cpp:307:n_pointsis added to the existing counts inuint32_t; a large value can wrap belowmax_points, causingCheckPointsto return success without reserving the requested space. The contour calculation at line 325 has the same issue, andCheckSubGlyphsat line 341 also adds unchecked unsigned counts. Reject counts above the supported limit and perform checked addition before comparing capacity, so callers cannot receive success with insufficient storage.Non-blocking
None.
Not verified
Build, tests, and console behavior were not verified. The change description reports successful Linux build and test runs; these were not run as part of this review. All seven changed files listed in the prepared bundle were included in the diff review; no changed files were excluded.
To get this to a good state
Reject oversized counts and guard the additions in
CheckPointsandCheckSubGlyphs. Then rerun the glyph loader tests and the reported build checks on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T09:36:19Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: prevent signed overflow when interpreting outline counts in
CheckPoints.What I ran
Reviewed head
fb0e6eba09f3a2bcdaee6a3ecd06efb643cf2014using the prepared diff and pinned repository reader. I did not run build or tests.Results
Findings
Blocking
core/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cpp:133:Countsign-extends the 16-bit outline count, thenCheckPointsadds base and current counts in signed 32-bit arithmetic before converting toint64_t. For valid signed counts near0x7fff, their sum can overflowint, which is undefined behavior and can produce an incorrect allocation size or bypass the0x7ffflimit. Promote each count before adding (or use anint64_treturn fromCount) and cover the boundary case.Non-blocking
None.
Not verified
Build, test suite, sanitizers, PR overlap, and PS5 runtime were not independently checked. The author reports Linux x86-64 GCC 13 build and test results, including sanitizer runs, but these were not run during this review. All changed files were included in the prepared bundle and were read:
CMakeLists.txt,Export.cpp,GlyphLoader.hpp,libSceFreeTypeOt.hpp,GlyphLoader.cpp,GuestFreeTypeOtGlyphLoader.cpp, anddocs/dev/debt/libSceFreeTypeOt.md. No files were listed as excluded by rule.To get this to a good state
Promote both counts before adding in
CheckPoints, add a regression test for the boundary sum, and rerun the glyph loader tests and sanitizer run on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:38:07Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: fix the
CheckPointsresize failure path so a failed table reallocation cannot leave loader state pointing at freed memory.What I ran
Reviewed head
6b590ca81c1ec57a489b134bf49ffa5f58ffd418using the prepared diff and pinnedrepo_read.pyreader. No build or tests were run by me; the Linux build and test results in the description are author-reported.Results
Findings
Blocking
base.pointssucceeds but resizingbase.tagsfails,ft_mem_realloc_nid_postfixmay already have freed the old points block while the function returns before updatingloader->max_pointsor adjustingcurrentpointers. Subsequent loader use can then access stale pointers, andDonemay free them again. Make the resize operation transactional or update state and pointers safely on partial failure.core/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cpp:142Non-blocking
None.
Not verified
core/libs/prx/libSceFreeTypeOt/CMakeLists.txt,Export.cpp,include/GlyphLoader.hpp,libSceFreeTypeOt.hpp,src/GlyphLoader.cpp,core/libs/tests/GuestFreeTypeOtGlyphLoader.cpp, anddocs/dev/debt/libSceFreeTypeOt.md; also inspectedinclude/GlyphSlot.hpp,include/Memory.hpp, andinclude/GuestList.hppfor context. No changed files were excluded by the manifest.files.jsonwas not available through the reader.To get this to a good state
Make
CheckPointssafe when one resize succeeds and a later resize fails, then rerun the glyph-loader test and relevant build checks on the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T01:53:14Z.
Review: COMMENTED
Reviewed — no blocking findings
The implementation is internally consistent with the stated FreeType 2.4.12 behavior, but I could not run the build or tests in this review session, so I cannot make a formal approval decision.
What I ran
Reviewed head
fef10b2f7e3277a60412a4b25fda2d2285c0ba4f. Read the prepared description, commits, manifest, diff, and all seven changed files listed for review. Inspected the glyph loader records, memory helpers, test setup, and debt entry at the pinned head. No commands or tests were run; the author-reported test results were not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build, tests, sanitizer results, export presence in a patched PRX, and console behavior were not independently verified. The author reports these checks in the PR description. Files excluded from the review folder by rule: none reported in
files.json.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:50:04Z.
Review: COMMENTED
The Linux integration build passed the registered FreeTypeOt glyph-loader CTest.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T21:28:49Z.
Review: COMMENTED
Actionable comments
Pending dependency exports.915bb651-5544-462d-b725-c587f820b79bReviewing files that changed from the base of the PR and between
192c4e45a0ande9e7b1eb99.core/libs/prx/libSceFreeTypeOt/CMakeLists.txtcore/libs/prx/libSceFreeTypeOt/Export.cppcore/libs/prx/libSceFreeTypeOt/include/GlyphLoader.hppcore/libs/prx/libSceFreeTypeOt/libSceFreeTypeOt.hppcore/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cppcore/libs/tests/GuestFreeTypeOtGlyphLoader.cppdocs/dev/debt/changes/feat-freetype-library-object-api.mddocs/dev/debt/libSceFreeTypeOt.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T23:26:03Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: guard empty table pointers before adjusting their offsets in
Prepareand the allocation paths.What I ran
Reviewed head
e9e7b1eb99d05b0d126a4624ac334d940ba79bfbusing the prepared diff andrepo_read.pysource context. No build or tests were run.Results
Negative control
Not run; no executable test was run to confirm the empty loader behavior.
Findings
Blocking
core/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cpp:67andcore/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cpp:77:AdjustPointsandAdjustSubglyphsadd counts to table pointers without checking whether the pointers are null.Preparecalls both unconditionally, so preparing a newly created loader with no allocated tables performs null pointer arithmetic, which is undefined behavior in C++.CheckPointscan also reachAdjustPointsafter allocating only contours. Preserve null pointers when their corresponding tables are absent, and cover these empty-table paths.Non-blocking
None.
Sources
Not verified
No build, tests, sanitizer run, or PS5 behavior was verified. The description's reported test results were not independently run. Read the changed files listed under
files.json'sreviewedentry and relevantGlyphSlot.hppandMemory.cppcontext through the reader;files.jsonlists no excluded changed files.To get this to a good state
Guard null table pointers in the adjustment helpers and add coverage for
Prepareon a fresh loader andCheckPointswhen only contours are allocated. Run the relevant glyph loader tests and sanitizer check on the new head.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T13:47:57Z.
Review: COMMENTED
Actionable comments
5f04bbe6-ea90-4a84-8566-41ae53de57d4Reviewing files that changed from the base of the PR and between
e9e7b1eb99andec326f3dc6.core/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cppcore/libs/tests/GuestFreeTypeOtGlyphLoader.cppdocs/dev/debt/changes/claude-project-thread-0kf6x6.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T14:26:12Z.
Review: APPROVED
Reviewed — looks good
The inspected implementation and ABI layout support the FreeType 2.4.12 glyph-loader port at head
ec326f3dc65ff523eb0c1e8fffec7ad6c2299053.What I ran
Read the prepared diff and all 8 files listed as reviewed in
files.json, plus pinned source context for the loader records and memory helpers. Excluded files: none.The reader returned the requested source, then failed while appending its read log to the read-only run folder. No build or test command was run.
Read files:
core/libs/prx/libSceFreeTypeOt/CMakeLists.txt,core/libs/prx/libSceFreeTypeOt/Export.cpp,core/libs/prx/libSceFreeTypeOt/include/GlyphLoader.hpp,core/libs/prx/libSceFreeTypeOt/libSceFreeTypeOt.hpp,core/libs/prx/libSceFreeTypeOt/src/GlyphLoader.cpp,core/libs/tests/GuestFreeTypeOtGlyphLoader.cpp,docs/dev/debt/changes/claude-project-thread-0kf6x6.md,docs/dev/debt/changes/feat-freetype-library-object-api.md.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The added tests were not run, and behavior on a PS5 was not verified. The author's reported test results were not independently confirmed.
To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.