feat(libfreetype): implement font metadata queries #15408
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15408"
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 Noxy-HNR on 2026-11-03T06:25:42Z.
What
Implement
FT_Get_BDF_Property,FT_Get_BDF_Charset_ID,FT_Get_Sfnt_LangTagandFT_Get_WinFNT_Headerinlibfreetypeinstead of throwing import placeholders. The queries accept this project's existing guest-face adapter, preserve face-owned string lifetimes and translate the Windows native FNT header into explicit guest LP64 fields.Contracts follow public FreeType and the already bundled backend at
37515cf56ba3349656049edbed89ffc6f6466f2d: BDF/property implementation, SFNT language tags, and FNT headers. The library's existing inventory supplies the named NIDs. Console ABI, backend version and interoperability between separately inventoried modules remain unverified in debt; no title compatibility claim.Merge coordination at readiness refresh: newer #15439, #15442, #15444, #15447 and #15468 cover gzip, Multiple Masters, face settings and color APIs. Their current source additions do not implement these four metadata queries, but share the library CMake target, export inventory, umbrella and debt file. Preserve
src/FontMetadata.cpp,include/FontMetadata.hpp, the typed declarations and the new output guards when combining them. No combined build with that newer stack is claimed.Tested
Readiness update at
f112f2b1ecb6aebfd19d7928c34d06d4d230530c, includingmainat4f41f4c375: addressed the requested guest-output guard fix. Every metadata output guard is checked, both charset destinations are validated before the backend writes either one, and denied access returnsFT_Err_Invalid_Argumentwithout changing the output. New Windows regressions allocate real guest direct memory, make it read-only, verify whole-buffer preservation (including both partial charset-output failures), then restore write permission and verify success. All six focused tests pass; both export variants also pass after an assertion-based mutation control that incorrectly returned success for a refused guard. Public-header audit now passes for 406 libraries / 28,302 exports. Hosted checks pass on this head.Windows 11 Home x86-64 (10.0.26300), GCC 15.2 / Ninja, Release, full configuration with recursive submodules and
BUILD_TESTING=ON:libsdependency, including NID patching, plus the focused test executables.guest_legacy_freetype_metadata,_nid,guest_freetype,guest_freetype_sfnt_names,guest_freetype_postscript_info, and_nid.-Wall -Wextra -Werrorcompilation, public-header audit (405 libraries / 28,213 exports), conventions and whitespace checks pass.mainatd1ae628bc2f62459cce1e9872ba5632c938c71f2.tools/pr_overlap.py --branch codex/libfreetype-font-metadatareports no shared files or exports across 1,714 open PRs; exact-name search also found none.No Linux or PS5 hardware/title run.
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-03T06:34:47Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The metadata wrappers ignore failed guest write guards and still write through output pointers, which can fault in the host process for read-only guest mappings.
What I ran
4df93c21c8871f53b79abcc88783fee13e4224b8against based1ae628bc2f62459cce1e9872ba5632c938c71f2; the stack checker reports a clean merge preview.Results
Commands and unedited outputs
Precheck report check table (copied verbatim):
The precheck's failed helper invocations reported that
tools/pr_abi_audit.pyandtools/pr_test_quality.pywere absent from its isolated snapshot. I reran both from the workspace against the exact base/head or changed paths.ABI audit output (the command above prints only the first line):
Test-quality heuristic output:
Manual registration check:
core/libs/prx/libfreetype/CMakeLists.txtregistersGuestLegacyFreeTypeMetadata.cppwithadd_test_executableand registers its tests withadd_test.Stack checker output:
Negative control
Not run: the new C++ tests need an exact-head build. No safe no-build control was available to make the read-only mapping guard fail.
Findings
Blocking
GuestArena::HostWrite::Open()reports whether the requested guest range can be written. On Windows,BeginHostWritereturnsfalsefor a mapped range without write permission. The new BDF-property, SFNT-language-tag and WinFNT-header wrappers ignore that result and immediately write to the guest pointer; the charset wrapper passes its guarded output pointers directly to FreeType without checking either guard. A read-only guest output can therefore fault in host code instead of returning a controlled error. Check each applicable guard before writing or passing an output pointer to FreeType, return an appropriate FreeType error when access is refused, and add a regression using a read-only guest mapping.Non-blocking
Sources
HostWrite::Open()exposes guard failureOpen()before writingNot verified
To get this to a good state
Check every guest-output guard before dereferencing or passing its pointer to FreeType, return an appropriate error on refused access, and add a read-only-mapping regression. I will rerun the precheck, ABI audit, test-quality inspection, and relevant checks on the updated head; build/runtime checks remain separate.