LATX, feat: Add experimental font wrapper family - #402
Draft
LaurenIsACoder wants to merge 11 commits into
Draft
Conversation
Move the ELF64 guest export and host symbol checks out of the Cairo-specific preflight into a reusable helper. Cairo retains the same strict activation policy and rejection reasons. Validated by a full LoongArch latx-x86_64 product build. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Add the integer, floating-point, aggregate, stack-argument, and variadic dispatch shapes required by the FreeType, Fontconfig, and Xft public ABIs. The signatures were checked against the x86_64 guest headers and compiled as part of the LoongArch product build. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Add complete guest export catalogs for FreeType, Fontconfig, and Xft, and register them as one experimental font group. A whole-family preflight requires matching guest exports and host symbols before any member is activated. Handle x86_64 variadics and by-value aggregates explicitly. Bridge synchronous FreeType outline and list callbacks, reject unsupported callback-bearing APIs without passing guest addresses to host code, and clear wrapper tracking state on unload. Xft variadic entry points are rebuilt through native Fontconfig and Xft APIs. The implementation is derived in part from Box64's MIT-licensed wrappers with attribution retained, but corrects signatures against public headers and avoids its fixed-slot and global-stream fallback hazards. Validated with a full LoongArch latx-x86_64 product build, direct FreeType/Fontconfig/Xft probes, a FreeType callback round trip, atomic preflight rejection, and real-display gtkperf. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Make Cairo activation depend on the experimental font family and run the same whole-family preflight before loading the native Cairo wrapper. If FreeType, Fontconfig, or Xft is incompatible, disable font and let dependency pruning disable Cairo before host objects can cross into a partial native stack. The cairo_ft_* object crossings remain fail-closed until FT_Face and FcPattern ownership and lifetime rules are wired across the wrappers. Validated by the LoongArch product build and atomic preflight rejection probe. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Custom wrappers can require host helper symbols that are not guaranteed by scanning the guest library exports alone. Let each wrapped library declare unconditional native prerequisites and reject the whole library family before activation when one is missing. Cover the Cairo font-face helpers, the FreeType face lifetime calls, the Fontconfig FT_Face query, and the Xft helper calls used by custom wrappers. Validated by the LoongArch product build. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Expose narrow inter-wrapper helpers for retaining host FT_Face objects, marking Cairo-borrowed faces, and reading an FcPattern FC_FT_FACE value. Keep borrowed faces separate from caller-owned FreeType faces. FT_Done_Face now rejects a face while Cairo has lent it to guest code, and wrapper teardown clears the associated bookkeeping without handing guest pointers to native code. Validated by the LoongArch product build and the FT_Face ownership probe. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Pass native cairo_font_options_t and FcPattern objects through cairo_ft_font_options_substitute and cairo_ft_font_face_create_for_pattern using the public Cairo argument order. Retain pre-opened FT_Face objects with Cairo user data, and track the ownership and thread of faces borrowed by cairo_ft_scaled_font_lock_face until the matching unlock. Fail with a Cairo error face when the required lifetime reference cannot be established. Validated by the LoongArch product build, native entry probes for the Cairo FT APIs, and three gtkperf runs without Pango warnings or X errors. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Pango can build FcFontSet containers with the guest allocator while storing host-native FcPattern pointers. Passing those containers to native Fontconfig lets the host allocator free guest memory. Transfer guest-owned containers into host-owned storage before native destruction, and keep native-owned sets on the direct path. Validated with the normal LAT product build and repeated LoongArch gtkperf runs using the font and Cairo groups. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
FcScandir executes its selector and comparator inside host Fontconfig. Passing guest function addresses directly would make LoongArch execute x86 code. Use a thread-local call context and native thunks for guest callbacks while preserving native callbacks on the direct path. Nested scans restore the previous context. Validated with the normal LAT product build and a LoongArch probe covering both callbacks with KZT disabled and the font group enabled. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Native FreeType can retain stream, memory, cache requester, debug hook, and FT_Generic callbacks after a wrapper returns. Synchronous raster callbacks also require native thunks. Guest function addresses cannot cross those boundaries directly. Add per-object callback state, reference and destruction tracking, safe callback-slot exhaustion, and a translator bridge for guest-visible generic finalizer pointers. Reject module classes, log handlers, compressed streams, and internal TrueType entry points that still lack a safe ABI. Validated with the normal LAT product build, deterministic reference-lifetime RED/GREEN coverage, GDB thunk-to-host evidence, and 20 repeated LoongArch callback-probe runs. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
XftLockFace exposes a host FT_Face whose public generic finalizers can be replaced by guest code. Xft may later destroy that face internally, outside the FreeType wrapper path. Guard each exposed face before and after guest access, keep it borrowed while locked, and refresh the bridge before Xft closes fonts. A bounded per-thread lock stack fails safely on invalid nesting. Validated with a deterministic LoongArch RED that hung in the unguarded native path, followed by 20/20 GREEN runs and GDB evidence for both guest-invoked and host-invoked finalizers. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增实验性的
fontKZT 库族,受控直通 FreeType、Fontconfig 和 Xft。font依赖。已在 LoongArch 本地图形环境完成验证:
ninja -C build64 latx-x86_64。LATX_KZT=1 LATX_KZT_ENABLE=font下连续 3/3 成功。LATX_KZT=1 LATX_KZT_ENABLE=cairo下连续 3/3 成功;日志确认自动选择font并命中 Cairo、FreeType、Fontconfig 的 KZT wrapper。未新增产品测试目标或提交临时探针。
Add the experimental
fontKZT library group for controlled native wrapping of FreeType, Fontconfig, and Xft.fontas a required dependency.Validated on a native LoongArch desktop environment:
ninja -C build64 latx-x86_64.LATX_KZT=1 LATX_KZT_ENABLE=font.LATX_KZT=1 LATX_KZT_ENABLE=cairo; logs confirmed automaticfontselection and KZT wrapper hits for Cairo, FreeType, and Fontconfig.No product test targets or temporary probes are included.