Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
bipinkrish:codex/cairo-error-font-faces
Dec 4, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
bipinkrish:codex/cairo-error-font-faces

Conversation

@bipinkrish

@bipinkrish bipinkrish commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Font-face handling

Layer / File(s) Summary
Nil-face mapping and error checks
core/libs/prx/libcairo/FontFace.cpp, core/libs/tests/GuestCairoFtFontFace.cpp, docs/dev/debt/changes/feat-libcairo-font-pipeline.md
The nil-face states now store their corresponding Cairo backend pointers, and the lookup returns the matching wrapper nil face. The test checks missing-file status propagation and preservation of the context’s original error. The documentation updates the stated limitation for successful FreeType faces.

Possibly related issues

  • boykopovar/AnyPS5#19098: This change updates the hand-written libcairo font-face path discussed in the issue, but it does not implement the issue’s proposed native Cairo replacement.

Suggested reviewers: ryongen, mcm190

Change: Bug fix

Merge Risk: Minimal · up to fa082

This fixes error font-face propagation for missing font files in the Cairo wrapper and adds a regression test. No merge-blocking risk was found.

Security architecture risk: Minimal · up to fa082

Missing fonts now return a Cairo error instead of stopping at an unimplemented operation. The change preserves the context’s first error and does not widen file access or grant new permissions.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The new behavior is reachable through existing guest font operations, but the changed handoff carries a fixed error sentinel, not the pattern filename. The existing readability check is unchanged, and the backend rejects the error face before normal font processing or replacement of the current face.

Trust Boundaries and Controls

  • observed — Backend-to-wrapper conversion matches two exact backend object addresses. The guest wrapper does not acquire ownership of those objects: destruction skips immortal faces, user-data writes return their error status, and backend reference calls leave the sentinels unchanged.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 20c53436-641f-4dd5-9abb-087997759019
Commits

Reviewing files that changed from the base of the PR and between 12b4fd5 and fa08244.

Files selected for processing: 3

  • core/libs/prx/libcairo/FontFace.cpp
  • core/libs/tests/GuestCairoFtFontFace.cpp
  • docs/dev/debt/changes/feat-libcairo-font-pipeline.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@JJenkx

JJenkx commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Independent Linux check on exact head fa082443ce4d, with parent 6ce3a027b1c1 as the control. All 41 guest_cairo_* tests passed on the head.

I also ran the same probe executable against both builds and failed exactly one nonthrowing allocation while creating a FreeType guest face through cairo_ft_font_face_create_for_ft_face. Both builds returned a no-memory face. On the parent, passing it to either cairo_scaled_font_create or cairo_set_font_face threw NotImplemented. On this head the scaled font reported CAIRO_STATUS_NO_MEMORY, its face getter returned the original guest handle, and a healthy context recorded the same error. A later attempt to select the default face preserved that first error. Reference and destroy also preserved the error face.

@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 — 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 PrivacyOnion 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.

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 Plyxen 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.

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)

@maskym

maskym commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Windows result for head fa082443ce, merged alone into main 63ee1c120a (the PR's Tested section names no Windows run).

Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, BUILD_TESTING=ON, Ninja. Build clean.

guest_cairo_ft_font_face, the test this PR adds or extends, passes 3 of 3 runs. Not run on a PS5.

AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@oneandonlydean
oneandonlydean merged commit 1bb228d into boykopovar:main Dec 4, 2026
15 of 17 checks passed
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.

8 participants