feat(libSceFreeType): implement FT_Get_Kerning #8558
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8558"
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 Filip722 on 2026-10-20T16:33:56Z.
What
FT_Get_Kerningis missing from the existing FreeType guest bridge, so imports of its known NID cannot resolve to a guest-safe implementation. This adds pair kerning through the bundled FreeType 2.13.3 backend.long.The name/NID
LPtlB241JSgcomes from the PS5 3.20 inventory. Behavior follows bundled FreeType's implementation. No game unblock or hardware equivalence is claimed.Tested
Debian GNU/Linux 13 x86-64, GCC 15.2.0, Release with
BUILD_TESTING=ON, using bundled FreeType 2.13.3.All system libraries built successfully with
cmake --build build --target libs guest_freetype_tests --parallel 2. The final focused CTest passed, and the packagedlibSceFreeType.prxexportsLPtlB241JSg. Changed-translation-unit checks and repository conventions passed.The focused
guest_freetyperegression compares the adapter with native FreeType and checks explicit expected negative values for unscaled, fitted and unfitted kerning. It covers small-size rounding, absent pairs, a font without a kerning table, out-of-range glyph indices, null arguments and preserved output on a null face. A temporary always-zero output mutation failed; restoring the adapter passed.The review follow-up adds
(0x10001, 1)and(0x7FFF0001, 1)zero-result checks in all four modes at both tested sizes, plus(1, 0x10001)to preserve the distinct right-index behavior. The updated focused Linux test, packaged-library rebuild and conventions checks passed.Rebased onto
7d7b097407on 2026-10-21. The existing kerning implementation and regression cases are unchanged; tests now use upstream’s shared font fixture, and both debt entries are retained. Rebuilt the FreeType library and both focused test executables;guest_freetypeandguest_freetype_charmappassed, along with conventions and whitespace checks.Windows and PS5 hardware were not tested. The existing guest layout and backend-version assumptions remain documented in the library debt file.
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 nikowolf123 on 2026-10-20T19:04:43Z.
On Windows, a left glyph index above
0xFFFFreturns the kerning of a different glyph pair instead of{0, 0}.Export.cpp#L103 passes
leftGlyphto FreeType unchanged. FreeType'skernlookup builds its key as((FT_ULong)(g1) << 16) | (g2)(ttkern.c#L39).FT_ULongisunsigned long(fttypes.h#L256), which is 32 bits on Windows, so the top 16 bits of the left index are dropped there. Wherelongis 64 bits, the key is above0xFFFFFFFFand matches no pair. That covers Linux and the LP64 console library that the existing debt entry assumes.I built the test's kern font (one pair, (1, 1) = -73) against the bundled FreeType 2.13.3 on both hosts. At 100 ppem,
FT_Get_Kerning(face, 0x10001, 1, mode, &v)gives:x = 0in every modex = -73unscaled,-448default and-467unfitted.0x7FFF0001gives the same values.The test's
0xFFFFFFFFcase does not catch this, because its truncated key is0xFFFF0001. Real fonts never have glyph indices this high. Still, the library already narrows out-of-range face indices and character codes the way the 64-bit build does. Placed after the null check on line 101, this returns what the 64-bit build returns. TheFT_IS_SFNTcheck leaves other font formats to FreeType:With this change, Windows matched Linux on ten pairs, including the ones above, in all four of the test's modes at 100 and 12 ppem. Adding a separate
(0x10001, 1)check that expects{0, 0}lets the Windows CI job cover this. That check can't go into the existing two-sided loop: FreeType itself matches(1, 0x10001)to the (1, 1) pair on every host.Imported from boykopovar/AnyPS5. Originally posted by Filip722 on 2026-10-20T19:07:46Z.
Thanks for the cross-platform reproduction. Fixed in 13521a96f. SFNT left indices above
std::numeric_limits<std::uint16_t>::max()now produce{0, 0}after null validation. The guard applies on both hosts, preserving LP64 behavior and allowing the Linux test to exercise it; other font formats still delegate to FreeType.Added
(0x10001, 1)and(0x7FFF0001, 1)checks in all four modes at 100 and 12 ppem, plus(1, 0x10001)to ensure the right-index behavior remains unchanged. The focused Linux test, packaged-library rebuild and conventions checks passed. I have not run Windows locally.Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T06:58:35Z.
Windows run of 256ab6609a merged onto
mainec7eacc62d(8474a1fd04, clean), one of the hosts the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release,BUILD_TESTING=ON.Built
libSceFreeTypeandguest_freetype_testswith no errors or warnings;ctest --repeat until-fail:2onguest_freetype: passes on both repeats. Windows is the LLP64 host where the left index above0xFFFFpicked another pair's kerning; at this head the0x10001and0x7FFF0001left-index checks are part ofguest_freetype, so they ran here. Not run: the negative control againstmain's library, a title.Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T03:31:30Z.
I opened #9588 for FT_Glyph_Get_CBox. I declared #8558 for merge order because the included outline dependency and this PR share a debt insertion. Retain both kerning and control-box entries during the rebase.