feat(font): open system font sets from a font directory #461

Merged
oneandonlydean merged 1 commit from upstream-pr/461 into main 2026-10-05 21:30:45 +00:00
oneandonlydean commented 2026-10-03 13:52:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-03T13:52:14Z.


What

sceFontOpenFontSet fails for every set type, so titles draw no text in the system fonts. In PPSA21564 that is the copyright line on the title screen, the credits and the button guides.

It now loads the set's primary font file from a font directory and opens it like a font file the title passes in:

  • Where: ANYPS5_SYSTEM_FONTS if set (it must be a directory, otherwise the open throws), else anyps5-fonts/ beside the generated executable.
  • What: the console's own file for the set under its own name first (SST-Roman.otf, SST-Bold.otf, SSTJpPro-Regular.otf, DFHEI5-SONY.ttf, ...), then an openly licensed substitute when that file is absent: Noto Sans for Latin and Vietnamese (NotoSans-{Light,Regular,Medium,Bold}.ttf and their italics), Noto Sans Mono for the typewriter sets, Noto Sans Thai for Thai, and Noto Sans CJK (NotoSansCJK-{Light,Regular,Medium,Bold}.ttc; the JP face for Japanese, SC for Chinese GB).
  • Without either: the open fails with SCE_FONT_ERROR_FONT_OPEN_FAILED, as now, and the title shows no text in that font.
  • The PS5-only JG2 set types (0x1A......) are accepted; their console file names are unknown, so they use the SSTJpPro files.

No font files are added to the repository; the user provides them. The file list is in docs/user/USAGE.md (Runtime layout, System fonts), and the gaps are in TechnicalDebt.md: only the set's primary file is opened, so characters the console takes from the set's other files are reported as unsupported glyphs, and a substitute's metrics differ from the console's.

System font handles use the system font context. Their faces are loaded by FreeType in host memory: about 1 MiB per CJK face does not fit the font memory a title sizes for the console's fonts, and sceFontCreateRenderer then failed with ALLOCATION_FAILED. Handles of the same font file share one copy of its bytes.

Why Noto

The Noto set is under the SIL Open Font License and covers every script the system sets need (Latin, Vietnamese, Thai, Japanese, Chinese) in the four weights they use. It is not the system font, so widths, line height and wrapping differ from the console, as the technical debt entry says. I also tried Source Sans 3, which is close for Latin text but has no Thai or CJK.

Title screen of PPSA21564, left: PS5 (phone photo), middle: Source Sans 3, right: Noto Sans. The copyright line along the bottom is the system font text:

PS5, Source Sans 3 and Noto Sans on the PPSA21564 title screen

Tested

  • Linux (CachyOS, x86-64): full build with BUILD_TESTING=ON and ctest pass (318/318), rebased on main 2707b3a3c.
  • New guest_system_font test (core/libs/tests/GuestSystemFont.cpp, generated TrueType fonts in a temporary font directory): an empty directory gives FONT_OPEN_FAILED and an unknown set type NO_SUPPORT_FONTSET; a missing ANYPS5_SYSTEM_FONTS directory throws; the console file is preferred, and once it is removed the substitute opens while an open handle keeps its face; each set type picks its family and weight (light, italic, Thai, Vietnamese, JG2 Japanese from the CJK file); a set with no file fails to open; glyph metrics and the horizontal layout come from the loaded face; font instances and memory fonts keep working; everything allocated is freed. Against main's library it fails (the missing directory does not throw, and no set opens).
  • PPSA21564: the title-screen copyright line, credits and button guides draw (image above); on my integration branch since 2026-10-03 through repeated passes of my visual regression check (checkpoint frames, flicker, shimmer, video tearing, FPS).
  • The only other open PR touching libSceFont is #699, which adds two unrelated stubs to Unimplemented.cpp.

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:4727050441 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/461). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-03T13:52:14Z. --- ### What `sceFontOpenFontSet` fails for every set type, so titles draw no text in the system fonts. In PPSA21564 that is the copyright line on the title screen, the credits and the button guides. It now loads the set's primary font file from a font directory and opens it like a font file the title passes in: - **Where:** `ANYPS5_SYSTEM_FONTS` if set (it must be a directory, otherwise the open throws), else `anyps5-fonts/` beside the generated executable. - **What:** the console's own file for the set under its own name first (`SST-Roman.otf`, `SST-Bold.otf`, `SSTJpPro-Regular.otf`, `DFHEI5-SONY.ttf`, ...), then an openly licensed substitute when that file is absent: Noto Sans for Latin and Vietnamese (`NotoSans-{Light,Regular,Medium,Bold}.ttf` and their italics), Noto Sans Mono for the typewriter sets, Noto Sans Thai for Thai, and Noto Sans CJK (`NotoSansCJK-{Light,Regular,Medium,Bold}.ttc`; the JP face for Japanese, SC for Chinese GB). - **Without either:** the open fails with `SCE_FONT_ERROR_FONT_OPEN_FAILED`, as now, and the title shows no text in that font. - The PS5-only JG2 set types (`0x1A......`) are accepted; their console file names are unknown, so they use the SSTJpPro files. No font files are added to the repository; the user provides them. The file list is in `docs/user/USAGE.md` (Runtime layout, System fonts), and the gaps are in `TechnicalDebt.md`: only the set's primary file is opened, so characters the console takes from the set's other files are reported as unsupported glyphs, and a substitute's metrics differ from the console's. System font handles use the system font context. Their faces are loaded by FreeType in host memory: about 1 MiB per CJK face does not fit the font memory a title sizes for the console's fonts, and `sceFontCreateRenderer` then failed with `ALLOCATION_FAILED`. Handles of the same font file share one copy of its bytes. ### Why Noto The Noto set is under the SIL Open Font License and covers every script the system sets need (Latin, Vietnamese, Thai, Japanese, Chinese) in the four weights they use. It is not the system font, so widths, line height and wrapping differ from the console, as the technical debt entry says. I also tried Source Sans 3, which is close for Latin text but has no Thai or CJK. Title screen of PPSA21564, left: PS5 (phone photo), middle: Source Sans 3, right: Noto Sans. The copyright line along the bottom is the system font text: ![PS5, Source Sans 3 and Noto Sans on the PPSA21564 title screen](https://raw.githubusercontent.com/oneandonlydean/AnyPS5/b49fca206a5ab9b5ab969d259aa89c32f55d1f6b/font-title-ps5-sourcesans3-notosans.jpg) ### Tested - Linux (CachyOS, x86-64): full build with `BUILD_TESTING=ON` and `ctest` pass (318/318), rebased on `main` 2707b3a3c. - New `guest_system_font` test (`core/libs/tests/GuestSystemFont.cpp`, generated TrueType fonts in a temporary font directory): an empty directory gives `FONT_OPEN_FAILED` and an unknown set type `NO_SUPPORT_FONTSET`; a missing `ANYPS5_SYSTEM_FONTS` directory throws; the console file is preferred, and once it is removed the substitute opens while an open handle keeps its face; each set type picks its family and weight (light, italic, Thai, Vietnamese, JG2 Japanese from the CJK file); a set with no file fails to open; glyph metrics and the horizontal layout come from the loaded face; font instances and memory fonts keep working; everything allocated is freed. Against `main`'s library it fails (the missing directory does not throw, and no set opens). - PPSA21564: the title-screen copyright line, credits and button guides draw (image above); on my integration branch since 2026-10-03 through repeated passes of my visual regression check (checkpoint frames, flicker, shimmer, video tearing, FPS). - The only other open PR touching libSceFont is #699, which adds two unrelated stubs to `Unimplemented.cpp`. ### 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
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!461
No description provided.