Skip to content

feat(font): implement sceFontGetRenderScaledKerning - #584

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
DotDebian:feat/font-get-render-scaled-kerning
Oct 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
DotDebian:feat/font-get-render-scaled-kerning

Conversation

@DotDebian

Copy link
Copy Markdown
Contributor

What

Implements sceFontGetRenderScaledKerning, which was a throwing stub.

It returns the kerning between two character codes at the render scale of the font: the cached style that sceFontSetupRenderScalePixel / sceFontSetupRenderScalePoint write and that a bind copies from the font style. Without a bound renderer it returns SCE_FONT_ERROR_NOT_BOUND_RENDERER. This is the same split as sceFontGetCharGlyphMetrics / sceFontGetRenderCharGlyphMetrics.

  • Render.cpp: the FreeType lookup of sceFontGetKerning moves into a helper shared by both functions; sceFontGetKerning behaves as before.
  • Errors: null kerning gives INVALID_PARAMETER, a bad handle INVALID_FONT_HANDLE, no renderer NOT_BOUND_RENDERER. The output is cleared on every path except the null one. A pair without kerning or a code without a glyph returns zeros and SCE_FONT_OK, as sceFontGetKerning does.

Source of the behaviour: shadPS4, which this library is ported from, has the function as a stub with no signature. The arguments, the cleared output and the renderer check come from cellFontGetRenderScaledKerning in RPCS3 (the PS3 predecessor of the library, where cellFontGetKerning has the same arguments as sceFontGetKerning). The kerning value itself is the sceFontGetKerning one at the render scale. None of this is confirmed on a title; it is recorded in TechnicalDebt.

Does not overlap #461 (no shared source or test file; one separate line in TechnicalDebt.md).

Tested

Windows 11, MinGW-w64 GCC 15.2.0, ctest: 217/217 pass.

guest_font is extended. The test builds a three-glyph TrueType font with a cmap and a kern pair of -200 units at 1000 units per em, then checks:

  • -20 px at a render scale of 100 px copied from the font style on bind, -10 px after sceFontSetupRenderScalePixel(50), -8 px after sceFontSetupRenderScalePoint(20) at 144 dpi;
  • sceFontGetKerning still returns the font scale value (-20 px) after the render scale changes;
  • zeros for the reversed pair and for a code without a glyph;
  • the three error codes, before a bind and after an unbind, and the cleared output.

Before the change the test stops at the first call with sceFontGetRenderScaledKerning not implemented.

Not tested on a title.

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 in TechnicalDebt
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

Return the kerning between two character codes at the render scale of
the font, the one set by sceFontSetupRenderScalePixel and
sceFontSetupRenderScalePoint, and fail with NOT_BOUND_RENDERER when no
renderer is bound. sceFontGetKerning keeps its behaviour and shares the
FreeType lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

Progress report (07404b6 → 52c13a0)

📈 System libraries: 79.17% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceFont sceFontGetRenderScaledKerning

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks. The NID recomputes (ryPlnDDI3rU is sceFontGetRenderScaledKerning), the shared LoadKerning leaves sceFontGetKerning as it was, and the argument checks follow cellFontGetRenderScaledKerning in RPCS3 as described, with the library's own INVALID_FONT_HANDLE for a bad handle like the neighbouring functions. The TechnicalDebt line records where it comes from. The test values check out (-200/1000 at 100 px, 50 px, and 20 pt at 144 dpi).

guest_font passes here, and on main's code it stops at "sceFontGetRenderScaledKerning not implemented".

PPSA21564 doesn't import this function. Ready to merge from my side.

@oneandonlydean
oneandonlydean merged commit 18d9745 into boykopovar:main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants