feat(libfontconfig): implement language sets and pattern core #14435

Merged
bipinkrish merged 5 commits from upstream-pr/14435 into main 2026-11-07 04:32:21 +00:00
bipinkrish commented 2026-11-01 13:06:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bipinkrish on 2026-11-01T13:06:49Z.


What

Replace 21 unconditional libfontconfig stubs with the four language-set exports and seventeen pattern-core exports. Language sets support creation/destruction, insertion and exact/territory/language queries. Patterns support creation/destruction, references, deep copies, equality, indexed removal/deletion, integer/double/bool/string/matrix insertion, generic retrieval and the four declared typed getters.

Patterns own copied strings and matrices, retain stable borrowed value addresses across appends, preserve value ordering, validate built-in property types and support custom properties. The public LP64 FcMatrix/FcValue layouts are asserted. Source attribution and the complete upstream fclang.c notice are retained in Objects.cpp.

Signatures and behavior generally follow Fontconfig 2.15.0 at 72b9a48f57de6204d99ce1c217b5609ee92ece9b: fcpat.c, fclang.c, fcname.c and fcstr.c. CMake generates and compiles the language, property-type and Unicode case-fold tables from the pinned submodule. Equality preserves 2.15.0's distinct-empty-pattern result and signed 16-bit case-table offsets.

FcPatternGetInteger accepts only FcTypeInteger. Doubles, including integral values, NaN and infinities, return FcResultTypeMismatch without changing the output. This intentionally differs from upstream Fontconfig's double-to-integer conversion and follows the firmware 13.42 system_ex/common_ex/lib/libfontconfig.sprx disassembly reported in BunnyFl's review, SHA-256 74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472, type check at 0x234c. The quoted instruction bytes were independently decoded; the complete firmware binary and console FcPatternAddDouble were not independently checked. This is disassembly evidence, not a console measurement. The debt entry also records the host-safety null behavior of pattern reference/destruction.

License distribution:

  • CMake installs the submodule's complete COPYING and Unicode-LICENSE.txt into licenses/fontconfig.
  • Unicode-LICENSE.txt preserves the pinned CaseFolding-15.1.0 header and the complete 2023 Unicode data/software permission notice from the official 2023 source. The notice text is retained verbatim; ICU code is not introduced.
  • Linux and Windows release layouts include both notices as libs/licenses/fontconfig.txt and libs/licenses/fontconfig-unicode.txt in patched/unpatched ZIP and tar archives. Missing or empty notices fail validation before existing output is replaced.

Console ABI/version fidelity, external opaque objects and unsupported faulting arguments remain documented in docs/dev/debt/libfontconfig.md. Production refusals remain; no test pins a NotImplemented_nid_no_patch refusal. After combining the merged implementations, 21 exports remain unconditional stubs. No game, console or title-library execution was used. No firmware binary was inspected locally; the getter correction uses the reviewer-provided disassembly above.

Rebased onto main 28154f27a0 after #14392 and #14441 merged. The library combines the merged charset, matrix, font-set and object-set implementations with this PR’s language sets and pattern core. All three Fontconfig tests are registered. FcMatrix has one definition in Types.hpp, and pattern duplication/destruction have one declaration each in InventoryExports.hpp. The release packager preserves the merged HarfBuzz and SQLite license handling and adds the Fontconfig notices. The landing-order dependency is satisfied.

Tested

Ubuntu 24.04.4 LTS, GCC 13.3.0.

Rebase validation at 0c939f79cd on 2026-11-07

  • Rebuilt the actual Fontconfig CMake target and all three registered tests in an isolated harness, using freshly built current-main libc. The Fontconfig library and object test compile with -Wall -Wextra -Werror.
  • guest_fontconfig, guest_fontconfig_sets and guest_fontconfig_objects passed in Release and Debug with ASan/UBSan and leak detection enabled.
  • Added a real-pattern font-set regression to GuestFontconfigObjects.cpp. It checks deep-copy ownership, independent values after changing and destroying the original pattern, and destruction through the merged set implementation.
  • Public-header audit passed for 407 libraries and 30,771 exports. All three affected headers compile standalone. The merged charset, matrix and set function bodies are preserved verbatim. All 21 debt-table rows match the remaining unconditional stub bodies.
  • python3 tools/tests/test_package_release.py ran 91 tests successfully with five platform-specific skips.
  • git diff --check and conventions against upstream/main passed. The required --base origin/main run reports the pre-existing upstream commit-subject violation at e62a0f2604, also reported when checking unchanged upstream/main against that fork base.
  • Validation uses focused Linux CMake harnesses. Fresh hosted CI is pending.

Earlier integer-getter validation before the rebase (d848a0885c):

  • Rebuilt the actual libfontconfig CMake module and guest_fontconfig_objects_tests in an isolated harness using existing guest libc/libkernel artifacts, with GCC 13.3.0, -Wall -Wextra -Werror -fsanitize=address,undefined -fno-omit-frame-pointer.
  • ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ctest --test-dir /tmp/anyps5-fontconfig-integer-tests/build -R '^guest_fontconfig_objects$' -V passed. Tests check integer boundaries, double type mismatches for finite/integral/fractional/out-of-range/NaN/infinite values, unchanged outputs, and missing-property/invalid-index errors. The previous conversion assertions and lifetime check were updated.
  • Negative control: the updated test against the unchanged 772af1fbee getter aborted at the new double-type-mismatch assertion, line 95. Applying the getter correction made the test pass.
  • Public-header audit passed: 399 libraries / 26,742 exports. python3 tools/check_conventions.py --base origin/main reports 0 errors and 8 existing unrelated debt-length warnings; git diff --check passes.

License/packaging validation at 772af1fbee:

  • python3 tools/tests/test_package_release.py: 81 tests run: 76 passed and 5 platform-specific skips. New tests exercise the actual CMake install registrations, exact notice bytes in both Linux/Windows archive layouts, both patched/unpatched variants and both ZIP/tar formats, plus missing/empty notice failures preserving existing release output and library inputs. Windows archive layout tests use fixtures on Linux.
  • CMake installation using the actual pinned Fontconfig COPYING and the bundled Unicode notice was separately verified byte for byte against their source files.
  • python3 tools/check_conventions.py --base origin/main: 0 errors and the same 8 unrelated debt-length warnings. git diff --check passes.

Runtime validation retained from this branch:

  • Initial implementation 59c428545d: full project configuration with BUILD_TESTING=ON; cmake --build build --target libs guest_fontconfig_objects_tests patched_libraries_tests --parallel 4 passed, including NID patching. Six selected CTests passed: the Fontconfig runtime test, patched libraries, public-header audit fixture and affected header compile batches.
  • 1,075,627 differential comparisons against native Fontconfig 2.15.0 passed for language names/case/territories/unknown tags; built-in property types; random insertion/retrieval/removal/copy operations; error/output-preservation behavior; and all common/full Unicode fold entries plus malformed UTF-8 cases. These probes predate the integer-getter correction. That getter now intentionally differs from upstream for doubles; the other production function bodies remain unchanged.
  • After removing the five unsupported-refusal assertions in 5f0f21a336, the focused library/test was rebuilt through its CMake registration in an isolated harness using existing guest libc/libkernel artifacts. CTest passed with -Wall -Wextra -Werror -fsanitize=address,undefined -fno-omit-frame-pointer and leak detection enabled. The public-header audit passed (399 libraries / 26,742 exports).
  • Negative control for the original implementation: disabling built-in property validation in a temporary source copy made the committed test fail on integer insertion into family.
  • tools/pr_overlap.py was run for the original and rebased implementation; shared-file/manual findings are described above.

The rebase validation rebuilt the focused Fontconfig module and all three tests. The complete CTest suite has not been run. Not tested on Windows/macOS hosts, games/homebrew or PS5 hardware.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5107620622 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14435). Originally posted by [bipinkrish](https://github.com/bipinkrish) on 2026-11-01T13:06:49Z. --- ### What Replace 21 unconditional libfontconfig stubs with the four language-set exports and seventeen pattern-core exports. Language sets support creation/destruction, insertion and exact/territory/language queries. Patterns support creation/destruction, references, deep copies, equality, indexed removal/deletion, integer/double/bool/string/matrix insertion, generic retrieval and the four declared typed getters. Patterns own copied strings and matrices, retain stable borrowed value addresses across appends, preserve value ordering, validate built-in property types and support custom properties. The public LP64 `FcMatrix`/`FcValue` layouts are asserted. Source attribution and the complete upstream `fclang.c` notice are retained in `Objects.cpp`. Signatures and behavior generally follow Fontconfig 2.15.0 at `72b9a48f57de6204d99ce1c217b5609ee92ece9b`: [fcpat.c](https://github.com/fontconfig/fontconfig/blob/72b9a48f57de6204d99ce1c217b5609ee92ece9b/src/fcpat.c), [fclang.c](https://github.com/fontconfig/fontconfig/blob/72b9a48f57de6204d99ce1c217b5609ee92ece9b/src/fclang.c), [fcname.c](https://github.com/fontconfig/fontconfig/blob/72b9a48f57de6204d99ce1c217b5609ee92ece9b/src/fcname.c) and [fcstr.c](https://github.com/fontconfig/fontconfig/blob/72b9a48f57de6204d99ce1c217b5609ee92ece9b/src/fcstr.c). CMake generates and compiles the language, property-type and Unicode case-fold tables from the pinned submodule. Equality preserves 2.15.0's distinct-empty-pattern result and signed 16-bit case-table offsets. `FcPatternGetInteger` accepts only `FcTypeInteger`. Doubles, including integral values, NaN and infinities, return `FcResultTypeMismatch` without changing the output. This intentionally differs from upstream Fontconfig's double-to-integer conversion and follows the firmware 13.42 `system_ex/common_ex/lib/libfontconfig.sprx` disassembly reported in [BunnyFl's review](https://github.com/boykopovar/AnyPS5/pull/14435#pullrequestreview-5746793316), SHA-256 `74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472`, type check at `0x234c`. The quoted instruction bytes were independently decoded; the complete firmware binary and console `FcPatternAddDouble` were not independently checked. This is disassembly evidence, not a console measurement. The debt entry also records the host-safety null behavior of pattern reference/destruction. License distribution: - CMake installs the submodule's complete `COPYING` and `Unicode-LICENSE.txt` into `licenses/fontconfig`. - `Unicode-LICENSE.txt` preserves the pinned CaseFolding-15.1.0 header and the complete 2023 Unicode data/software permission notice from the official [2023 source](https://github.com/unicode-org/icu/blob/release-73-2/icu4c/LICENSE). The notice text is retained verbatim; ICU code is not introduced. - Linux and Windows release layouts include both notices as `libs/licenses/fontconfig.txt` and `libs/licenses/fontconfig-unicode.txt` in patched/unpatched ZIP and tar archives. Missing or empty notices fail validation before existing output is replaced. Console ABI/version fidelity, external opaque objects and unsupported faulting arguments remain documented in `docs/dev/debt/libfontconfig.md`. Production refusals remain; no test pins a `NotImplemented_nid_no_patch` refusal. After combining the merged implementations, 21 exports remain unconditional stubs. No game, console or title-library execution was used. No firmware binary was inspected locally; the getter correction uses the reviewer-provided disassembly above. Rebased onto main `28154f27a0` after #14392 and #14441 merged. The library combines the merged charset, matrix, font-set and object-set implementations with this PR’s language sets and pattern core. All three Fontconfig tests are registered. `FcMatrix` has one definition in `Types.hpp`, and pattern duplication/destruction have one declaration each in `InventoryExports.hpp`. The release packager preserves the merged HarfBuzz and SQLite license handling and adds the Fontconfig notices. The landing-order dependency is satisfied. ### 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. --> Ubuntu 24.04.4 LTS, GCC 13.3.0. Rebase validation at `0c939f79cd` on 2026-11-07 - Rebuilt the actual Fontconfig CMake target and all three registered tests in an isolated harness, using freshly built current-main libc. The Fontconfig library and object test compile with `-Wall -Wextra -Werror`. - `guest_fontconfig`, `guest_fontconfig_sets` and `guest_fontconfig_objects` passed in Release and Debug with ASan/UBSan and leak detection enabled. - Added a real-pattern font-set regression to `GuestFontconfigObjects.cpp`. It checks deep-copy ownership, independent values after changing and destroying the original pattern, and destruction through the merged set implementation. - Public-header audit passed for 407 libraries and 30,771 exports. All three affected headers compile standalone. The merged charset, matrix and set function bodies are preserved verbatim. All 21 debt-table rows match the remaining unconditional stub bodies. - `python3 tools/tests/test_package_release.py` ran 91 tests successfully with five platform-specific skips. - `git diff --check` and conventions against `upstream/main` passed. The required `--base origin/main` run reports the pre-existing upstream commit-subject violation at `e62a0f2604`, also reported when checking unchanged `upstream/main` against that fork base. - Validation uses focused Linux CMake harnesses. Fresh hosted CI is pending. Earlier integer-getter validation before the rebase (`d848a0885c`): - Rebuilt the actual `libfontconfig` CMake module and `guest_fontconfig_objects_tests` in an isolated harness using existing guest libc/libkernel artifacts, with GCC 13.3.0, `-Wall -Wextra -Werror -fsanitize=address,undefined -fno-omit-frame-pointer`. - `ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ctest --test-dir /tmp/anyps5-fontconfig-integer-tests/build -R '^guest_fontconfig_objects$' -V` passed. Tests check integer boundaries, double type mismatches for finite/integral/fractional/out-of-range/NaN/infinite values, unchanged outputs, and missing-property/invalid-index errors. The previous conversion assertions and lifetime check were updated. - Negative control: the updated test against the unchanged `772af1fbee` getter aborted at the new double-type-mismatch assertion, line 95. Applying the getter correction made the test pass. - Public-header audit passed: 399 libraries / 26,742 exports. `python3 tools/check_conventions.py --base origin/main` reports 0 errors and 8 existing unrelated debt-length warnings; `git diff --check` passes. License/packaging validation at `772af1fbee`: - `python3 tools/tests/test_package_release.py`: 81 tests run: 76 passed and 5 platform-specific skips. New tests exercise the actual CMake install registrations, exact notice bytes in both Linux/Windows archive layouts, both patched/unpatched variants and both ZIP/tar formats, plus missing/empty notice failures preserving existing release output and library inputs. Windows archive layout tests use fixtures on Linux. - CMake installation using the actual pinned Fontconfig `COPYING` and the bundled Unicode notice was separately verified byte for byte against their source files. - `python3 tools/check_conventions.py --base origin/main`: 0 errors and the same 8 unrelated debt-length warnings. `git diff --check` passes. Runtime validation retained from this branch: - Initial implementation `59c428545d`: full project configuration with `BUILD_TESTING=ON`; `cmake --build build --target libs guest_fontconfig_objects_tests patched_libraries_tests --parallel 4` passed, including NID patching. Six selected CTests passed: the Fontconfig runtime test, patched libraries, public-header audit fixture and affected header compile batches. - 1,075,627 differential comparisons against native Fontconfig 2.15.0 passed for language names/case/territories/unknown tags; built-in property types; random insertion/retrieval/removal/copy operations; error/output-preservation behavior; and all common/full Unicode fold entries plus malformed UTF-8 cases. These probes predate the integer-getter correction. That getter now intentionally differs from upstream for doubles; the other production function bodies remain unchanged. - After removing the five unsupported-refusal assertions in `5f0f21a336`, the focused library/test was rebuilt through its CMake registration in an isolated harness using existing guest libc/libkernel artifacts. CTest passed with `-Wall -Wextra -Werror -fsanitize=address,undefined -fno-omit-frame-pointer` and leak detection enabled. The public-header audit passed (399 libraries / 26,742 exports). - Negative control for the original implementation: disabling built-in property validation in a temporary source copy made the committed test fail on integer insertion into `family`. - `tools/pr_overlap.py` was run for the original and rebased implementation; shared-file/manual findings are described above. The rebase validation rebuilt the focused Fontconfig module and all three tests. The complete CTest suite has not been run. Not tested on Windows/macOS hosts, games/homebrew or PS5 hardware. ### 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 <!-- #14392 merged --> - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-01 14:35:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T14:35:55Z.

Review: COMMENTED


Reviewed — no blocking findings, partial source review

The layout asserts and the enumerator values match Fontconfig 2.15.0 as far as I checked, the pattern reference count frees only at the last release, the ABI audit passes with no findings, and the new release-notice tests fail on base; I did not read all 429 lines of Objects.cpp, so this is a partial review and not an approval.

What I ran

  • Exact head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d, base 929e8d8442 (the precheck base).
  • Environment: Linux, /usr/bin/python3 3.11.2, no build.
  • Precheck: python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14435 --output-dir /dev/shm/reviewer-run/precheck/14435. Its negative control on tools/tests/test_package_release.py fails on base with five assertion failures and two errors, so the new release-notice tests discriminate the change.
  • ABI audit by hand (helper absent from the head tree): python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 929e8d8442 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --json (exit 0; passed; 0 findings; 53 symbols).
  • Layout read at head: core/libs/prx/libfontconfig/include/Types.hpp. FcType (FcTypeUnknown = -1 through FcTypeRange), FcLangResult and FcResult values match Fontconfig's fontconfig.h; FcMatrix is four doubles (32 bytes) and FcValue is an FcType plus a union at offset 8 (16 bytes), both asserted.
  • Ownership read at head: FcPattern reference counting (Objects.cpp around line 274: fetch_sub(1) == 1 before delete), and FcLangSet creation and destruction (lines 222-226).
  • Generator read at head: core/libs/prx/libfontconfig/GenerateData.cmake, which reads the case-fold table from the FONTCONFIG_SOURCE submodule and fails the build when a fold exceeds three code points.
  • Test-quality helper on core/libs/tests/GuestFontconfigObjects.cpp from a head extract: one literal-path registration heuristic (the test is registered as guest_fontconfig_objects in core/libs/prx/libfontconfig/CMakeLists.txt).

Results

Precheck report, checks table, unedited (/dev/shm/reviewer-run/precheck/14435/report.md):

Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check 929e8d8442bb23635f7a55ff3e1232cdcd52c379...772af1fbee310ecccfd5d09890b49aebd7e6ad6d
conventions_and_pr_template passed /usr/bin/python3 tools/check_conventions.py --base 929e8d8442bb23635f7a55ff3e1232cdcd52c379 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --title feat(libfontconfig): implement language sets and pattern core --body /dev/shm/reviewer-run/precheck/14435/pr-body.md
changed_export_abi_audit failed /usr/bin/python3 tools/pr_abi_audit.py --base 929e8d8442bb23635f7a55ff3e1232cdcd52c379 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --json
python_syntax passed /usr/bin/python3 -m py_compile tools/package_release.py
unit:tools/tests/test_package_release.py passed /usr/bin/python3 -m unittest tools.tests.test_package_release
python_test_registration passed /usr/bin/python3 tools/check_test_registration.py --scripts
live_dependency_and_mergeability_check passed /usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14435 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14435/stack
build_dependent_cpp_tests not_applicable Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.
test_quality_heuristics failed /usr/bin/python3 /dev/shm/reviewer-run/precheck/14435/head-772af1fbee31-5b9b1ab2/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14435/head-772af1fbee31-5b9b1ab2 --json .gitmodules 3rdparty/fontconfig core/libs/prx/libfontconfig/CMakeLists.txt core/libs/prx/libfontconfig/Export.cpp core/libs/prx/libfontconfig/GenerateData.cmake core/libs/prx/libfontconfig/Objects.cpp core/libs/prx/libfontconfig/Unicode-LICENSE.txt core/libs/prx/libfontconfig/include/InventoryExports.hpp core/libs/prx/libfontconfig/include/Types.hpp core/libs/tests/GuestFontconfigObjects.cpp docs/dev/debt/libfontconfig.md tools/package_release.py tools/tests/test_package_release.py
negative_controls failed A pass means every candidate failed by assertion on base; a failure means at least one did not discriminate or could not run. See per-test results.

Negative control

The release-notice negative control described above discriminates the change. The guest test GuestFontconfigObjects.cpp was not run; it needs a build.

Findings

Blocking: none found in the parts I read.

Non-blocking:

  • Not checked: the body of Objects.cpp (429 lines) apart from the reference-counting and language-set lines listed above, including the pattern append, copy, and matrix code, and the property-type validation. The author's Fontconfig 2.15.0 citations were not fetched.
  • The pinned submodule (3rdparty/fontconfig) and the generated tables were not compared with the upstream files here.

Sources

Not verified

  • Most of Objects.cpp was not read; this result is partial.
  • The C++ tests guest_fontconfig_objects were not built or run.
  • The Fontconfig 2.15.0 behaviour and the submodule contents were not checked.
  • Hosted: at this head conventions (one run cancelled, one queued), eligibility, labels, library-portability and report were queued at review time.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5728640524 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14435#pullrequestreview-5728640524). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T14:35:55Z. **Review:** COMMENTED --- # Reviewed — no blocking findings, partial source review The layout asserts and the enumerator values match Fontconfig 2.15.0 as far as I checked, the pattern reference count frees only at the last release, the ABI audit passes with no findings, and the new release-notice tests fail on base; I did not read all 429 lines of `Objects.cpp`, so this is a partial review and not an approval. ## What I ran - Exact head `772af1fbee310ecccfd5d09890b49aebd7e6ad6d`, base `929e8d8442` (the precheck base). - Environment: Linux, `/usr/bin/python3` 3.11.2, no build. - Precheck: `python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14435 --output-dir /dev/shm/reviewer-run/precheck/14435`. Its negative control on `tools/tests/test_package_release.py` fails on base with five assertion failures and two errors, so the new release-notice tests discriminate the change. - ABI audit by hand (helper absent from the head tree): `python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 929e8d8442 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --json` (exit 0; `passed`; 0 findings; 53 symbols). - Layout read at head: `core/libs/prx/libfontconfig/include/Types.hpp`. `FcType` (`FcTypeUnknown` = -1 through `FcTypeRange`), `FcLangResult` and `FcResult` values match Fontconfig's `fontconfig.h`; `FcMatrix` is four doubles (32 bytes) and `FcValue` is an `FcType` plus a union at offset 8 (16 bytes), both asserted. - Ownership read at head: `FcPattern` reference counting (`Objects.cpp` around line 274: `fetch_sub(1) == 1` before `delete`), and `FcLangSet` creation and destruction (lines 222-226). - Generator read at head: `core/libs/prx/libfontconfig/GenerateData.cmake`, which reads the case-fold table from the `FONTCONFIG_SOURCE` submodule and fails the build when a fold exceeds three code points. - Test-quality helper on `core/libs/tests/GuestFontconfigObjects.cpp` from a head extract: one literal-path registration heuristic (the test is registered as `guest_fontconfig_objects` in `core/libs/prx/libfontconfig/CMakeLists.txt`). ## Results Precheck report, checks table, unedited (`/dev/shm/reviewer-run/precheck/14435/report.md`): | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check 929e8d8442bb23635f7a55ff3e1232cdcd52c379...772af1fbee310ecccfd5d09890b49aebd7e6ad6d` | | conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base 929e8d8442bb23635f7a55ff3e1232cdcd52c379 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --title feat(libfontconfig): implement language sets and pattern core --body /dev/shm/reviewer-run/precheck/14435/pr-body.md` | | changed_export_abi_audit | failed | `/usr/bin/python3 tools/pr_abi_audit.py --base 929e8d8442bb23635f7a55ff3e1232cdcd52c379 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --json` | | python_syntax | passed | `/usr/bin/python3 -m py_compile tools/package_release.py` | | unit:tools/tests/test_package_release.py | passed | `/usr/bin/python3 -m unittest tools.tests.test_package_release` | | python_test_registration | passed | `/usr/bin/python3 tools/check_test_registration.py --scripts` | | live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14435 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14435/stack` | | build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` | | test_quality_heuristics | failed | `/usr/bin/python3 /dev/shm/reviewer-run/precheck/14435/head-772af1fbee31-5b9b1ab2/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14435/head-772af1fbee31-5b9b1ab2 --json .gitmodules 3rdparty/fontconfig core/libs/prx/libfontconfig/CMakeLists.txt core/libs/prx/libfontconfig/Export.cpp core/libs/prx/libfontconfig/GenerateData.cmake core/libs/prx/libfontconfig/Objects.cpp core/libs/prx/libfontconfig/Unicode-LICENSE.txt core/libs/prx/libfontconfig/include/InventoryExports.hpp core/libs/prx/libfontconfig/include/Types.hpp core/libs/tests/GuestFontconfigObjects.cpp docs/dev/debt/libfontconfig.md tools/package_release.py tools/tests/test_package_release.py` | | negative_controls | failed | `A pass means every candidate failed by assertion on base; a failure means at least one did not discriminate or could not run. See per-test results.` | ## Negative control The release-notice negative control described above discriminates the change. The guest test `GuestFontconfigObjects.cpp` was not run; it needs a build. ## Findings **Blocking:** none found in the parts I read. **Non-blocking:** - Not checked: the body of `Objects.cpp` (429 lines) apart from the reference-counting and language-set lines listed above, including the pattern append, copy, and matrix code, and the property-type validation. The author's Fontconfig 2.15.0 citations were not fetched. - The pinned submodule (`3rdparty/fontconfig`) and the generated tables were not compared with the upstream files here. ## Sources - Layout at head: https://github.com/boykopovar/AnyPS5/blob/772af1fbee310ecccfd5d09890b49aebd7e6ad6d/core/libs/prx/libfontconfig/include/Types.hpp - Reference counting at head: https://github.com/boykopovar/AnyPS5/blob/772af1fbee310ecccfd5d09890b49aebd7e6ad6d/core/libs/prx/libfontconfig/Objects.cpp#L270-L275 - Generator at head: https://github.com/boykopovar/AnyPS5/blob/772af1fbee310ecccfd5d09890b49aebd7e6ad6d/core/libs/prx/libfontconfig/GenerateData.cmake ## Not verified - Most of `Objects.cpp` was not read; this result is partial. - The C++ tests `guest_fontconfig_objects` were not built or run. - The Fontconfig 2.15.0 behaviour and the submodule contents were not checked. - Hosted: at this head `conventions` (one run cancelled, one queued), `eligibility`, `labels`, `library-portability` and `report` were queued at review time.
BunnyFl commented 2026-11-03 03:09:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T03:09:44Z.

Review: CHANGES_REQUESTED


I compared part of this PR against firmware 13.42's own system_ex/common_ex/lib/libfontconfig.sprx (sha256 74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472). This is disassembly only, not measured on a console; each body cited is read to its return. The console module is its own C++ implementation, not upstream fcpat.c. Patterns are 0x48-byte operator new objects (FcPatternCreate, 0x8b0). Since FcPattern is opaque, only the API behaviour below matters.

One difference: FcPatternGetInteger doesn't convert doubles. It looks the object up, returns 1 (FcResultNoMatch) when it's absent, and returns 3 (FcResultNoId) for a negative or out-of-range id. It then accepts only FcTypeInteger:

 2343: b8 02 00 00 00     mov    $0x2,%eax          # FcResultTypeMismatch
 2348: 48 c1 e2 04        shl    $0x4,%rdx          # 16-byte value entries
 234c: 83 3c 11 01        cmpl   $0x1,(%rcx,%rdx,1) # type == FcTypeInteger
 2350: 75 1c              jne    0x236e
 2359: 8b 41 08           mov    0x8(%rcx),%eax
 235c: 89 02              mov    %eax,(%rdx)
 235e: 31 c0              xor    %eax,%eax          # FcResultMatch

There is no cvt* instruction anywhere in 0x2130-0x2393. A value added with FcPatternAddDouble presumably gives FcResultTypeMismatch on the console. I didn't read FcPatternAddDouble (0x1210) to confirm it stores type 2. This PR (core/libs/prx/libfontconfig/Objects.cpp:337-343 on 772af1fbee) truncates it and returns FcResultMatch, following upstream. Could the integer getter accept FcTypeInteger only, with a test that adds a double and expects FcResultTypeMismatch? That would also remove the out-of-range-double refusal at :341-342.

Consistent with the module, as far as I read:

  • FcPatternGetBool, FcPatternGetString and FcPatternGetMatrix each accept exactly one type, cmpl $0x4, $0x3 and $0x5, with no conversion. That matches :354, :364 and :374.
  • Lifetime: FcPatternReference (0x9f0) is lock incl (%rdi); ret. FcPatternDestroy (0x7e0) is lock decl (%rdi) and frees at zero. Neither checks for null, so the PR's null handling (core/libs/prx/libfontconfig/Objects.cpp:274 and :278) is a host-safety choice. docs/dev/debt/libfontconfig.md should say so if it doesn't already.
  • Language sets:
    • FcLangSetAdd (0x6880) lowercases into a std::string, inserts it into a list, and always returns 1.
    • FcLangSetHasLang (0x6a20) returns 0 for an identical string. It returns 1 when the strings share a prefix that ends at a - in both, or when one string ends exactly where the other has a -. Otherwise it returns 2.
    • There is no built-in language table, but for en/en, en/en-us, zh-cn/zh-tw and enx/en that gives the same results as the PR's table plus CompareLanguages.

Not compared: FcPatternAdd*, FcPatternGet, FcPatternDel, FcPatternRemove, FcPatternEqual, FcPatternDuplicate's copy depth, and FcLangSetDestroy. Related: on #15283 I noted that the console's FcFontSetAdd stores FcPatternDuplicate of its argument, which relies on this PR's duplicate semantics.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5746793316 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14435#pullrequestreview-5746793316). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T03:09:44Z. **Review:** CHANGES_REQUESTED --- I compared part of this PR against firmware 13.42's own `system_ex/common_ex/lib/libfontconfig.sprx` (sha256 `74d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472`). This is disassembly only, not measured on a console; each body cited is read to its return. The console module is its own C++ implementation, not upstream `fcpat.c`. Patterns are 0x48-byte `operator new` objects (`FcPatternCreate`, `0x8b0`). Since `FcPattern` is opaque, only the API behaviour below matters. **One difference: `FcPatternGetInteger` doesn't convert doubles.** It looks the object up, returns 1 (`FcResultNoMatch`) when it's absent, and returns 3 (`FcResultNoId`) for a negative or out-of-range id. It then accepts only `FcTypeInteger`: ``` 2343: b8 02 00 00 00 mov $0x2,%eax # FcResultTypeMismatch 2348: 48 c1 e2 04 shl $0x4,%rdx # 16-byte value entries 234c: 83 3c 11 01 cmpl $0x1,(%rcx,%rdx,1) # type == FcTypeInteger 2350: 75 1c jne 0x236e 2359: 8b 41 08 mov 0x8(%rcx),%eax 235c: 89 02 mov %eax,(%rdx) 235e: 31 c0 xor %eax,%eax # FcResultMatch ``` There is no `cvt*` instruction anywhere in `0x2130`-`0x2393`. A value added with `FcPatternAddDouble` presumably gives `FcResultTypeMismatch` on the console. I didn't read `FcPatternAddDouble` (`0x1210`) to confirm it stores type 2. This PR (`core/libs/prx/libfontconfig/Objects.cpp:337-343` on `772af1fbee`) truncates it and returns `FcResultMatch`, following upstream. Could the integer getter accept `FcTypeInteger` only, with a test that adds a double and expects `FcResultTypeMismatch`? That would also remove the out-of-range-double refusal at `:341-342`. **Consistent with the module, as far as I read:** - `FcPatternGetBool`, `FcPatternGetString` and `FcPatternGetMatrix` each accept exactly one type, `cmpl $0x4`, `$0x3` and `$0x5`, with no conversion. That matches `:354`, `:364` and `:374`. - **Lifetime:** `FcPatternReference` (`0x9f0`) is `lock incl (%rdi); ret`. `FcPatternDestroy` (`0x7e0`) is `lock decl (%rdi)` and frees at zero. Neither checks for null, so the PR's null handling (`core/libs/prx/libfontconfig/Objects.cpp:274` and `:278`) is a host-safety choice. `docs/dev/debt/libfontconfig.md` should say so if it doesn't already. - **Language sets:** - `FcLangSetAdd` (`0x6880`) lowercases into a `std::string`, inserts it into a list, and always returns 1. - `FcLangSetHasLang` (`0x6a20`) returns 0 for an identical string. It returns 1 when the strings share a prefix that ends at a `-` in both, or when one string ends exactly where the other has a `-`. Otherwise it returns 2. - There is no built-in language table, but for `en`/`en`, `en`/`en-us`, `zh-cn`/`zh-tw` and `enx`/`en` that gives the same results as the PR's table plus `CompareLanguages`. Not compared: `FcPatternAdd*`, `FcPatternGet`, `FcPatternDel`, `FcPatternRemove`, `FcPatternEqual`, `FcPatternDuplicate`'s copy depth, and `FcLangSetDestroy`. Related: on #15283 I noted that the console's `FcFontSetAdd` stores `FcPatternDuplicate` of its argument, which relies on this PR's duplicate semantics.
BunnyFl commented 2026-11-03 03:59:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T03:59:45Z.

Review: APPROVED


Re-review of d848a0885c: my change request is addressed. FcPatternGetInteger (core/libs/prx/libfontconfig/Objects.cpp:331-339) now accepts only FcTypeInteger and returns FcResultTypeMismatch otherwise, leaving the output untouched. That matches firmware 13.42's cmpl $0x1,(%rcx,%rdx,1) at 0x234c.

Windows 11, WinLibs GCC, head merged onto current main with 3rdparty/fontconfig at the pinned 72b9a48: guest_fontconfig_objects passes. Mutation: with the old FcTypeInteger || FcTypeDouble acceptance restored in Objects.cpp, the test fails at core/libs/tests/GuestFontconfigObjects.cpp:95, the double-index FcResultTypeMismatch check.

My earlier review's "not compared" list still holds: I didn't read the console's FcPatternAdd*, generic FcPatternGet, FcPatternDel/Remove, FcPatternEqual, FcPatternDuplicate depth or FcLangSetDestroy. Everything I did compare (the typed getters, the reference count, the language-set add/match) is consistent with the module.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5747102361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14435#pullrequestreview-5747102361). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T03:59:45Z. **Review:** APPROVED --- Re-review of `d848a0885c`: my change request is addressed. `FcPatternGetInteger` (`core/libs/prx/libfontconfig/Objects.cpp:331-339`) now accepts only `FcTypeInteger` and returns `FcResultTypeMismatch` otherwise, leaving the output untouched. That matches firmware 13.42's `cmpl $0x1,(%rcx,%rdx,1)` at `0x234c`. Windows 11, WinLibs GCC, head merged onto current `main` with `3rdparty/fontconfig` at the pinned `72b9a48`: `guest_fontconfig_objects` passes. Mutation: with the old `FcTypeInteger || FcTypeDouble` acceptance restored in `Objects.cpp`, the test fails at `core/libs/tests/GuestFontconfigObjects.cpp:95`, the double-index `FcResultTypeMismatch` check. My earlier review's "not compared" list still holds: I didn't read the console's `FcPatternAdd*`, generic `FcPatternGet`, `FcPatternDel`/`Remove`, `FcPatternEqual`, `FcPatternDuplicate` depth or `FcLangSetDestroy`. Everything I did compare (the typed getters, the reference count, the language-set add/match) is consistent with the module.
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!14435
No description provided.