fix(libcairo): propagate FreeType error font faces #27755

Merged
bipinkrish merged 1 commit from upstream-pr/27755 into main 2026-12-04 06:52:35 +00:00
bipinkrish commented 2026-11-27 08:06:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bipinkrish on 2026-11-27T08:06:26Z.


What

Carry the pinned Cairo backend’s file-not-found and no-memory font faces through the guest font-face bridge. A missing file in a Fontconfig pattern now gives cairo_scaled_font_create an error font and sets the same error on a healthy context passed to cairo_set_font_face. The error objects retain their guest identity and require no allocation.

Tested

On Ubuntu 24.04.4 x86-64, the new missing-file regression failed on the base commit with cairo_scaled_font_create not implemented. All 41 tests in ctest --test-dir build -R '^guest_cairo_' --output-on-failure passed with the change. The test checks the scaled font status, the context error through its target, and preservation of the first context error. A separate program using Cairo 1.18.0 returned CAIRO_STATUS_FILE_NOT_FOUND (18) for the face, scaled font and context. python3 tools/check_conventions.py passed. The standalone tools/debt_fold.py --check reports the same two conflicting shader debt fragments on both the base and the branch.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

Summary by CodeRabbit

  • Bug Fixes
    • Cairo font-face errors now retain the correct status for missing files and memory failures. Error statuses remain consistent when creating scaled fonts and assigning font faces to Cairo contexts.
  • Documentation
    • Clarified that successfully created FreeType font faces do not have a native FreeType backend.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5523303771 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27755). Originally posted by [bipinkrish](https://github.com/bipinkrish) on 2026-11-27T08:06:26Z. --- ### What Carry the pinned Cairo backend’s file-not-found and no-memory font faces through the guest font-face bridge. A missing file in a Fontconfig pattern now gives `cairo_scaled_font_create` an error font and sets the same error on a healthy context passed to `cairo_set_font_face`. The error objects retain their guest identity and require no allocation. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> On Ubuntu 24.04.4 x86-64, the new missing-file regression failed on the base commit with `cairo_scaled_font_create not implemented`. All 41 tests in `ctest --test-dir build -R '^guest_cairo_' --output-on-failure` passed with the change. The test checks the scaled font status, the context error through its target, and preservation of the first context error. A separate program using Cairo 1.18.0 returned `CAIRO_STATUS_FILE_NOT_FOUND` (18) for the face, scaled font and context. `python3 tools/check_conventions.py` passed. The standalone `tools/debt_fold.py --check` reports the same two conflicting shader debt fragments on both the base and the branch. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Cairo font-face errors now retain the correct status for missing files and memory failures. Error statuses remain consistent when creating scaled fonts and assigning font faces to Cairo contexts. - **Documentation** - Clarified that successfully created FreeType font faces do not have a native FreeType backend. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-27 09:03:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T09:03:23Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review evidence supports merging.

What I ran

Reviewed head fa082443ce4d05d3e279571f99d9fcfee21057b2 using the prepared diff and repo_read.py source reads. No test commands were run.

Results

Check Result Note
Changed code review passed Three changed files read
Automated tests not run Only author-reported test results available

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libcairo/FontFace.cpp, core/libs/tests/GuestCairoFtFontFace.cpp, and docs/dev/debt/changes/feat-libcairo-font-pipeline.md were read in full. files.json was not available as a review-folder document; the reader's file listing confirms all three changed files are included and read. The Cairo backend source, build, tests, and console behavior were not independently verified. The description reports 41 passing guest Cairo tests and a standalone Cairo 1.18.0 check; these were not run in this review.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6085753322 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27755#pullrequestreview-6085753322). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T09:03:23Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review evidence supports merging. ## What I ran Reviewed head `fa082443ce4d05d3e279571f99d9fcfee21057b2` using the prepared diff and `repo_read.py` source reads. No test commands were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Three changed files read | | Automated tests | not run | Only author-reported test results available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libcairo/FontFace.cpp`, `core/libs/tests/GuestCairoFtFontFace.cpp`, and `docs/dev/debt/changes/feat-libcairo-font-pipeline.md` were read in full. `files.json` was not available as a review-folder document; the reader's file listing confirms all three changed files are included and read. The Cairo backend source, build, tests, and console behavior were not independently verified. The description reports 41 passing guest Cairo tests and a standalone Cairo 1.18.0 check; these were not run in this review. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-27 14:29:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-27T14:29:29Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against fa082443ce:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_cairo_ft_font_face_tests built cleanly.
  • CTest (guest_cairo_ft_font_face):
    1/1 Test #6245: guest_cairo_ft_font_face .........   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libcairo/FontFace.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #6245: guest_cairo_ft_font_face .........Subprocess aborted***Exception:   0.51 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified that CairoFontFaceFromBackend_nid_no_patch correctly handles both _cairo_font_face_nil and _cairo_font_face_nil_file_not_found before taking BackendMutex, preventing map allocations for upstream error faces
    • Checked lifetime and reference semantics in CairoFontFaceNilNoMemory and CairoFontFaceNilFileNotFound, ensuring .immortal = true and correct .backend pointers are retained across reference/destroy operations
    • Verified that CairoFontFaceBackend_nid_no_patch safely returns the upstream nil backend pointers when passed error faces, enabling propagation to downstream consumers like cairo_scaled_font_create and cairo_set_font_face
    • Checked GuestCairoFtFontFace.cpp test logic to confirm it verifies status 18 propagation to scaled fonts and contexts, preserves the initial error on subsequent assignments, and cleans up all allocated test objects
    • Verified AGENTS.md conventions, debt fragment format in feat-libcairo-font-pipeline.md, and absence of undocumented stubs or comments

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6089646314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27755#pullrequestreview-6089646314). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-27T14:29:29Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `fa082443ce`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_cairo_ft_font_face_tests` built cleanly. - **CTest** (`guest_cairo_ft_font_face`): ``` 1/1 Test #6245: guest_cairo_ft_font_face ......... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libcairo/FontFace.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #6245: guest_cairo_ft_font_face .........Subprocess aborted***Exception: 0.51 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified that CairoFontFaceFromBackend_nid_no_patch correctly handles both _cairo_font_face_nil and _cairo_font_face_nil_file_not_found before taking BackendMutex, preventing map allocations for upstream error faces - Checked lifetime and reference semantics in CairoFontFaceNilNoMemory and CairoFontFaceNilFileNotFound, ensuring .immortal = true and correct .backend pointers are retained across reference/destroy operations - Verified that CairoFontFaceBackend_nid_no_patch safely returns the upstream nil backend pointers when passed error faces, enabling propagation to downstream consumers like cairo_scaled_font_create and cairo_set_font_face - Checked GuestCairoFtFontFace.cpp test logic to confirm it verifies status 18 propagation to scaled fonts and contexts, preserves the initial error on subsequent assignments, and cleans up all allocated test objects - Verified AGENTS.md conventions, debt fragment format in feat-libcairo-font-pipeline.md, and absence of undocumented stubs or comments Looks Good To Me
Plyxen commented 2026-11-28 05:06:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T05:06:23Z.

Review: APPROVED


Checked head fa082443ce. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to main a163d4b886 together with #27930, #27929, #27926, #27925, #27924, #27923, #27922, #27901, #27828, #27771, #27748, #27682, #27765. tools/check_conventions.py --head and tools/debt_fold.py --check passed and the full build succeeded. guest_cairo_ft_font_face passes. In the full CPU suite (5,120 tests) the only failures are unrelated:

  • windows_read_trap_unknown fails on main too (fixed in #28028).
  • frame_capture_minimize, jpeg_external_toolchain and guest_pthread_mutex_contention are timeouts under load; they pass when run on their own.
  • guest_audio_in_capture passes 20/20 on main and with #27922.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6095939412 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27755#pullrequestreview-6095939412). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-11-28T05:06:23Z. **Review:** APPROVED --- Checked head `fa082443ce`. All on Windows 11 with WinLibs GCC 15.2 (Release), applied to `main` `a163d4b886` together with #27930, #27929, #27926, #27925, #27924, #27923, #27922, #27901, #27828, #27771, #27748, #27682, #27765. `tools/check_conventions.py --head` and `tools/debt_fold.py --check` passed and the full build succeeded. `guest_cairo_ft_font_face` passes. In the full CPU suite (5,120 tests) the only failures are unrelated: - `windows_read_trap_unknown` fails on `main` too (fixed in #28028). - `frame_capture_minimize`, `jpeg_external_toolchain` and `guest_pthread_mutex_contention` are timeouts under load; they pass when run on their own. - `guest_audio_in_capture` passes 20/20 on `main` and with #27922. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 08:43:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:43:58Z.

Review: COMMENTED


The Linux guest_cairo_ft_font_face CTest passed with the patch. The fixture checks that a FreeType failure yields a Cairo error face with the expected status, alongside the normal FreeType font-face path.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6166319595 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27755#pullrequestreview-6166319595). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T08:43:58Z. **Review:** COMMENTED --- The Linux `guest_cairo_ft_font_face` CTest passed with the patch. The fixture checks that a FreeType failure yields a Cairo error face with the expected status, alongside the normal FreeType font-face path. 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!27755
No description provided.