feat(libfontconfig): implement FcDefaultSubstitute #17631
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17631"
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 GalaxyGamingFR on 2026-11-09T05:05:19Z.
What
Implement
FcDefaultSubstituteinlibfontconfig, replacing its parameterless throwing placeholder inExport.cpp.src/fcdefault.c, the version of the pinned3rdparty/fontconfigsubmodule (72b9a48) and the one the debt file cites for the pattern core. The port uses only the publicFcPatternGet/FcPatternAdd*/FcPatternDelfunctions, soPatternValue,ValidTypeandValuesEqualinObjects.cppare untouched.InventoryExports.hppnow declares it asvoid FcDefaultSubstitute(FcPattern* pattern).weight(80),slant(0),width(100), the eight boolean defaults (hinting,verticallayout,autohint,globaladvance,embeddedbitmap,decorative,symbol,variable),fontversion(0x7fffffff),hintstyle(FC_HINT_FULL, 3) andorder(0) are added; existing values are left alone.sizedefaults to 12,scaleto 1 anddpito 75. Without apixelsize,scaleanddpiare rewritten andpixelsize = size * scale * dpi / 72is added. With one,sizeis recomputed from it (pixelsize / dpi * 72 / scale), as 2.15.0 does.sizeis always replaced by a single double. An integerpixelsizeis converted to double, where 2.15.0 reads the union's double member.FcTypeRangevalues (PatternValue::Viewthrows for them), so there is nothing to read.namelang: there is no PS5 locale environment, so an absentnamelangbecomesen, which is exactly what 2.15.0'sFcGetDefaultLangspicks whenFC_LANG,LC_ALL,LC_CTYPEandLANGare all unset. Absentfamilylang,stylelangandfullnamelangget that language followed byen-us. 2.15.0 addsen-uswith a weak binding; pattern values here carry no binding, so it is a plain second value.prgnameanddesktopare never added: the console has no known program-name orXDG_CURRENT_DESKTOPsource.NotImplemented_nid_no_patch, where upstream would dereference it.The debt file records that this follows public 2.15.0 source, not a measured console module or firmware disassembly, and is unverified on a PS5. The remaining-exports table drops the row and its count goes from 16 to 15.
No title's trace or disassembly was used, and the export was not measured on a PS5.
Tested
Windows 11, WinLibs MinGW GCC 15.2.0. This is not a full CMake build. I compiled
tests/GuestFontconfigObjects.cppwith libfontconfig'sExport.cpp,Objects.cpp,Sets.cppandConfig.cppinto one executable, withAPS5_VABIdefined empty, a one-lineNotImplementedAt_nid_no_patchshim, andFontconfigData.hppgenerated from the pinned submodule commit with a script mirroringGenerateData.cmake. Not built on Linux or macOS.DefaultSubstitutechecks that an empty pattern gets every default with exact values and exactly one value each (two for the*langobjects,enthenen-us), thatprgnameanddesktopstay absent, and that a second call changes nothing; that a presetweight,hinting, integersize,scale,dpi,namelang,stylelang,variableandorderare kept without duplicates andpixelsizeis computed from them (20 * 2 * 144 / 72 = 80); and that a presetpixelsizeis kept whilesizeis recomputed from it andscaleis not added.hintstyledefault to 2, droppingscalefrom thepixelsizeformula, changing theorderdefault to 1 and thevariabledefault to true each make the test fail; restoring the source makes it pass again.operator newthrough the existing pattern functions, so the test needs no application heap.-Wall -Wextrais clean for the changed files, andpython tools/check_conventions.py --base origin/mainpasses.I searched open pull requests for
FcDefaultSubstitutejust before opening this one, and none implements it. #16564 editsObjects.cppandTypes.hpp; this PR touches neither.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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:07:50Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this review; the portability and failure behavior below should be clarified before relying on this implementation.
What I ran
Reviewed head
c06e83723b5d0c57a867d81262299b67271cd1e4. I readreview/description.md,review/commits.md,review/manifest.json,review/diff.patch, and the full text of all four changed files listed as reviewed in the manifest:core/libs/prx/libfontconfig/Export.cpp,core/libs/prx/libfontconfig/include/InventoryExports.hpp,core/libs/tests/GuestFontconfigObjects.cpp, anddocs/dev/debt/libfontconfig.md. I also read the relevant pattern APIs incore/libs/prx/libfontconfig/Objects.cpp.No commands or tests were run; test results in the PR description are author-reported.
Results
Findings
Blocking
None.
Non-blocking
Export.cpp:175readspixelsizethroughnumber(), which treats only integer and double values as numeric and returns0.0for other types. If the firstpixelsizevalue has an unexpected type,sizeis replaced with zero-derived output rather than leaving the input alone or reporting the mismatch. Consider matching Fontconfig's accepted types or documenting this fallback explicitly.Export.cpp:169-178deletes existingscale,dpi, andsizevalues before adding replacements, but does not check whether theFcPatternAdd*calls succeed. The underlying pattern add functions can return failure on allocation failure, so this can leave a pattern missing values after the operation. Consider handling insertion failure or documenting the best-effort behavior.Not verified
review/files.jsonwas not available in the reader results, so excluded files and the manifest'sreviewedlist could not be independently checked. No build, test, convention check, or PS5 runtime check was performed. The full text of changed files is reported included in the manifest and was read; the author-reported Windows test and mutation checks were not independently verified.To get this to a good state
Nothing is required. Optional points: clarify handling for unexpected
pixelsizetypes and allocation failures.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T08:51:56Z.
Review: COMMENTED
Reviewed — comments
This port has a concrete pixel-size edge case: it treats a matched
pixelsizethat is not numeric as zero when recomputingsize.What I ran
7ea29ff8c4d3a21296b6f1d0b63c301914951d6b; base ismain. No merged-preview check or commands were run.description.md,commits.md,manifest.json,diff.patch, and all four changed files listed in the manifest. InspectedObjects.cppfor pattern get/add/delete behavior anddocs/dev/debt/libfontconfig.mdfor surrounding debt notes. The prepared review folder reported all changed files included;files.jsonwas unavailable through the reader.Results
Findings
Blocking
None.
Non-blocking
Export.cpp:221usesnumber("pixelsize", 0.0)after the getter has matched any value type. Ifpixelsizeexists but contains a string or other nonnumeric value,numberreturns zero and overwritessizewith zero. Upstream expects a numeric pixel size, so this is malformed-input handling; consider retaining the current size or following the library's type-mismatch behavior instead of silently substituting zero.Not verified
files.jsoncould not be read via the available reader interface.To get this to a good state
Nothing is required. Consider handling a matched nonnumeric
pixelsizewithout silently deriving a zero size.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T08:56:36Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
de0c21eb-6eac-4ba1-ab03-3438e9947fc4Reviewing files that changed from the base of the PR and between
1b8f79a5b5and7ea29ff8c4.core/libs/prx/libfontconfig/Export.cppcore/libs/prx/libfontconfig/include/InventoryExports.hppcore/libs/tests/GuestFontconfigObjects.cppdocs/dev/debt/changes/feat-libfontconfig-default-substitute.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:17:19Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the optional points below are for follow-up.
What I ran
Reviewed head
b64a1edf278f82753cadb859be0a32532d676ceafrom the prepared diff and repository reader (repo_read.py). No build or test commands were run. The description reports author-run Windows tests; those results were not independently verified.Results
Findings
Blocking
None.
Non-blocking
FcPatternAddInteger,FcPatternAddBool, andFcPatternAddStringreturn status values that are ignored for defaults and language entries (core/libs/prx/libfontconfig/Export.cpp:203,core/libs/prx/libfontconfig/Export.cpp:211,core/libs/prx/libfontconfig/Export.cpp:232,core/libs/prx/libfontconfig/Export.cpp:238). On allocation failure, the function can return with only part of the requested defaults applied. Consider checking these results and handling failure consistently with the required size additions.Not verified
core/libs/prx/libfontconfig/Export.cpp,core/libs/prx/libfontconfig/include/InventoryExports.hpp,core/libs/tests/GuestFontconfigObjects.cpp, anddocs/dev/debt/changes/feat-libfontconfig-default-substitute.md. No files were excluded by the supplied manifest.To get this to a good state
Nothing is required. Optional follow-up: handle failures from all pattern-add calls so allocation failures cannot silently leave a partially substituted pattern.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T15:48:32Z.
Review: APPROVED
Reviewed — looks good
The implementation and its tests were read at head
7c668dec4cdb7025a697de4c53d41fa3c2ac723f; no blocking defect was verified, though the reported test run and PS5 behavior were not independently verified.What I ran
No commands or tests were run. I read the prepared diff and the changed files at the pinned head.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The Windows test, mutation checks, warning check, and conventions check described by the author were not run during this review. PS5 behavior and the full build were not verified. The review bundle’s
files.jsonwas unavailable; the manifest lists four changed files, and all four were read. No files were excluded in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T15:51:36Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
dad074bb-a7ee-4ce0-bc32-46414478c407Reviewing files that changed from the base of the PR and between
b64a1edf27and7c668dec4c.core/libs/prx/libfontconfig/Export.cppdocs/dev/debt/changes/feat-libfontconfig-default-substitute.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.