fix(libSceFont): render a glyph into a zero-extent surface to measure it #9992
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9992"
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 klosixgaming-arch on 2026-10-23T03:19:51Z.
What
sceFontRenderCharGlyphImageand its Horizontal and Vertical forms returnedSCE_FONT_ERROR_NO_SUPPORT_SURFACEfor any surface whose width, height or row stride is 0, and cleared the metrics. A title that sizes a string before it has a surface to draw into initialises a surface with width 0 and renders each character only to read the metrics back. Every one of those calls failed, so the title never saw an advance.This accepts a surface whose width or height is 0: the glyph metrics and image metrics are returned, the update rectangle is empty and nothing is written to the buffer. A zero stride is accepted only together with a zero width or height. A negative width, height or stride, a null buffer and a pixel size other than 1 or 4 bytes still return
SCE_FONT_ERROR_NO_SUPPORT_SURFACE.Evidence
Tekken Dark Resurrection, the PSP classic that runs in the PSPHD emulator on PS5 (
tekkenin my test folder). Logging the return value of every sceFont call it makes, 68 calls ofsceFontRenderCharGlyphImageHorizontalbefore the first stop all returned0x80460050, each with a surface of buffer set, width 0, height 31, row stride 0, one byte per pixel and a scissor of 0,0,0,31. With this change the same 68 calls return 0 with real metrics (for example 'C' advance 19.14, width 16.33, height 22.77).The exact console result for a zero-extent surface is not measured. It is inferred from the title doing this on a console; the debt note says so.
This does not unblock Tekken. It still stops with
Could not get surface summary (8a6c000b)at the same place, and I have not yet found why the string it sizes ends up with width 0 afterwards. I am sending this separately because the failing return code is wrong on its own and is easy to verify.Related open PR
#8250 (reject undersized render surface strides) validates the stride of surfaces whose width and height are positive and explicitly returns early for the rest, so the two do not overlap in behaviour. Both add a line to
docs/dev/debt/libSceFont.md, so whichever merges second needs a trivial documentation rebase.Tested
Windows 11 (10.0.26200), WinLibs GCC 15.2.0, main
8fbafb82b0plus this change:libsandrelinkerbuild;guest_font,guest_system_font,guest_font_writing_line,font_face_lifetime,font_face_lifetime_replaceandfont_face_lifetime_churnpass (6 of 6);tools/check_conventions.pypasses.The new checks are in
GuestSystemFont.cpp: a surface of width 0 and stride 0, and one of height 0, returnSCE_FONT_OKwith the same advance as a normal surface, an empty update rectangle and an untouched buffer; a negative width, a zero stride with positive extent and a null buffer still returnSCE_FONT_ERROR_NO_SUPPORT_SURFACE. Without the change toLayout.cppguest_system_fontfails at the first of these (I built it that way to check).Checklist
main; open PR #8250 touches the same validation for a different case (see above).mdfiles or images added to the repositoryAI-assisted: yes. Written with AI assistance and reviewed by me.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QLz9JYSXCPssYHgRW1CxJH
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T03:22:15Z.
Review: APPROVED
Reviewed exact head
c0024158dbagainst current base8fbafb82b03473eba4197436852bead4a291f15b. The validation change accepts zero width or height (including zero stride only for an empty extent) while still rejecting negative dimensions/stride, zero stride on a nonempty surface, null buffers, and unsupported pixel sizes. The new regression assertions check returned metrics, an empty update rectangle, and an untouched buffer. I found no blocking issue in the diff.The author reports successful Windows builds of
libsandrelinker, six focused font tests, and passing conventions. CI eligibility, conventions, intake, labels, and report checks pass; hosted product builds are skipped. I did not rerun the font test locally: the available configured build uses the older/marc/AnyPS5source tree, and the root filesystem is full, so it cannot provide an exact-head build here. The PR documents that zero-extent behavior is inferred from the title's calls and is not measured on a console.