feat(libfontconfig): implement the configuration-less font queries #17741

Merged
zkiller1236 merged 2 commits from upstream-pr/17741 into main 2026-11-13 05:35:29 +00:00
zkiller1236 commented 2026-11-09 13:49:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zkiller1236 on 2026-11-09T13:49:19Z.


What

FcFontList (7+Gq-0xFybo), FcFontSetMatch (8DLBHeMsS1k), FcFontMatch (FqneT2syjGE), FcFontSort (MApHziT-St4) and FcConfigSubstitute (8v4Xk2b+C1k) were parameterless placeholders that threw. They now take the public fontconfig.h prototypes and follow Fontconfig 2.15.0 (the bundled 3rdparty/fontconfig) against this module's configuration functions, which the firmware 13.42 disassembly already recorded in the debt file shows to be configuration-less: FcConfigCreate, FcConfigReference and FcConfigGetCurrent return null and FcInitBringUptoDate returns true.

  • FcFontList(config, pattern, objects): as in fclist.c, a null configuration first calls FcInitBringUptoDate (returning null if it fails); FcConfigReference then yields null, so it returns null.
  • FcFontSetMatch(config, sets, nsets, pattern, result): as in fcmatch.c, it stores FcResultNoMatch in *result before taking the reference, then returns null.
  • FcFontMatch(config, pattern, result) and FcFontSort(config, pattern, trim, coverage, result): as in fcmatch.c, they store FcResultNoMatch before taking the reference and return null; FcFontSort leaves *coverage untouched, as 2.15.0 only writes it after the reference.
  • FcConfigSubstitute(config, pattern, kind): as in FcConfigSubstituteWithPat, a kind outside FcMatchPattern..FcMatchScan returns false; otherwise the null reference also returns false. kind is taken as int, so any guest value is compared without converting it to the enum.

Each function calls the module's real FcConfigReference and throws if it ever returns a configuration, since no font or substitution data exists to continue with. A null argument that 2.15.0 asserts against (the set array, pattern or result) also throws. FcMatchKind is added to Types.hpp with the fontconfig.h values. The five rows leave the debt file's placeholder table (16 to 11) and get their own entry, which states that the console's copies of these functions were not disassembled, so it is unverified that they call the same FcConfigReference.

Tested

Linux x86-64, GCC, Release with BUILD_TESTING=ON, on main 3d7f347871.

  • guest_fontconfig, guest_fontconfig_config, guest_fontconfig_current, guest_fontconfig_sets and guest_fontconfig_objects pass. The new CheckConfigurationQueries covers FcFontList with null, created and current configurations, with and without a pattern and object set; FcFontSetMatch with zero and one sets, checking that a preset FcResultMatch / FcResultOutOfMemory becomes FcResultNoMatch; FcFontMatch and FcFontSort with null and created configurations, both trim values and a null or sentinel coverage pointer (left unchanged); the seven null-argument throws; and FcConfigSubstitute for kinds -1, 0, 1, 2, 3 and 0x7fffffff, with and without a pattern.
  • On main the new test does not compile, because these exports take no parameters there, and calling them throws.
  • check_conventions.py --base origin/main passes. pr_overlap.py reports no shared exports; #16564, #16634 and #17631 change neighbouring lines (the debt table's count line, and one declaration line in InventoryExports.hpp for #16634), so whichever merges later resolves a small text conflict.
  • Reviewed before opening by a separate AI reviewer (Claude Sonnet), which checked the control flow and enum values against the bundled 2.15.0 source. Its two requested changes are applied: kind is an int, and the debt entry is shortened. FcFontMatch and FcFontSort were added in a second commit and reviewed the same way.

Windows and PS5/title execution are untested.

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

Claude Code assisted with the investigation, implementation, tests and review.

🤖 Generated with Claude Code

https://claude.ai/code/session_0145C1bggApen1Stz87XDkXo

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5224928097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17741). Originally posted by [zkiller1236](https://github.com/zkiller1236) on 2026-11-09T13:49:19Z. --- ### What `FcFontList` (`7+Gq-0xFybo`), `FcFontSetMatch` (`8DLBHeMsS1k`), `FcFontMatch` (`FqneT2syjGE`), `FcFontSort` (`MApHziT-St4`) and `FcConfigSubstitute` (`8v4Xk2b+C1k`) were parameterless placeholders that threw. They now take the public `fontconfig.h` prototypes and follow Fontconfig 2.15.0 (the bundled `3rdparty/fontconfig`) against this module's configuration functions, which the firmware 13.42 disassembly already recorded in the debt file shows to be configuration-less: `FcConfigCreate`, `FcConfigReference` and `FcConfigGetCurrent` return null and `FcInitBringUptoDate` returns true. - `FcFontList(config, pattern, objects)`: as in `fclist.c`, a null configuration first calls `FcInitBringUptoDate` (returning null if it fails); `FcConfigReference` then yields null, so it returns null. - `FcFontSetMatch(config, sets, nsets, pattern, result)`: as in `fcmatch.c`, it stores `FcResultNoMatch` in `*result` before taking the reference, then returns null. - `FcFontMatch(config, pattern, result)` and `FcFontSort(config, pattern, trim, coverage, result)`: as in `fcmatch.c`, they store `FcResultNoMatch` before taking the reference and return null; `FcFontSort` leaves `*coverage` untouched, as 2.15.0 only writes it after the reference. - `FcConfigSubstitute(config, pattern, kind)`: as in `FcConfigSubstituteWithPat`, a kind outside `FcMatchPattern`..`FcMatchScan` returns false; otherwise the null reference also returns false. `kind` is taken as `int`, so any guest value is compared without converting it to the enum. Each function calls the module's real `FcConfigReference` and throws if it ever returns a configuration, since no font or substitution data exists to continue with. A null argument that 2.15.0 asserts against (the set array, pattern or result) also throws. `FcMatchKind` is added to `Types.hpp` with the `fontconfig.h` values. The five rows leave the debt file's placeholder table (16 to 11) and get their own entry, which states that the console's copies of these functions were not disassembled, so it is unverified that they call the same `FcConfigReference`. ### Tested Linux x86-64, GCC, Release with `BUILD_TESTING=ON`, on `main` 3d7f347871. - `guest_fontconfig`, `guest_fontconfig_config`, `guest_fontconfig_current`, `guest_fontconfig_sets` and `guest_fontconfig_objects` pass. The new `CheckConfigurationQueries` covers `FcFontList` with null, created and current configurations, with and without a pattern and object set; `FcFontSetMatch` with zero and one sets, checking that a preset `FcResultMatch` / `FcResultOutOfMemory` becomes `FcResultNoMatch`; `FcFontMatch` and `FcFontSort` with null and created configurations, both `trim` values and a null or sentinel coverage pointer (left unchanged); the seven null-argument throws; and `FcConfigSubstitute` for kinds -1, 0, 1, 2, 3 and `0x7fffffff`, with and without a pattern. - On `main` the new test does not compile, because these exports take no parameters there, and calling them throws. - `check_conventions.py --base origin/main` passes. `pr_overlap.py` reports no shared exports; #16564, #16634 and #17631 change neighbouring lines (the debt table's count line, and one declaration line in `InventoryExports.hpp` for #16634), so whichever merges later resolves a small text conflict. - Reviewed before opening by a separate AI reviewer (Claude Sonnet), which checked the control flow and enum values against the bundled 2.15.0 source. Its two requested changes are applied: `kind` is an `int`, and the debt entry is shortened. `FcFontMatch` and `FcFontSort` were added in a second commit and reviewed the same way. Windows and PS5/title execution are untested. <!-- 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. --> ### 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 Claude Code assisted with the investigation, implementation, tests and review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0145C1bggApen1Stz87XDkXo
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!17741
No description provided.