feat(libSceFreeType): implement FT_Get_Sfnt_Table and FT_Outline_Get_Bitmap #10601

Merged
MarcZX10 merged 13 commits from upstream-pr/10601 into main 2026-11-06 19:35:08 +00:00
MarcZX10 commented 2026-10-24 12:04:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:04:28Z.


What

Adds FT_Get_Sfnt_Table and FT_Outline_Get_Bitmap to libSceFreeType, following the bundled FreeType 2.13.3 (ftobjs.c, ftoutln.c).

FT_Get_Sfnt_Table returns the native table pointer unchanged, so the guest reads the native TT_* structures. Their public layouts match the console's LP64 ones only with a 64-bit FT_Long, so a host with a 32-bit FT_Long (Windows) throws for a registered face instead of returning a mismatched layout.

FT_Outline_Get_Bitmap runs the native rasteriser on a native copy of the guest outline and renders into the guest bitmap buffer in place; it follows the native argument checks and error codes, and a guest coordinate outside the host FT_Pos range throws (Windows only).

Console signatures and errors are unverified; the debt entries say so.

Commits: for each function in turn, the implementation, its test and its debt entry.

Tested

Linux x86-64, GCC, full CMake build (Ninja, Release). guest_freetype_sfnt_table compares the returned tables of a TrueType fixture (head, hhea, maxp, OS/2, post), absent tables (vhea, PCLT), out-of-range tags and a BDF face with a native oracle, byte for byte, and covers null and unregistered faces. guest_freetype_outline_bitmap renders a square, a triangle and a curved contour into gray and mono bitmaps through both paths and compares the pixels, and compares the error codes for an unsupported pixel mode, a null bitmap, a null outline and a null library. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran both tests with that check disabled in a local, uncommitted edit; both exit 0. Windows was not run. tools/check_conventions.py and git diff --check pass. No title or GPU involved.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4995225217 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10601). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:04:28Z. --- ### What Adds `FT_Get_Sfnt_Table` and `FT_Outline_Get_Bitmap` to libSceFreeType, following the bundled FreeType 2.13.3 ([ftobjs.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftobjs.c), [ftoutln.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftoutln.c)). `FT_Get_Sfnt_Table` returns the native table pointer unchanged, so the guest reads the native `TT_*` structures. Their public layouts match the console's LP64 ones only with a 64-bit `FT_Long`, so a host with a 32-bit `FT_Long` (Windows) throws for a registered face instead of returning a mismatched layout. `FT_Outline_Get_Bitmap` runs the native rasteriser on a native copy of the guest outline and renders into the guest bitmap buffer in place; it follows the native argument checks and error codes, and a guest coordinate outside the host `FT_Pos` range throws (Windows only). Console signatures and errors are unverified; the debt entries say so. Commits: for each function in turn, the implementation, its test and its debt entry. ### Tested Linux x86-64, GCC, full CMake build (Ninja, Release). `guest_freetype_sfnt_table` compares the returned tables of a TrueType fixture (`head`, `hhea`, `maxp`, `OS/2`, `post`), absent tables (`vhea`, `PCLT`), out-of-range tags and a BDF face with a native oracle, byte for byte, and covers null and unregistered faces. `guest_freetype_outline_bitmap` renders a square, a triangle and a curved contour into gray and mono bitmaps through both paths and compares the pixels, and compares the error codes for an unsupported pixel mode, a null bitmap, a null outline and a null library. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran both tests with that check disabled in a local, uncommitted edit; both exit 0. Windows was not run. `tools/check_conventions.py` and `git diff --check` pass. No title or GPU involved. ### Checklist - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [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!10601
No description provided.