feat(libSceFreeType): implement FT_Get_PS_Font_Value and FT_Attach_File #10616

Merged
MarcZX10 merged 12 commits from upstream-pr/10616 into main 2026-11-07 20:15:14 +00:00
MarcZX10 commented 2026-10-24 13:07:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T13:07:29Z.


What

Adds FT_Get_PS_Font_Value and FT_Attach_File to libSceFreeType, following the bundled FreeType 2.13.3 (ftobjs.c).

FT_Get_PS_Font_Value queries the Type 1 dictionary through the native call and copies the value into the guest buffer only when it fits, as natively; its value sizes follow the native FT_Long, so a host with a 32-bit one (Windows) throws for a registered face.

FT_Attach_File resolves and reads the guest path like FT_New_Face and attaches the bytes through a memory stream, so the native call never sees a guest path. The native argument checks, the unsupported-driver error and the attached metrics (kerning from an AFM file) are the native ones. FT_Attach_Stream is left out because it takes a guest FT_Open_Args block.

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

Commits: for each function in turn (FT_Get_PS_Font_Value, then FT_Attach_File), the implementation, its test and its debt entry. The test commit of the first function adds Type1Fixture.hpp, which builds a minimal Type 1 font (an encrypted private dictionary with two glyphs) and a matching AFM file at run time.

Tested

Linux x86-64, GCC, full CMake build (Ninja, Release). guest_freetype_ps_font_value compares every dictionary key (and a few beyond the last) for two indices and several buffer lengths, byte for byte, plus the size-only query, a TrueType face, and null and unregistered faces. guest_freetype_attach_file writes the AFM file under a temporary app0, attaches it to a Type 1 face through the guest and through the native API, compares the error codes and checks the kerning pair appears (-50) and stays after a second attach; it also covers a missing file, a null path, a TrueType face, and null and unregistered faces. 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. The public header audit (test_public_headers.py --audit-only) and all 64 public_headers_compile_* batches pass. Windows was not run, and its coverage is limited: a MinGW host has a 32-bit FT_Long, so FT_Get_PS_Font_Value throws for a registered face there and the byte-for-byte comparison against the native call only runs where FT_Long is 64-bit; on Windows only the null and unregistered face checks of that test and the FT_Attach_File test apply. 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:4995649254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10616). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T13:07:29Z. --- ### What Adds `FT_Get_PS_Font_Value` and `FT_Attach_File` to libSceFreeType, following the bundled FreeType 2.13.3 ([ftobjs.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftobjs.c)). `FT_Get_PS_Font_Value` queries the Type 1 dictionary through the native call and copies the value into the guest buffer only when it fits, as natively; its value sizes follow the native `FT_Long`, so a host with a 32-bit one (Windows) throws for a registered face. `FT_Attach_File` resolves and reads the guest path like `FT_New_Face` and attaches the bytes through a memory stream, so the native call never sees a guest path. The native argument checks, the unsupported-driver error and the attached metrics (kerning from an AFM file) are the native ones. `FT_Attach_Stream` is left out because it takes a guest `FT_Open_Args` block. Console signatures and errors are unverified; the debt entries say so. Commits: for each function in turn (`FT_Get_PS_Font_Value`, then `FT_Attach_File`), the implementation, its test and its debt entry. The test commit of the first function adds `Type1Fixture.hpp`, which builds a minimal Type 1 font (an encrypted private dictionary with two glyphs) and a matching AFM file at run time. ### Tested Linux x86-64, GCC, full CMake build (Ninja, Release). `guest_freetype_ps_font_value` compares every dictionary key (and a few beyond the last) for two indices and several buffer lengths, byte for byte, plus the size-only query, a TrueType face, and null and unregistered faces. `guest_freetype_attach_file` writes the AFM file under a temporary `app0`, attaches it to a Type 1 face through the guest and through the native API, compares the error codes and checks the kerning pair appears (-50) and stays after a second attach; it also covers a missing file, a null path, a TrueType face, and null and unregistered faces. 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. The public header audit (`test_public_headers.py --audit-only`) and all 64 `public_headers_compile_*` batches pass. Windows was not run, and its coverage is limited: a MinGW host has a 32-bit `FT_Long`, so `FT_Get_PS_Font_Value` throws for a registered face there and the byte-for-byte comparison against the native call only runs where `FT_Long` is 64-bit; on Windows only the null and unregistered face checks of that test and the `FT_Attach_File` test apply. `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!10616
No description provided.