Skip to content

fix(libSceFont): resolve a default string direction at creation - #10021

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
klosixgaming-arch:fix/font-writing-line-horizontal
Oct 25, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
klosixgaming-arch:fix/font-writing-line-horizontal

Conversation

@klosixgaming-arch

@klosixgaming-arch klosixgaming-arch commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What

A string created from a text source in the default horizontal form (0x10) reported 0x10. TEKKEN: DARK RESURRECTION (PPSA31371) passes the reported form to sceFontCreateWritingLine, which only accepts 0x11 and 0x12, so the call failed and the title's text layout width was 0.

On firmware 13.42, sceFontCreateString decides the direction for a default-form source, and sceFontStringGetWritingForm returns the stored form (measurement by BunnyFl, in the comments). This PR does the same: the string gets 0x12 when its first strong character is left to right, 0x11 when it is right to left, and 0x12 when it has none. LRM and RLM count as strong, embeddings and overrides do not, and text between an isolate initiator and its PDI is skipped. Explicit 0x11 and 0x12 sources keep their form.

The report ran non-empty text only until a later glyph-stage failure, and only empty text ran to completion, so this is not full native right-to-left rendering. Which characters are strong is decided by Unicode block ranges, not the full bidi class tables. Both are in docs/dev/debt/libSceFont.md.

Tested

  • guest_font and guest_font_writing_line pass. The font test covers every row of the reported table that can be built from code points, plus explicit 0x11 and 0x12 sources.
  • Windows 11, RTX 5090: Tekken (PPSA31371) with this change reaches its menus, character select and a fight at about 55 fps by eye (discussion TEKKEN: DARK RESURRECTION (PPSA31371) #10051).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR
  • No comments in code
  • Unimplemented paths throw; no silent stubs
  • No notes, investigation .md files or images added to the repository
  • No third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA31371 TEKKEN: DARK RESURRECTION (PPSA31371) #10051
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted: yes. Written with AI assistance and reviewed by me.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new focused assertions and title trace are useful, but I can’t approve this head yet. The required conventions check fails on the existing head commit 39bb288c8 (wip-writingform): it is not a Conventional Commit subject. Please amend/squash it to a permitted subject and keep the successful convention check visible.

One behavior question: this maps every default 0x10 string to LTR 0x12, including text whose first strong character is RTL. The PR notes this limitation and says the native default result is unmeasured. Is there measured or API-contract evidence that sceFontStringGetWritingForm should always return LTR for a default-form source? If this is an evidence-based compatibility fix, documenting that basis would make the choice auditable; if the firmware resolves direction from text, this mapping could report the wrong direction for RTL strings.

@github-actions github-actions Bot added the prx label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10636 docs/dev/debt/libSceFont.md L6

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.

Pull request Shared files not compared
PR 5209 core/libs/prx/libSceFont/src/Text.cpp
docs/dev/debt/libSceFont.md
PR 8250 docs/dev/debt/libSceFont.md
PR 10539 docs/dev/debt/libSceFont.md

@klosixgaming-arch
klosixgaming-arch force-pushed the fix/font-writing-line-horizontal branch from 39bb288 to b38774d Compare October 23, 2026 04:56
@klosixgaming-arch

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

Commit subject: my fault. I amended the commit in the wrong checkout, so the subject fix never reached the branch. The head is now b38774ddf0 (fix(libSceFont): report a default horizontal string as left to right), and the conventions check should run again on it.

Evidence for always returning LTR: there is none beyond what the PR states. Nothing is measured on a console, and I have no API contract for sceFontStringGetWritingForm. What I do have is:

  • Tekken Dark Resurrection sets form 0x10, then passes the form the string reports to sceFontCreateWritingLine.
  • sceFontCreateWritingLine accepts only 0x11 and 0x12 (the existing test pins 0x10 as rejected), so the string must report one of those for this to work.
  • With 0x12 returned, the title gets past its 8a6c000b stop. I have not seen its text render.

If the firmware resolves the direction from the text, 0x11 for a right-to-left first strong character would be the better answer, and this mapping is wrong for that text. I did not implement that because I cannot tell which is right without a measurement, and Tekken's strings are Latin. If you know the console result, or would rather I resolve it from the first strong character, I will change it.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head b38774ddf0306610ec8b228449442094cae4fa6b. The getter now maps only the stored default horizontal form (0x10) to 0x12; invalid handles still return 0, and explicit 0x11/0x12 values remain unchanged. This is consistent with the existing writing-line validation, which rejects 0x10 and accepts 0x11/0x12, and with the reported Tekken call sequence. The regression test checks the default and both explicit forms and restores the source's default before the existing checks. I found no defect in the scoped change.

The author reports a Windows 11 GCC build and passing guest_font and guest_font_writing_line tests, along with a title reproduction that gets past the prior error; text rendering remains unverified, and the native default getter result is explicitly unmeasured. Locally, git diff --check upstream/main...upstream/pr-10021-current and python3 tools/check_conventions.py --base upstream/main --head upstream/pr-10021-current passed. Hosted eligibility, conventions, labels, and report passed; product and auxiliary build jobs were skipped by workflow policy. I could not run the guest font binaries in this Linux environment.

@klosixgaming-arch

Copy link
Copy Markdown
Contributor Author

Evidence from running the title with this change: with this PR and #9992 applied on top of main at 9d6adeb, TEKKEN: DARK RESURRECTION (PPSA31371) gets past the Could not get surface summary (8a6c000b) stop, plays its intro movie, reaches the game's start menu, character select and the fight tutorial, and runs at about 55 fps by eye. The title's own text renders correctly. Details are in #10051.

That run only covers left-to-right text: the title passes the default string form (0x10) to sceFontCreateWritingLine, which rejects it, and reporting 0x12 is what lets it continue. It does not show what the native library returns for that default form, and the doc note in this PR still says so.

AI-assisted: yes. Written with AI assistance and reviewed by me.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@klosixgaming-arch the focused tests pass, but they assert the chosen LTR default without establishing the native rule. Can you provide a console result or an API contract for default-form strings with LTR and RTL text, and align the getter and tests with it? The Latin-text run establishes that caller path; it does not show that every default 0x10 string should report 0x12. I would keep this question open rather than substitute another unmeasured direction rule.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing test and title run show the chosen result lets the reported path proceed, but the native getter result for a default horizontal form is still explicitly unmeasured. The change maps every stored 0x10 value to 0x12, while the current evidence is a Latin-text call path and does not establish the getter contract across RTL/default-form inputs. Please add a console/API-contract result covering default-form LTR and RTL inputs, or keep the behavior scoped to the demonstrated case and mark the general mapping unresolved. This is an evidence gap in the core behavior, not a request for unrelated rendering coverage.

@klosixgaming-arch klosixgaming-arch changed the title fix(libSceFont): report a default horizontal string as left to right fix(libSceFont): report a default string without right-to-left text as left to right Oct 23, 2026
@klosixgaming-arch
klosixgaming-arch force-pushed the fix/font-writing-line-horizontal branch from b38774d to ef9fed3 Compare October 23, 2026 13:09
@klosixgaming-arch

klosixgaming-arch commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@oneandonlydean @MarcZX10 agreed: the all-0x10 mapping was not backed by a measured result. The native getter result for a default-form string, with left-to-right or right-to-left text, has not been measured yet, so I took the second option and scoped the change to what the title shows.

Head ef9fed3a2a (rebased onto current main, which also cleared the merge conflict):

  • A default-form (0x10) string reports 0x12 only when none of its characters is in a right-to-left block or is a right-to-left control. That is the Latin text Tekken passes.
  • A default-form string that holds a right-to-left character keeps reporting 0x10, as before, and the debt note says the native result for it is unknown. I did not add a first-strong or other direction rule.
  • Explicit 0x11 and 0x12 forms are reported as stored.
  • The test now covers Latin and CJK codes, Hebrew, Arabic and a right-to-left embedding control in the default form, and explicit 0x11 and 0x12 sources. guest_font and guest_font_writing_line pass.

Once a native result for the default form with right-to-left text is measured, the debt line is where it belongs, and the second branch is the only thing to change.

AI-assisted: yes. Written with AI assistance and reviewed by me.

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 23, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of current head ef9fed3a2aada48ef4c87262c8b045f3eec6ce86. The revision addresses the earlier scope concern by leaving default-form strings containing RTL characters unchanged and limiting the new result to strings without the listed RTL ranges. The tests cover both branches, and the debt note now says the native result is unknown.

The remaining core behavior is still inferred: the only evidence is that Tekken passes Latin text to sceFontCreateWritingLine; that does not establish what the PS5's sceFontStringGetWritingForm returns for that string, nor that every non-RTL default-form string should return 0x12. The observed rejection is AnyPS5's behavior, not a console measurement. Under the repo's rule that unverified behavior stays unresolved rather than being guessed, please provide a native/API-contract result for the getter or leave its unknown default-form behavior unimplemented until measured. The exact-head regression currently asserts the proposed result but cannot establish it. Hosted policy checks pass; product jobs are path-skipped. This is an evidence blocker, not a request to close the PR.

@BunnyFl

BunnyFl commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Firmware result for the open question, from libSceFont.sprx of firmware 13.42, run natively: the module loaded in a small harness, with a text source made by its own sceFontTextSourceInit and a parser callback that hands over the code points.

sceFontStringGetWritingForm only returns the form byte stored in the string. The direction is decided earlier, in sceFontCreateString: for a default-form source (0x10, which sceFontTextSourceInit sets), the string gets the direction of its first character with a strong direction. That is 0x12 for left-to-right and 0x11 for right-to-left, and 0x12 when there is no such character. Explicit 0x11 and 0x12 sources keep their form. No SDK-version check is on this path.

text in a default-form source 13.42 reports this PR reports
ABC, U+4E00 U+4E8C, U+03B1 0x12 0x12
12 , empty string 0x12 0x12
Hebrew U+05E9 U+05DC, Arabic U+0627 U+0644 0x11 0x10
Syriac U+0710, Thaana U+0780, N'Ko U+07CA, U+FB1D, U+FE70 0x11 0x10
1 then Hebrew; Hebrew then A 0x11 0x10
A then Hebrew 0x12 0x10
U+200F (RLM) then A 0x11 0x10
U+200E (LRM) then Hebrew 0x12 0x10
U+202B (RLE) or U+202E (RLO) then A 0x12 0x10
U+2067 (RLI) Hebrew U+2069 (PDI) then A 0x12 0x10
U+2066 (LRI) A U+2069 (PDI) then Hebrew 0x11 0x10
U+2067 (RLI) Hebrew, no PDI 0x12 0x10

So the first strong character decides. RLM and LRM count as strong; RLE and RLO don't, and text between an isolate initiator and its PDI (or the end of the text) is skipped. Every case matches Unicode bidi rules P2 and P3. sceFontCreateWritingLine accepted each reported form.

So the PR's Latin result (0x12, the Tekken case) matches 13.42. For a string with a right-to-left character, 13.42 doesn't keep 0x10: it reports 0x11 or 0x12 from the first strong character.

One limit of the run: the harness has no real font, so for non-empty strings sceFontCreateString later fails at its glyph stage (0x80460005). The form byte is written before that stage, and no later code in the function writes it again. The values above are what sceFontStringGetWritingForm returns on the string object the library had built when it released it. The empty string ran to completion and returned 0x12 the normal way. Each case ran three times with the same results.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@klosixgaming-arch BunnyFl's 13.42 report answers the open question, and ef9fed3 doesn't match it yet. On firmware, sceFontCreateString decides the direction for a default-form (0x10) source: it stores 0x12 if the first strong-direction character is left-to-right, 0x11 if it is right-to-left, and 0x12 if there is none. sceFontStringGetWritingForm only returns the stored byte. The head does the opposite: CreateString copies 0x10 and the getter scans the text for any right-to-left code point.

Could you move the decision into CreateString, follow the report's LRM/RLM and isolate cases, keep explicit forms unchanged, and have the getter return the stored byte? The RTL/mixed/control test expectations should follow the report's table. In the debt note, please say what the report covers: non-empty strings were checked before a later glyph-stage failure, and only empty text completed, so this isn't full native RTL rendering.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
A string created from a text source in the default horizontal form (0x10)
reported 0x10. TEKKEN: DARK RESURRECTION (PPSA31371) passes the reported form
to sceFontCreateWritingLine, which only accepts 0x11 and 0x12, so the call
failed and the layout width was 0.

On firmware 13.42 sceFontCreateString decides the direction for a default-form
source and sceFontStringGetWritingForm returns the stored form. The string
gets 0x12 when its first strong character is left to right, 0x11 when it is
right to left, and 0x12 when it has none. Left-to-right and right-to-left marks
count as strong, embeddings and overrides do not, and text between an isolate
initiator and its PDI is skipped. Explicit 0x11 and 0x12 sources keep their
form.

The test follows the table reported on the pull request. Which characters are
strong is decided by Unicode block ranges here, not by the full bidi class
tables.
@klosixgaming-arch klosixgaming-arch changed the title fix(libSceFont): report a default string without right-to-left text as left to right fix(libSceFont): resolve a default string direction at creation Oct 25, 2026
@klosixgaming-arch
klosixgaming-arch force-pushed the fix/font-writing-line-horizontal branch from ef9fed3 to 0e46a0c Compare October 25, 2026 00:21
@klosixgaming-arch

Copy link
Copy Markdown
Contributor Author

@BunnyFl thank you, that is exactly the measurement this PR was missing. @oneandonlydean you were right that the head did the opposite of the firmware.

New head 0e46a0c497, rebased onto current main:

  • The decision moved into sceFontCreateString: a default-form (0x10) source gets 0x12 when the first strong character is left to right, 0x11 when it is right to left, and 0x12 when there is none. The getter returns the stored form. Explicit 0x11 and 0x12 sources keep their form.
  • LRM and RLM count as strong, embeddings and overrides (RLE, RLO) do not, and text between an isolate initiator and its PDI, or the end of the text, is skipped.
  • GuestFont.cpp now has the report's rows that can be built from code points (Latin, CJK, Greek, digits and a space, empty, Hebrew, Arabic, Syriac, Thaana, N'Ko, U+FB1D, U+FE70, a digit then Hebrew, Hebrew then A, A then Hebrew, RLM then A, LRM then Hebrew, RLE then A, RLO then A, the two isolate cases, an isolate with no PDI), plus explicit 0x11 and 0x12 sources. guest_font and guest_font_writing_line pass.
  • The debt note says what the report covers: non-empty strings were checked before a later glyph-stage failure and only empty text completed, so this is not full native right-to-left rendering. It also says that which characters are strong is decided here by Unicode block ranges, not the full bidi class tables.

AI-assisted: yes. Written with AI assistance and reviewed by me.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@oneandonlydean
oneandonlydean merged commit 6bc12fc into boykopovar:main Oct 25, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs prx unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants