feat(libSceFreeTypeOt): implement the FT_Vector polar calls, FT_Outline_Transform and FT_Outline_Embolden #16122

Merged
noamroger merged 5 commits from upstream-pr/16122 into main 2026-11-15 04:48:57 +00:00
noamroger commented 2026-11-05 17:51:37 +00:00 (Migrated from github.com)

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


What

libSceFreeTypeOt exports seven sceFreeTypeOtUnknown_* stubs whose NIDs are FreeType vector and outline calls (checked with tools/nid_names.py --name): 1jmC2QcpRl0 FT_Vector_Length, HMcNe70D9TI FT_Vector_Polarize, 2rmvbvOCyjY FT_Vector_From_Polar, 6wJwUIVwAxg FT_Vector_Rotate, 0Lv6K1d47jg FT_Outline_Transform, l6Cf9rb9fZQ FT_Outline_Embolden and BgUMBGvhATU FT_Outline_EmboldenXY. This PR ports them and removes the seven stubs, in three commits.

  • They follow FreeType 2.4.11 (c6a66b49e64e), the version FT_Library_Version reported on a console in #15865. 2.4.12 rewrote the CORDIC (constants, 29-bit normalization, rounding) and the emboldening (normalized vectors, shifted orientation area), so the version matters for every result here.
  • New src/Polar.cpp (CORDIC from fttrigon.c) and src/OutlineTransform.cpp (ftoutln.c), on the existing LP64 GuestVector, GuestMatrix and GuestOutline layouts. Counts and contour ends are read as signed short, as in 2.4.11.
  • The CORDIC downscale adds 1 when FT_LONG64 is defined and not in the 32-bit build the stock configuration selects under __STDC__; results that depend on that throw, the same rule as the module's existing FT_MulDiv_No_Round. Components above 32 bits, FT_MulFix / FT_MulDiv inputs where the two builds can disagree, signed overflow, contour ends outside the points and null pointers that 2.4.11 dereferences also throw, before anything is written.
  • Turns beyond ±90° are reduced by whole half turns instead of looping, so a huge angle returns at once with the same result.
  • Emboldening uses the 2.4.11 orientation internally, not the exported 2.13.3-based FT_Outline_Get_Orientation.
  • Two debt entries list these limits; the Unknown counter goes from 61 to 54.

Tested

Linux x86-64, GCC 13, full build. The new guest_freetype_ot_polar and guest_freetype_ot_outline_transform tests cover lengths, polar angles, rotations in every quadrant, whole-turn reduction, TrueType and PostScript contours, separate X/Y strengths, nested contours, a sharp corner, the Invalid_Argument cases, and that every throwing case leaves its outputs untouched. Expected values come from FreeType 2.4.11 (tag VER-2-4-11) compiled on the same machine. Outside the repository, a differential run fed 3 000 000 random vectors and 400 000 random outlines to this code and to that FreeType build, once in the default 32-bit mode and once with FT_CONFIG_OPTION_FORCE_INT64: every non-throwing result matches both builds exactly, and no throwing case writes anything. The 10 guest_freetype_ot*, guest_freetype_corner and guest_freetype_stream* tests pass. tools/check_conventions.py --base origin/main passes. Not tested on a PS5.

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 (#10594 and #10600 implement these calls in libSceFreeType, a different module, and only rename the Ot stubs; #15687 renames other Ot stubs; textual overlap only in libSceFreeTypeOt Export.cpp, CMakeLists.txt and its debt file)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5176132054 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16122). Originally posted by [noamroger](https://github.com/noamroger) on 2026-11-05T17:51:37Z. --- ### What libSceFreeTypeOt exports seven `sceFreeTypeOtUnknown_*` stubs whose NIDs are FreeType vector and outline calls (checked with `tools/nid_names.py --name`): `1jmC2QcpRl0` FT_Vector_Length, `HMcNe70D9TI` FT_Vector_Polarize, `2rmvbvOCyjY` FT_Vector_From_Polar, `6wJwUIVwAxg` FT_Vector_Rotate, `0Lv6K1d47jg` FT_Outline_Transform, `l6Cf9rb9fZQ` FT_Outline_Embolden and `BgUMBGvhATU` FT_Outline_EmboldenXY. This PR ports them and removes the seven stubs, in three commits. - They follow FreeType **2.4.11** (`c6a66b49e64e`), the version `FT_Library_Version` reported on a console in #15865. 2.4.12 rewrote the CORDIC (constants, 29-bit normalization, rounding) and the emboldening (normalized vectors, shifted orientation area), so the version matters for every result here. - New `src/Polar.cpp` (CORDIC from `fttrigon.c`) and `src/OutlineTransform.cpp` (`ftoutln.c`), on the existing LP64 `GuestVector`, `GuestMatrix` and `GuestOutline` layouts. Counts and contour ends are read as signed `short`, as in 2.4.11. - The CORDIC downscale adds 1 when `FT_LONG64` is defined and not in the 32-bit build the stock configuration selects under `__STDC__`; results that depend on that throw, the same rule as the module's existing FT_MulDiv_No_Round. Components above 32 bits, FT_MulFix / FT_MulDiv inputs where the two builds can disagree, signed overflow, contour ends outside the points and null pointers that 2.4.11 dereferences also throw, before anything is written. - Turns beyond ±90° are reduced by whole half turns instead of looping, so a huge angle returns at once with the same result. - Emboldening uses the 2.4.11 orientation internally, not the exported 2.13.3-based `FT_Outline_Get_Orientation`. - Two debt entries list these limits; the Unknown counter goes from 61 to 54. ### Tested Linux x86-64, GCC 13, full build. The new `guest_freetype_ot_polar` and `guest_freetype_ot_outline_transform` tests cover lengths, polar angles, rotations in every quadrant, whole-turn reduction, TrueType and PostScript contours, separate X/Y strengths, nested contours, a sharp corner, the Invalid_Argument cases, and that every throwing case leaves its outputs untouched. Expected values come from FreeType 2.4.11 (tag VER-2-4-11) compiled on the same machine. Outside the repository, a differential run fed 3 000 000 random vectors and 400 000 random outlines to this code and to that FreeType build, once in the default 32-bit mode and once with `FT_CONFIG_OPTION_FORCE_INT64`: every non-throwing result matches both builds exactly, and no throwing case writes anything. The 10 `guest_freetype_ot*`, `guest_freetype_corner` and `guest_freetype_stream*` tests pass. `tools/check_conventions.py --base origin/main` passes. Not tested on a PS5. ### 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 (#10594 and #10600 implement these calls in libSceFreeType, a different module, and only rename the Ot stubs; #15687 renames other Ot stubs; textual overlap only in libSceFreeTypeOt Export.cpp, CMakeLists.txt and its debt file) - [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!16122
No description provided.