feat(libSceFreeTypeOt): manage glyph slot bitmaps and implement FT_GlyphSlot_Own_Bitmap #16120

Merged
noamroger merged 2 commits from upstream-pr/16120 into main 2026-11-09 05:49:59 +00:00
noamroger commented 2026-11-05 17:50:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by noamroger on 2026-11-05T17:50:07Z.


What

Implements the glyph slot bitmap ownership calls of libSceFreeTypeOt, which were sceFreeTypeOtUnknown_* stubs: ft_glyphslot_alloc_bitmap (Ln9I6YfmYJU), ft_glyphslot_free_bitmap (7cVMwHmN308), ft_glyphslot_set_bitmap (AEU2tkjdZ2w) and FT_GlyphSlot_Own_Bitmap (nSIux4OQyJM). The first three follow FreeType 2.4.12 src/base/ftobjs.c, FT_GlyphSlot_Own_Bitmap follows 2.4.12 src/base/ftbitmap.c (with the FT_Bitmap_Copy it calls). They work on the existing LP64 GuestGlyphSlotRec, read the FT_GLYPH_OWN_BITMAP flag at offset 8 of the slot's internal record (FT_Slot_InternalRec, 72 bytes, layout checked with static_assert), and allocate through the Ot ft_mem_* calls, so the guest memory callbacks see the same allocations as in FreeType (face memory for the slot calls, library memory for Own_Bitmap).

2.4.12 is the version already used for the other Ot exports (FT_Sqrt32, FT_Property_Set date it to 2.4.11-2.4.12); #15865 reports FT_Library_Version 2.4.11 measured on a console, and these four functions, FT_Bitmap_Copy and FT_Slot_InternalRec are identical in 2.4.11 (c6a66b49e64e). Inputs where that source dereferences a null pointer, the int overflow of |pitch| * rows in FT_Bitmap_Copy and a pitch of INT_MIN throw; this and the remaining unverified points (console prototypes, the FT_ULong size passed as FT_Long) are recorded in docs/dev/debt/libSceFreeTypeOt.md. The sceFreeTypeOtUnknown_* count there goes from 61 to 57.

#15687 only renames these four stubs and #10591 implements FT_GlyphSlot_Own_Bitmap in libSceFreeType (another module) while renaming the Ot stub, so both overlap this PR in text only. FT_GlyphSlot_Oblique and FT_GlyphSlot_Embolden stay stubbed and will come in a follow-up PR.

Tested

Linux (Ubuntu 24.04, g++ 13), full CMake build of the FreeTypeOt targets: the new guest_freetype_ot_glyph_slot test and the existing guest_freetype_ot* and guest_freetype_corner tests pass (ctest -R guest_freetype). The new test was also run with -fsanitize=address,undefined. It covers: allocation into a slot that borrows its buffer (no free, owned flag set, other flags kept, cleared buffer), reallocation of an owned buffer (old block freed), 0 bytes (null buffer, flag kept), a size above LONG_MAX (Invalid_Argument) and a failing allocator (Out_Of_Memory, flag stays set as in FreeType); free_bitmap of an owned buffer, of a borrowed one and without internal record; set_bitmap over owned and borrowed buffers; Own_Bitmap copying a negative-pitch bitmap with its geometry and palette, leaving an owned bitmap and an outline slot alone, accepting a null buffer, and leaving the slot unchanged on Out_Of_Memory and on a negative int size. tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py cannot reach the GitHub API from my environment; I checked by NID that no open pull request implements Ln9I6YfmYJU, 7cVMwHmN308, AEU2tkjdZ2w or nSIux4OQyJM in libSceFreeTypeOt.

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

Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5176112950 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16120). Originally posted by [noamroger](https://github.com/noamroger) on 2026-11-05T17:50:07Z. --- ### What Implements the glyph slot bitmap ownership calls of libSceFreeTypeOt, which were `sceFreeTypeOtUnknown_*` stubs: `ft_glyphslot_alloc_bitmap` (`Ln9I6YfmYJU`), `ft_glyphslot_free_bitmap` (`7cVMwHmN308`), `ft_glyphslot_set_bitmap` (`AEU2tkjdZ2w`) and `FT_GlyphSlot_Own_Bitmap` (`nSIux4OQyJM`). The first three follow FreeType 2.4.12 `src/base/ftobjs.c`, `FT_GlyphSlot_Own_Bitmap` follows 2.4.12 `src/base/ftbitmap.c` (with the `FT_Bitmap_Copy` it calls). They work on the existing LP64 `GuestGlyphSlotRec`, read the `FT_GLYPH_OWN_BITMAP` flag at offset 8 of the slot's internal record (`FT_Slot_InternalRec`, 72 bytes, layout checked with `static_assert`), and allocate through the Ot `ft_mem_*` calls, so the guest memory callbacks see the same allocations as in FreeType (face memory for the slot calls, library memory for `Own_Bitmap`). 2.4.12 is the version already used for the other Ot exports (`FT_Sqrt32`, `FT_Property_Set` date it to 2.4.11-2.4.12); #15865 reports `FT_Library_Version` 2.4.11 measured on a console, and these four functions, `FT_Bitmap_Copy` and `FT_Slot_InternalRec` are identical in 2.4.11 (`c6a66b49e64e`). Inputs where that source dereferences a null pointer, the `int` overflow of `|pitch| * rows` in `FT_Bitmap_Copy` and a pitch of `INT_MIN` throw; this and the remaining unverified points (console prototypes, the `FT_ULong` size passed as `FT_Long`) are recorded in `docs/dev/debt/libSceFreeTypeOt.md`. The `sceFreeTypeOtUnknown_*` count there goes from 61 to 57. #15687 only renames these four stubs and #10591 implements `FT_GlyphSlot_Own_Bitmap` in libSceFreeType (another module) while renaming the Ot stub, so both overlap this PR in text only. `FT_GlyphSlot_Oblique` and `FT_GlyphSlot_Embolden` stay stubbed and will come in a follow-up PR. ### Tested Linux (Ubuntu 24.04, g++ 13), full CMake build of the FreeTypeOt targets: the new `guest_freetype_ot_glyph_slot` test and the existing `guest_freetype_ot*` and `guest_freetype_corner` tests pass (`ctest -R guest_freetype`). The new test was also run with `-fsanitize=address,undefined`. It covers: allocation into a slot that borrows its buffer (no free, owned flag set, other flags kept, cleared buffer), reallocation of an owned buffer (old block freed), 0 bytes (null buffer, flag kept), a size above `LONG_MAX` (Invalid_Argument) and a failing allocator (Out_Of_Memory, flag stays set as in FreeType); `free_bitmap` of an owned buffer, of a borrowed one and without internal record; `set_bitmap` over owned and borrowed buffers; `Own_Bitmap` copying a negative-pitch bitmap with its geometry and palette, leaving an owned bitmap and an outline slot alone, accepting a null buffer, and leaving the slot unchanged on Out_Of_Memory and on a negative `int` size. `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` cannot reach the GitHub API from my environment; I checked by NID that no open pull request implements `Ln9I6YfmYJU`, `7cVMwHmN308`, `AEU2tkjdZ2w` or `nSIux4OQyJM` in libSceFreeTypeOt. ### 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 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 Generated with [Claude Code](https://claude.com/claude-code)
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!16120
No description provided.