Repository navigation
fix(font): keep Arabic and Thai text on one baseline (AnyPS5 #5209 backport) - #474
Merged
imnotsharingmyname merged 1 commit intoDec 5, 2026
Conversation
Add Source/anyps5/0042, a backport of upstream AnyPS5 #5209. On the pinned base, sceFontWritingRefersRenderStep moved the pen down by each glyph's vertical advance, so text the game lays out through the writing API (Arabic and Thai) drifted one glyph per line. It also reported each run's extent as the pen position, which made Thai text surfaces several times too tall. The patch keeps the pen on one baseline for the horizontal writing forms and includes the upstream regression test. Refs imnotsharingmyname#18, imnotsharingmyname#91. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With the game language set to Arabic or Thai, text laid out through libSceFont's writing API comes out one glyph per line. Each character lands lower and further right than the one before, so a short prompt turns into a diagonal column (#18, #91). The "invisible letters" part of the original Arabic report no longer reproduces on v1.2.33. The letters are drawn, just in the wrong places.
On v1.2.33 the Thai game doesn't get that far. It stops 9–21 s after boot with its own
Out of graphics memory [Onion]assert: a 1,051,392-byte request against a full 184 MiB pool (192,581,280 of 192,937,984 bytes used, 2630 allocations). This happened in 5 of 5 boots. English and the other Latin languages are not affected.Cause
The game lays out Arabic and Thai strings with
sceFontCreateStringandsceFontWritingRefersRenderStep, using writing forms 0x11 and 0x12. Latin text uses the per-glyph API and never reaches this code.On the pinned AnyPS5 base (319621b),
FillWritingMetricsFromGlyphset each step'sadvanceYto the glyph's vertical advance. The pen therefore moved down one line per character, even though every writing form the library accepts is horizontal. The function also overwrote the step'sGlyphMetrics.width/heightwith the pen position. As a result, the first glyph of a run reported 0 × 0 and the run's render metrics grew with the drift.A libSceFont call trace showed the drift in every string that took this path (numbers below). The game sizes its text surfaces from these metrics. With the fix, the median Thai text surface height drops from 1271 px to 118 px (Arabic: from 1081 px to 124 px). That is consistent with the Onion pool running out, but I did not instrument the pool itself.
Fix
Upstream AnyPS5 fixed this in boykopovar/AnyPS5#5209 (410e3b8b21, plus the test in 35f854562e), merged just after our pinned base.
Source/anyps5/0042-fix-libSceFont-keep-horizontal-writing-on-one-baseline.patchbackports it unchanged:advanceYis 0 for writing steps.The patch also carries the upstream regression test (in
guest_system_font) and the debt note. No AstroHybrid code or other library changes.Two open PRs (#453 and #420) already use 0041, so this patch is 0042. It applies on top of both.
Testing
Source/anyps5/0001…0042applies withgit am --3way(as inTools/build.ps1) and withgit am --3way --keep-cr(as inTools/linux/prepare-anyps5.sh).Source/anyps5-linux/0001applies on top. The resulting tree is identical to the one I built and tested. The series also applies after the 0041 patches from Add PlayStation trophies and in-game trophy notifications #453 and Set up and play from a PS5 fake package (.pkg) or image (.ffpfsc, .ffpfs, .ffpkg, .exfat) read in place #420.libSceFont-module.prx,libSceFont.prxandlibSceFont.native.prxas shipped.ctest -R "^(guest_font|guest_font_writing_line|guest_system_font)$"passes 3/3, including the new test.Risks and limits
Arabic is still not right. The patch fixes the layout bug that both languages share. After it, Arabic shows these problems in the world map, pause menu and level pause menu:
In the trace, each word of such a string gets a correct run on one baseline. AnyPS5's libSceFont reports bidi level 0 for every character and applies no Arabic contextual forms, which fits the first two problems. I haven't found the cause of the third, so treat it as unexplained. All three need a separate change. Without this patch, the same text is a one-glyph-per-line column, so this is still an improvement for Arabic but not a fix for Arabic text rendering bug (letters invisible, only diacritics shown) #18.
Coverage: Thai was checked in 5 runs with the patch (4 boots, 1 level), Arabic in 4 (3 boots, 1 level) and English in 2 boots, all on one PC. Long menus such as settings and other levels were not checked.
Scope: the change only affects writing steps. Latin text doesn't use them in this game, and the library only accepts horizontal writing forms, so nothing depended on the old
advanceY.Release files: the shipped
.prxfiles only change once libSceFont is rebuilt from the series.Refs #91 (Thai) and #18 (Arabic, partial). I'd leave closing #91 until a release build has been checked, and #18 should stay open.
🤖 Generated with Claude Code