Repository navigation
feat(libSceFont): implement sceFontCharactersRefersTextCodes and text code stepping - #6019
Merged
adriadam10 merged 1 commit intoOct 17, 2026
Merged
Conversation
… code stepping sceFontCharactersRefersTextCodes fills a 64-byte FontTextCodes with the order and code of a text character and keeps the current, start and term characters at +0x28, +0x30 and +0x38. The traversal follows the PS4 11.00 libSceFont.sprx disassembly posted in the review of boykopovar#4050, which implemented the same rules: Refers never compares the character with the term and returns null for a clustered or synthetic character, sceFontTextCodesStepNext returns null at the term after visiting it, sceFontTextCodesStepBack returns null at the start character, and both steps skip synthetic characters. Null from StepNext at the end of the chain and from StepBack at the head of the chain is assumed and not covered by the report. The signatures follow Orbital's IDA type database and SharpProspero. A null cursor or output returns null as in KytyPS5; a null text character throws. guest_font_tests gets configure_windows_unwind so the expected exception reaches the test on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 tasks done
11 tasks done
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
Collaborator
|
Checked build and ctest ( |
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.
What
Implements
sceFontCharactersRefersTextCodes,sceFontTextCodesStepNextandsceFontTextCodesStepBack, the three remaining text-code exports of libSceFont, over the character chainsceFontCreateStringalready builds.Prior art. #4050 by @p3n1cillin implemented the same three functions with the same PS4 11.00 rules (the rules @fma-rc reported from the disassembly in its review) and was closed by a maintainer for two reasons: no title was shown to call them, and the behaviour comes from the PS4 library only. Both reasons still apply to this PR, which follows the same rules and names no title either. It was written from that disassembly comment, not from the #4050 branch, and differs from it in a
FontTextCodesunion oversystemUse[8]instead of named cursor fields, a null text character that throws instead of returning null, and tests added to the existingguest_fontsuite. The reasons #1014 and #4865 were closed (no title confirmed to call these functions, no known executable importing them) apply to it as well. The earlier attempts by @renzipego-cpu, @Thomas73737, @tarfouss3 and @Dripl1x, and why each was closed, are listed under the duplicate check below.Source of the behaviour.
libSceFont.sprxdisassembly of these NIDs that @fma-rc posted in the review of #4050. This is PS4 behaviour; no PS5 source is known. The repo already prefers PS4 measurements over KytyPS5 for libSceFont (see thesceFontWritingLineGetOrderingSpaceandsceFontCharacterGetSyllableStringStatedebt entries, both measured on PS4 11.00libSceFont.sprx).Refers(0x15f80) never compares the character with the term, keeps the current character at cursor +0x28, the start at +0x30 and the term at +0x38, and returns null for a character whose byte +0x31 (clusterIndex) or +0x33 (synthetic) is set.StepNext(0x15fd0) compares the current character with the term (cmp 0x38(%rax),%rcx) before advancing, so it returns null at the term after visiting it: over A B C with C as term it yields B, then C, then null. The report says it returns null only at the term; null at the end of the chain (for example with a null term, as one test uses) is assumed here and not covered by the report.StepBack(0x16020) returns null when the current character is the start (cmp 0x30(%rax),%rcx), so a cursor created at B does not step back to A. Null at the head of the chain is assumed here and not covered by the report.sceFontCharactersRefersTextCodes(textCharacter, termCharacter, textCodes*)andsceFontTextCodesStepBack/sceFontTextCodesStepNext(textCodesStep); the same three in SharpProspero.SceFontTextCodes, 64 bytes with the order pointer at 0 and the 32-bit code at 8; the newFontTextCodesunion (text.order,text.code,text.reservedoversystemUse[8]) has astatic_asserton its size, and the cursor words at +0x28/+0x30/+0x38 aresystemUse[5..7].sceFontWritingRefersRenderStepCharacter); the disassembly report does not cover them.Changes:
FontTypes.hpp: adds the 64-byteFontTextCodesunion.Text.cpp: the three exports as above; a step that returns null leaves the codes unchanged.Unimplemented.cpp: the three throwing stubs are removed.guest_font: walks a three-character string forward and back and checks order and code at each step, the term being visited, the stop at the start character, a cursor whose start is its term, skipped synthetic characters, nullRefersfor clustered and synthetic characters, null output and null step, untouched codes after a null result, and the throwing null character.core/libs/prx/libSceFont/CMakeLists.txt:guest_font_testsgetsconfigure_windows_unwind, likeguest_system_font_testsandguest_font_writing_line_tests, so the exception the test expects from the null text character reaches it on Windows instead of terminating the process.docs/dev/debt/libSceFont.md: records the sources and that the rules are PS4 ones.Still throwing (
std::runtime_error): a null text character, whose console result is not covered by the disassembly report. The other unimplemented libSceFont exports are not touched.Progress: libSceFont 120/195 → 123/195 (
tools/progress.py).Tested
Head
cf762829d1ba0cbe6278653a96300c53447a5dda, basee27ff7c545cb5ac669612567d853956ffa02ebe6.BUILD_TESTING=ON, AMD EPYC 7763 (GitHub Codespaces), tests run natively):guest_font_testspasses in 5 of 5 runs, the test executable being run directly five times.core/libs/prx/libSceFont/src/Text.cpp,core/libs/prx/libSceFont/src/Unimplemented.cppwith the base version:guest_font_testsfails withsceFontCharactersRefersTextCodes not implemented. Restoring the PR source and rebuilding,guest_font_testspasses in 5 of 5 runs again.mainat2b7e3ce69fd889deceb6b52ac1fbf13e7c0d1084, WinLibs MinGW-w64 GCC 15.2.0, Release,BUILD_TESTING=ON: 1212/1212 tests pass; the relinker (Linux, Windows, macOS), register-context and write-watch jobs of the same run also pass.git diff --checkpass. The Linux job of the Build workflow now targets the project's self-hosted runner, so it was not run on the fork; no title was run.Duplicate and overlap check
sceFontCharacterGetSyllableStringStateand two attribute calls); feat(font): implement text codes stepping and attribute storage #1000 was closed by its author without a comment and replaced by feat(font): implement text codes stepping and attribute storage #1014, which a maintainer closed because the owner asked to merge only changes a title needs and none of its functions was confirmed on a title.core/libs/tests/GuestFont.cpptocore/libs/tests/media/and rewrites theguest_fontregistration incore/libs/prx/libSceFont/CMakeLists.txt, next to theconfigure_windows_unwind(guest_font_tests)line this PR adds; that is a one-line CMake conflict, resolved by keeping theconfigure_windows_unwindcall beside the newadd_library_test(media NAME guest_font ...). fix(font): serialize shared FreeType face lifetime #6282 touchesCMakeLists.txtandGuestFont.cppand merges with this PR without conflict. Before those, fix(libSceFont): keep horizontal writing on a single baseline #5209 was the only open PR touching the same files (Text.cpparoundFillWritingMetricsFromGlyph, and one line appended at the end ofdocs/dev/debt/libSceFont.md). Its hunks do not overlap this PR's (helper added afterAccumulateWritingMetrics, exports added aftersceFontCharacterRefersTextNext, debt line added after thesceFontCharacterGetSyllableStringStateentry); its patch applies on top of this branch.e27ff7c54.Checklist
e27ff7c54; 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)🤖 Generated with Claude Code