fix(libSceFont): keep horizontal writing on a single baseline #5209
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5209"
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 Misjudgments on 2026-10-13T14:39:58Z.
What
Horizontal writing steps in libSceFont advanced the pen by the glyph's vertical
advance on every character, so text drifted down diagonally — steepest for CJK
fonts, whose vertical advance is roughly the em size. The step's
GlyphMetricswidth/height were also overwritten with the pen position, leaving the first
glyph of each run invisible at pen
(0, 0).Every supported writing form (
0x10,0x11,0x12) is horizontal, so the penmust advance only along X and the step must keep the real glyph width/height.
The vertical advance stays available as a metric through
sceFontGetCharGlyphMetrics.Tested
Windows 11 x64. Current
mainboots the PSP Classics title Ape Academy 2(UCES00302) to a playable state; the emulator's own UI dialog ("Confirm Rewind":
Rewind / Cancel / Yes) rendered its text with each glyph stepped diagonally
downwards and dropped the first glyph of every word. After this fix, rebuilt
libSceFont.prxandlibSceFont-module.prxwere redeployed and the dialog textrenders on a single baseline with all glyphs present; the title remains
playable. No other libSceFont callers regressed in this test.
Checklist
main; no equivalent open PR implements this fixdocs/dev/debt/libSceFont.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:02:28Z.
Review: CHANGES_REQUESTED
Thanks for tracking this down. Before merging I need three things:
sceFontWritingRefersRenderStep/sceFontWritingGetRenderMetrics) and pinsstep.yconstant across characters,advanceY == 0, andGlyphMetrics.width/heightequal to the glyph's own values (including the first character at pen(0, 0)). A manual run on one title is not enough to merge a behaviour change.FillWritingMetricsFromGlyph(src/core/libraries/font/font.cpp:145) does what the code you removed did (advanceY = Vertical.advance,GlyphMetrics.width/height = step.x/y), with a comment saying the real library keeps the anchor at the pen position. Please say which source you follow for zeroing them, and whether the real library's step keeps the glyph's width/height.docs/dev/debt/libSceFont.md:23notes that our vertical metrics (FreeType's vertical advance) are not confirmed on a title. If the real vertical advance of a CJK face is small or 0 for horizontal text, the drift may come from that value rather than from advancing the pen by it. Please check which of the two explains the dialog, and make the debt line say so.Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-18T11:40:38Z.
Test that fails on current
mainand passes with this change, plus a measurement from real firmware.Test (added to
guest_system_font, uses its square-glyph font at 100 px, whose glyph has horizontal advance 70 and vertical advance 100): writes the string "AA" throughsceFontWritingInitandsceFontWritingRefersRenderStepand checks both steps.main: fails at the first step check (advanceYis 100, the second step lands aty100).x 0, y 0, advanceX 70, advanceY 0, step 2 isx 70, y 0, advanceX 70, advanceY 0, and the step's own glyph metrics still report the vertical advance 100.guest_system_font,guest_fontandguest_font_writing_linepass (3/3), Windows 11, GCC 15.2.Real firmware (PS4 firmware 11.00 libSceFont loaded on Windows, not the PS5 library): the steps of "Ab c" come back
x=0 y=0 adv=22.4688,0,x=22.4688 y=0 adv=17.7969,0,x=40.2656 y=0 adv=8.89062,0,x=49.1562 y=0 adv=16,0.ystays 0 and the second advance is 0 on every step, so horizontal text does not step vertically, which is what this change does.Game: Ape Academy 2 (PPSA11132, PSP Classics) on current
main, Windows 11, RTX 4070 SUPER: the controller screen text ("Click the touch pad button...", "Press START to play!") has letters scattered down the screen. With this change inlibSceFontit is on one line.Test diff
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T22:50:01Z.
Independent confirmation on a second Sony classics emulator: Syphon Filter (PPSA06323) 01.000.003, a PS1 classics title. Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release.
Setup
main38d3c0858a+ #8847 (an unrelated AGC change).libSceFont.prx,libSceFont-module.prxandlibSceFont.native.prxreplaced by a build of38d3c0858awith this PR merged. It merges cleanly onto38d3c0858a. Every other library is byte-identical, and the title is relinked against each set.ANYPS5_SYSTEM_FONTS. The title opens system font set0x1808B4D4, which takesNotoSansCJK-Regular.ttcwithNotoSans-Regular.ttfas fallback. Without those files the title crashes 6 s in, which is the documented missing-fonts case.Result at the emulator's controller-layout screen, 95 s into each run:
Before/after crop: 20261021-pr5209-PPSA06323-before-after.png
Both runs hold 59.94 FPS for 183 s with no driver stop. I scripted only Cross, so neither went past the screen, which asks for START; this checks the text layout only. The PR conflicts with current
mainbut applied cleanly at38d3c0858a. Candidate library sha256 prefixes:libSceFont.prx28c90aaa121e1489,libSceFont-module.prx6830d8a9b95af65a.AI-assisted testing and report: yes, Claude Code.