feat(libcairo): implement cairo_ft_font_options_substitute #16895
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16895"
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 AlexWhitehouse on 2026-11-07T20:54:39Z.
What
libcairo
cairo_ft_font_options_substitute(NIDii895dyBjMo) threwcairo_ft_font_options_substitute not implemented. This PR ports it from Cairo 1.18.0, the version libcairo's existing code cites:cairo-ft-font.c,_cairo_ft_font_options_substituteand its public wrapper. The newFtFontOptions.cppstarts with that file's notice.It adds Cairo font options to a Fontconfig pattern, through libfontconfig's existing exports (
FcPatternGet,FcPatternAddBool,FcPatternAddInteger,FcPatternDel), in upstream's order:antialias: if the pattern has no value, it adds one (false forCAIRO_ANTIALIAS_NONE). For anything other than subpixel antialiasing, it also replacesrgbawithFC_RGBA_NONE.rgba: if still absent, it adds one from the subpixel order (RGB, BGR, VRGB or VBGR; the default order maps to RGB) for subpixel antialiasing, orFC_RGBA_NONEotherwise.hintingandhintstyle: if absent, they are added from the hint style (none, slight, medium, full).FcPatternGet, as upstream does, so a value already in the pattern is never overwritten. A failed add stops where upstream returnsCAIRO_STATUS_NO_MEMORY.cairo_font_options_statuscheck in the wrapper does.Known gaps (debt): upstream also adds
lcdfilterwhen the options' LCD filter isn't the default. This repo's font-options object has no LCD filter field and Cairo exports no setter for it, so the filter is always the default and that branch can't run; the new debt entry says so. Hint metrics are unused, as upstream. The NID is removed from the callable-exports table, and both counts that name the remaining exports now say 73, the stubs left inExport.cpp.Tested
guest_cairo_ft_font_options(core/libs/tests/GuestCairoFtFontOptions.cpp) creates options and patterns through the guest exports, calls the export, and readsantialias,rgba,hintingandhintstyleback through Fontconfig's getters. It covers:rgbabeing replaced for non-subpixel antialiasing;main, the test fails withcairo_ft_font_options_substitute not implemented;guest_cairo_font_options,guest_cairo_matrix,guest_cairo_surface,guest_fontconfig_objectsandpublic_headers.libfontconfig.prx, and the four Cairo and five Fontconfig tests pass (9/9) at 92464009ab, with no compiler or linker warnings in the changed files.rgbaassertion.CairoFontOptionsReadinFontOptions.cppinstead of copying the private storage by layout. The same Linux tests pass, and swapping the subpixel-order and hint-style fields in the reader fails thehintingassertion. The Windows test's three PATH entries are now oneENVIRONMENT_MODIFICATIONlist.ctest --show-only=json-v1on a scratch project shows the old three-string form set only the first entry plus a stray property, and the joined form sets all three.python3 tools/check_conventions.py --base origin/main: all checks passed.python3 tools/pr_overlap.py: no open PR implements this export. #16892 implemented it untildc4fdb67afdropped it, along with itsFontOptions.cppreader; the two PRs now share only libcairo's count line.maineaec74e322. Both counts were recounted against the 73 stubs left inExport.cpp;main's count lines still said 117 and 89. The same Linux tests pass, plusguest_cairo_regions,guest_cairo_context,guest_cairo_surface_user_data,guest_cairo_graphics_stateandguest_cairo_path.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
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:15:41Z.
Review: COMMENTED
Read
92464009abagainstmain.I compared
FtFontOptions.cppwith Cairo 1.18.0_cairo_ft_font_options_substituteand its wrapper, and the logic matches: theFcPatternGet == FcResultNoMatchpresence checks, theFcPatternDelplusFC_RGBA_NONEpath, the RGB and FULL defaults, the order of the four blocks, and the early return on a failed add. The nil/NULL early return matchescairo_font_options_status. The test's expected values match upstream, including out-of-range enums, and 123 is the right count againstmain's 124.Overlap. #16892, opened two minutes earlier, also implements
ii895dyBjMo(inFontFace.cpp), removes the same stub and edits the same count line, so the "no other open PR implements the same functions" box isn't accurate. Its version doesn't follow upstream (hinting from hint metrics, missingrgba, no presence checks), so this one should be the one kept; the two need coordinating.CMakeLists.txt:46-49.set_tests_propertiesreads name/value pairs, soENVIRONMENT_MODIFICATIONgets only the libcairo entry, and the libfontconfig string becomes the name of a junk property whose value is the libc entry. It works today only because the prx libraries share one output directory. Joining the three into one;-separated string fixes it.FtFontOptions.cpp:43-59. Thememcpydepends on the privateCairoFontOptionsStoragefield order inFontOptions.cpp, and the nil check callscairo_font_options_copy(nullptr). A small reader inFontOptions.cppwould keep this from breaking silently when that struct grows, for example with thelcd_filterthis PR records as debt.Not run here; this is from reading the code against the 1.18.0 sources.
AI-assisted: yes.