feat(font): implement writing lines #769

Merged
adriadam10 merged 1 commit from upstream-pr/769 into main 2026-10-06 01:13:28 +00:00
adriadam10 commented 2026-10-05 22:39:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T22:39:39Z.


What

Implements the libSceFont writing line: sceFontCreateWritingLine, sceFontDestroyWritingLine, sceFontWritingLineClear, sceFontWritingLineWritesOrder, sceFontWritingLineRefersRenderStep, sceFontWritingLineGetRenderMetrics. Astro's Playroom imports all six.

  • Behaviour follows KytyPS5 (src/libs/libFont.cpp), the only reference with a body (shadPS4 and prosper only return OK). Each written run is placed at the line's advance so far (y 0, no spacing or adjustment); the line advance is the sum of the run advances and the extent is the union of the run extents shifted by their pen position. RefersRenderStep returns the runs in order, then null, and starts over after a new run is written or the line is cleared. Destroying a null handle returns OK and the refer call returns null for a null line, as in KytyPS5.
  • Signatures and the SceFontWritingLineStep (0x40 bytes) / SceFontCreateWritingLineDetail (id 0x0FD5) layouts come from SharpProspero (SceFont.Engine.cs, SceFontStructs.cs). Writing form values are the SharpProspero ones Text.cpp already uses.
  • Exact or throw: only horizontal (0x10) and left-to-right (0x12) lines, writing attribute 0 and non-null run metrics are modelled. RTL lines, other attributes, a detail with another id, the metrics of an empty line (KytyPS5 returns placeholder values) and unknown or null handles throw: KytyPS5 returns -1 there and no reference gives the real error code.
  • Left throwing: sceFontWritingLineGetOrderingSpace (KytyPS5 returns head = tail = line advance: a placeholder) and sceFontGlyphDefineAttribute (its pair sceFontGlyphGetAttribute has no body anywhere).
  • TechnicalDebt: one line under Functional (what is modelled) and one under Unknown function info (SharpProspero layouts, unknown attribute).

#699 adds stubs right after the last block this PR removes from Unimplemented.cpp, so whichever merges second has a one-hunk conflict there.

Tested

Linux (GCC Release + the fast build). New guest_font_writing_line test: creates lines, writes three runs and checks every step field and the line metrics after each write, the restart after a write and after clear, a second LTR line, and every throwing path (bad form, detail id, attribute, null metrics, empty-line metrics, null/unknown/destroyed handles). It fails on main (the stubs throw). Each piece was checked to make the test fail when broken (12 mutations: pen position, extent shift, min/max, advance sum, orderer, cursor restart, clear, form/attribute/detail/empty checks, handle registry). guest_font still passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4751611910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/769). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-05T22:39:39Z. --- ### What Implements the libSceFont writing line: `sceFontCreateWritingLine`, `sceFontDestroyWritingLine`, `sceFontWritingLineClear`, `sceFontWritingLineWritesOrder`, `sceFontWritingLineRefersRenderStep`, `sceFontWritingLineGetRenderMetrics`. Astro's Playroom imports all six. - Behaviour follows KytyPS5 (`src/libs/libFont.cpp`), the only reference with a body (shadPS4 and prosper only return OK). Each written run is placed at the line's advance so far (`y` 0, no spacing or adjustment); the line advance is the sum of the run advances and the extent is the union of the run extents shifted by their pen position. `RefersRenderStep` returns the runs in order, then null, and starts over after a new run is written or the line is cleared. Destroying a null handle returns OK and the refer call returns null for a null line, as in KytyPS5. - Signatures and the `SceFontWritingLineStep` (0x40 bytes) / `SceFontCreateWritingLineDetail` (id `0x0FD5`) layouts come from SharpProspero (`SceFont.Engine.cs`, `SceFontStructs.cs`). Writing form values are the SharpProspero ones `Text.cpp` already uses. - Exact or throw: only horizontal (`0x10`) and left-to-right (`0x12`) lines, writing attribute 0 and non-null run metrics are modelled. RTL lines, other attributes, a detail with another id, the metrics of an empty line (KytyPS5 returns placeholder values) and unknown or null handles throw: KytyPS5 returns `-1` there and no reference gives the real error code. - Left throwing: `sceFontWritingLineGetOrderingSpace` (KytyPS5 returns head = tail = line advance: a placeholder) and `sceFontGlyphDefineAttribute` (its pair `sceFontGlyphGetAttribute` has no body anywhere). - TechnicalDebt: one line under Functional (what is modelled) and one under Unknown function info (SharpProspero layouts, unknown attribute). #699 adds stubs right after the last block this PR removes from `Unimplemented.cpp`, so whichever merges second has a one-hunk conflict there. ### Tested Linux (GCC Release + the fast build). New `guest_font_writing_line` test: creates lines, writes three runs and checks every step field and the line metrics after each write, the restart after a write and after clear, a second LTR line, and every throwing path (bad form, detail id, attribute, null metrics, empty-line metrics, null/unknown/destroyed handles). It fails on `main` (the stubs throw). Each piece was checked to make the test fail when broken (12 mutations: pen position, extent shift, min/max, advance sum, orderer, cursor restart, clear, form/attribute/detail/empty checks, handle registry). `guest_font` still passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-05 22:40:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T22:40:04Z.


Progress report (964dd3c → 83442e1)

📈 System libraries: 80.18% (+0.19%, +6 implemented functions)

✅ 6 implemented
Library Name
libSceFont sceFontCreateWritingLine
libSceFont sceFontDestroyWritingLine
libSceFont sceFontWritingLineClear
libSceFont sceFontWritingLineGetRenderMetrics
libSceFont sceFontWritingLineRefersRenderStep
libSceFont sceFontWritingLineWritesOrder
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6004637390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/769#issuecomment-6004637390). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-05T22:40:04Z. --- <!-- progress-report --> ### Progress report (964dd3c → 83442e1) 📈 **System libraries**: 80.18% (+0.19%, +6 implemented functions) <details> <summary>✅ 6 implemented</summary> | Library | Name | | - | - | | libSceFont | `sceFontCreateWritingLine` | | libSceFont | `sceFontDestroyWritingLine` | | libSceFont | `sceFontWritingLineClear` | | libSceFont | `sceFontWritingLineGetRenderMetrics` | | libSceFont | `sceFontWritingLineRefersRenderStep` | | libSceFont | `sceFontWritingLineWritesOrder` | </details>
adriadam10 commented 2026-10-05 23:32:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T23:32:36Z.


Rebased on main after the new sceFontGraphicsDrawupFillTexture*Object stubs in Unimplemented.cpp (conflict next to the removed WritingLine stubs; both kept). guest_font_writing_line passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6005475895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/769#issuecomment-6005475895). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-05T23:32:36Z. --- Rebased on main after the new `sceFontGraphicsDrawupFillTexture*Object` stubs in `Unimplemented.cpp` (conflict next to the removed WritingLine stubs; both kept). `guest_font_writing_line` passes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!769
No description provided.