Skip to content

feat(libSceFreeType): implement outline orientation - #9538

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
Ondra97:codex/feat-freetype-outline-orientation
Oct 23, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
Ondra97:codex/feat-freetype-outline-orientation

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

What

Implement FT_Outline_Get_Orientation (weVsBCT+TTQ) for the existing LP64 guest outline. Compute the bounding box, apply the bundled FreeType coordinate limits and normalization shifts, and integrate the control-point polygons with a signed 64-bit area accumulator. The query leaves points, tags, contours, flags and descriptor pointers unchanged.

The name/NID matches the pinned PS5 3.20 inventory. Behavior follows bundled FreeType 2.13.3 ftoutln.c and the bridge's existing 64-bit coordinates and unsigned counts. Console ABI/version and large-outline equivalence remain unverified and are recorded in debt.

Delegating directly to the Windows native routine would use its 32-bit FT_Pos area: two equally oriented 32767-by-32767 rectangles produce a negative wrapped sum there, while the LP64 sum is positive. The adapter preserves the LP64 result. After the reference normalization, each edge contribution is bounded by 2^31; at most 65,535 points fit comfortably in the 64-bit accumulator. Valid outline arrays and contour indices remain the caller's precondition, as in native FreeType.

Merge after #9530 for the shared include/debt insertions; #9530 already declares #9309. These are merge-order dependencies, not shared implementations or runtime requirements. No title unblock or performance improvement is claimed.

Tested

Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, bundled dependencies. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER. Font rendering is on the CPU; GPUs tested: n/a.

Base: a6dcea9279b53b3a39c13695eac66f7c8b5b503c. Head: 29eab421d93bf3383b7385940d9f5e21e731867b.

  • The new behavioral regression cannot link against unchanged base because the guest orientation export is absent. This is a missing-feature baseline, not an observed game failure.
  • cmake --build build --parallel 10: full all-target integration build passed with the previously reviewed temporary test-only test(agc): align the array window test's texels at run time #8310 source at ca55e46f98ad85861dd7567abad0c028274daca1. That source was restored byte-for-byte and is excluded from this PR. This is an overlay-qualified build, not a standalone clean-main all-target pass.
  • After restoration, cmake --build build --target libs guest_freetype_tests guest_freetype_charmap_tests patched_libraries_tests --parallel 8: passed with submitted sources.
  • ctest --test-dir build -R '^(guest_freetype(_charmap)?|patched_libraries)$' -V: 3/3 passed, no skips, 0.26 s. 360 patched libraries loaded, 0 failed.
  • The existing guest_freetype test now checks 1,555 polygon cases, null/empty/degenerate inputs, holes and cancellation between contours, reversal/translation properties, coordinate-limit boundaries, normalization collapse, 64-bit extreme coordinates, 65,535 points and 65,535 contours, descriptor/input preservation, and 2 subsequently rendered glyphs with matching native bitmap pixels and bearings.
  • Native FreeType comparisons cover cases where its host-width arithmetic is applicable. Small random polygons also use an independent classic shoelace-area oracle. LP64 overflow cases use known geometric results; the regression confirms the different native Windows result for the two-rectangle case. No native LP64 execution is claimed.
  • Packaged NID weVsBCT+TTQ is present.
  • Strict g++ -std=c++20 -Wall -Wextra -Werror -fno-asynchronous-unwind-tables -fsyntax-only -Icore/libs -I3rdparty/freetype/include core/libs/prx/libSceFreeType/Export.cpp core/libs/tests/GuestFreeType.cpp: passed.
  • python tools/check_conventions.py --base origin/main, python tools/check_test_registration.py build and git diff origin/main HEAD --check: passed. Registration audit: 1,167 executables, none unregistered.

No title, PS5 hardware, Linux or macOS runtime was tested.

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: feat(libSceFreeType): implement FT_Get_Gasp #9530
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Progress report (2e0c925 → 8c4a455)

➖ System libraries: 44.81% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceFreeType FT_Outline_Get_Orientation_nid_postfix

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the adapter against the pinned FreeType 2.13.3 implementation and the current GuestOutline representation. The collapsed/large-coordinate guards, independent x/y normalization shifts, contour closure, winding-sign mapping and degenerate result match the source algorithm; using a 64-bit accumulator addresses the LP64 result the PR documents. The expanded tests cover native-comparable inputs, geometry properties, contour cancellation, coordinate limits and rendered glyph output without mutating the guest outline.

The PR reports 1,555 polygon cases, two rendered-glyph comparisons, a strict syntax check, the focused 3/3 CTest selection and a 360-library patching check. Those runs are author-reported; I did not rerun a local build. Hosted eligibility, conventions, intake, labels and report checks pass; product jobs are skipped. The #9530 overlap is explicitly ordered in Depends on, and its author confirmed this PR should land afterward.

Approved.

@Ondra97

Ondra97 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

I am preparing the three FT_Get_CID_* metadata queries as an independent follow-up. The shared insertions in Export.cpp and the debt file will go after #9538, which already orders #9530 and #9309. I will declare that merge-order dependency and rebase those insertions after this PR merges. No changes to this branch are needed.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the current head after #9545 declared this PR as its shared-insertion predecessor. The author has updated the branch to current main, the stated order is represented in Depends on, and the existing review of the outline algorithm and tests remains applicable. Hosted eligibility, conventions, intake, labels and report checks pass; platform builds are skipped by path policy. The Windows tests are author-reported; I did not run a local build.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked the unchanged implementation and its #9530 merge-order prerequisite. The adapter follows bundled FreeType’s coordinate bounding and normalization logic while retaining the LP64 accumulator; the tests cover degenerate, nested, cancellation, boundary and large-coordinate outlines plus rendered glyphs. Eligibility, conventions, intake, labels and report checks pass; build jobs were skipped. I did not run local tests. Approval stands with #9530 first as declared.

@fogydes

fogydes commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Reviewed; verified the implementation against the pinned ftoutln.c orientation routine. Each branch is a faithful port: null/empty → TRUETYPE and the degenerate-bounds box check match the source's opening; the ±0x1000000 range gate is taken verbatim; the shift math is the source's FT_MSB(abs) - 14 recomputed as bit_width(|x|) - 15 (same exponent, sign-safe with the unsigned OR of the two absolute extremes); the (y - prevY) * (x + prevX) accumulation runs the same order and sign — so the result is POSTSCRIPT for a positive signed area, TRUETYPE for negative, NONE for zero, exactly as freetype maps it. The deliberate divergence the body documents (64-bit accumulator instead of a 32-bit FT_Pos wrap) is the right call on LP64 and is covered by the two-extreme-rectangle special case in the tests. Guest buffers stay untouched (const query, no adapter state), the debt entry links the pinned source and scopes the unverified console ABI part, and the tests cover degenerate outlines, boundary coordinates both inside and outside the range gate, the LP64 extemes, random polygons cross-checked against an independent shoelace oracle, and rendered glyphs with the x-reflection flipping orientation. Nothing invented anywhere in the answer space.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9462 FT_Outline_Get_Orientation
PR 9922 FT_Outline_Get_Orientation

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 8286 docs/dev/debt/libSceFreeType.md
PR 9802 docs/dev/debt/libSceFreeType.md
PR 9848 docs/dev/debt/libSceFreeType.md
PR 9924 docs/dev/debt/libSceFreeType.md
PR 9933 docs/dev/debt/libSceFreeType.md

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 23, 2026
@oneandonlydean
oneandonlydean merged commit 0291694 into boykopovar:main Oct 23, 2026
10 checks passed
@Ondra97
Ondra97 deleted the codex/feat-freetype-outline-orientation branch October 25, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants