feat(libfontconfig): implement language sets and pattern core #14435
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14435"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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/FcValuelayouts are asserted. Source attribution and the complete upstreamfclang.cnotice are retained inObjects.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.FcPatternGetIntegeraccepts onlyFcTypeInteger. Doubles, including integral values, NaN and infinities, returnFcResultTypeMismatchwithout changing the output. This intentionally differs from upstream Fontconfig's double-to-integer conversion and follows the firmware 13.42system_ex/common_ex/lib/libfontconfig.sprxdisassembly reported in BunnyFl's review, SHA-25674d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472, type check at0x234c. The quoted instruction bytes were independently decoded; the complete firmware binary and consoleFcPatternAddDoublewere 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:
COPYINGandUnicode-LICENSE.txtintolicenses/fontconfig.Unicode-LICENSE.txtpreserves 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.libs/licenses/fontconfig.txtandlibs/licenses/fontconfig-unicode.txtin 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 aNotImplemented_nid_no_patchrefusal. 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
28154f27a0after #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.FcMatrixhas one definition inTypes.hpp, and pattern duplication/destruction have one declaration each inInventoryExports.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
0c939f79cdon 2026-11-07-Wall -Wextra -Werror.guest_fontconfig,guest_fontconfig_setsandguest_fontconfig_objectspassed in Release and Debug with ASan/UBSan and leak detection enabled.GuestFontconfigObjects.cpp. It checks deep-copy ownership, independent values after changing and destroying the original pattern, and destruction through the merged set implementation.python3 tools/tests/test_package_release.pyran 91 tests successfully with five platform-specific skips.git diff --checkand conventions againstupstream/mainpassed. The required--base origin/mainrun reports the pre-existing upstream commit-subject violation ate62a0f2604, also reported when checking unchangedupstream/mainagainst that fork base.Earlier integer-getter validation before the rebase (
d848a0885c):libfontconfigCMake module andguest_fontconfig_objects_testsin 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$' -Vpassed. 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.772af1fbeegetter aborted at the new double-type-mismatch assertion, line 95. Applying the getter correction made the test pass.python3 tools/check_conventions.py --base origin/mainreports 0 errors and 8 existing unrelated debt-length warnings;git diff --checkpasses.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.COPYINGand 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 --checkpasses.Runtime validation retained from this branch:
59c428545d: full project configuration withBUILD_TESTING=ON;cmake --build build --target libs guest_fontconfig_objects_tests patched_libraries_tests --parallel 4passed, including NID patching. Six selected CTests passed: the Fontconfig runtime test, patched libraries, public-header audit fixture and affected header compile batches.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-pointerand leak detection enabled. The public-header audit passed (399 libraries / 26,742 exports).family.tools/pr_overlap.pywas 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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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
772af1fbee310ecccfd5d09890b49aebd7e6ad6d, base929e8d8442(the precheck base)./usr/bin/python33.11.2, no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14435 --output-dir /dev/shm/reviewer-run/precheck/14435. Its negative control ontools/tests/test_package_release.pyfails on base with five assertion failures and two errors, so the new release-notice tests discriminate the change.python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 929e8d8442 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --json(exit 0;passed; 0 findings; 53 symbols).core/libs/prx/libfontconfig/include/Types.hpp.FcType(FcTypeUnknown= -1 throughFcTypeRange),FcLangResultandFcResultvalues match Fontconfig'sfontconfig.h;FcMatrixis four doubles (32 bytes) andFcValueis anFcTypeplus a union at offset 8 (16 bytes), both asserted.FcPatternreference counting (Objects.cpparound line 274:fetch_sub(1) == 1beforedelete), andFcLangSetcreation and destruction (lines 222-226).core/libs/prx/libfontconfig/GenerateData.cmake, which reads the case-fold table from theFONTCONFIG_SOURCEsubmodule and fails the build when a fold exceeds three code points.core/libs/tests/GuestFontconfigObjects.cppfrom a head extract: one literal-path registration heuristic (the test is registered asguest_fontconfig_objectsincore/libs/prx/libfontconfig/CMakeLists.txt).Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/14435/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check 929e8d8442bb23635f7a55ff3e1232cdcd52c379...772af1fbee310ecccfd5d09890b49aebd7e6ad6d/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/usr/bin/python3 tools/pr_abi_audit.py --base 929e8d8442bb23635f7a55ff3e1232cdcd52c379 --head 772af1fbee310ecccfd5d09890b49aebd7e6ad6d --json/usr/bin/python3 -m py_compile tools/package_release.py/usr/bin/python3 -m unittest tools.tests.test_package_release/usr/bin/python3 tools/check_test_registration.py --scripts/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14435 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14435/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./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.pyA 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.cppwas not run; it needs a build.Findings
Blocking: none found in the parts I read.
Non-blocking:
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.3rdparty/fontconfig) and the generated tables were not compared with the upstream files here.Sources
github.com/boykopovar/AnyPS5@772af1fbee/core/libs/prx/libfontconfig/include/Types.hppgithub.com/boykopovar/AnyPS5@772af1fbee/core/libs/prx/libfontconfig/Objects.cpp (L270-L275)github.com/boykopovar/AnyPS5@772af1fbee/core/libs/prx/libfontconfig/GenerateData.cmakeNot verified
Objects.cppwas not read; this result is partial.guest_fontconfig_objectswere not built or run.conventions(one run cancelled, one queued),eligibility,labels,library-portabilityandreportwere queued at review time.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(sha25674d7414445f8687c1d22a92fa3c994d2e5fa304e6699dc84dcc5459af7da8472). 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 upstreamfcpat.c. Patterns are 0x48-byteoperator newobjects (FcPatternCreate,0x8b0). SinceFcPatternis opaque, only the API behaviour below matters.One difference:
FcPatternGetIntegerdoesn'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 onlyFcTypeInteger:There is no
cvt*instruction anywhere in0x2130-0x2393. A value added withFcPatternAddDoublepresumably givesFcResultTypeMismatchon the console. I didn't readFcPatternAddDouble(0x1210) to confirm it stores type 2. This PR (core/libs/prx/libfontconfig/Objects.cpp:337-343on772af1fbee) truncates it and returnsFcResultMatch, following upstream. Could the integer getter acceptFcTypeIntegeronly, with a test that adds a double and expectsFcResultTypeMismatch? That would also remove the out-of-range-double refusal at:341-342.Consistent with the module, as far as I read:
FcPatternGetBool,FcPatternGetStringandFcPatternGetMatrixeach accept exactly one type,cmpl $0x4,$0x3and$0x5, with no conversion. That matches:354,:364and:374.FcPatternReference(0x9f0) islock incl (%rdi); ret.FcPatternDestroy(0x7e0) islock decl (%rdi)and frees at zero. Neither checks for null, so the PR's null handling (core/libs/prx/libfontconfig/Objects.cpp:274and:278) is a host-safety choice.docs/dev/debt/libfontconfig.mdshould say so if it doesn't already.FcLangSetAdd(0x6880) lowercases into astd::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.en/en,en/en-us,zh-cn/zh-twandenx/enthat gives the same results as the PR's table plusCompareLanguages.Not compared:
FcPatternAdd*,FcPatternGet,FcPatternDel,FcPatternRemove,FcPatternEqual,FcPatternDuplicate's copy depth, andFcLangSetDestroy. Related: on #15283 I noted that the console'sFcFontSetAddstoresFcPatternDuplicateof its argument, which relies on this PR's duplicate semantics.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 onlyFcTypeIntegerand returnsFcResultTypeMismatchotherwise, leaving the output untouched. That matches firmware 13.42'scmpl $0x1,(%rcx,%rdx,1)at0x234c.Windows 11, WinLibs GCC, head merged onto current
mainwith3rdparty/fontconfigat the pinned72b9a48:guest_fontconfig_objectspasses. Mutation: with the oldFcTypeInteger || FcTypeDoubleacceptance restored inObjects.cpp, the test fails atcore/libs/tests/GuestFontconfigObjects.cpp:95, the double-indexFcResultTypeMismatchcheck.My earlier review's "not compared" list still holds: I didn't read the console's
FcPatternAdd*, genericFcPatternGet,FcPatternDel/Remove,FcPatternEqual,FcPatternDuplicatedepth orFcLangSetDestroy. Everything I did compare (the typed getters, the reference count, the language-set add/match) is consistent with the module.