Skip to content

facade: plugins/text-freetype2: move 3 platform conditionals behind a per-platform layer #863

Closed

Description

@zackees

Inventory of platform conditionals in plugins/text-freetype2/text-freetype2.c (3 #ifs). Existing pattern: find-font-{cocoa.m,unix.c,windows.c}.

lines macro what the branch does
75 _WIN32 flag OBS_SOURCE_DEPRECATED on the source (Windows has the GDI+ text source)
512, 514 _WIN32, __APPLE__ DEFAULT_FACE = Arial / Helvetica / Sans Serif

Proposed facade

Add to the existing find-font-* files: ft2_platform_default_face() and ft2_platform_source_flags() declared in a shared find-font.h and implemented in find-font-windows.c, find-font-cocoa.m, find-font-unix.c.

Likely must stay

Nothing. CMake OS_MACOS / OS_LINUX... / OS_WINDOWS source selection (CMakeLists.txt:11,13,25,53) stays; it is the intended mechanism.

Test approach

Behaviour-preserving moves. Verify with: the plugin's native builds on each platform (ci-full label, since these are outside the quick gate), the existing cmocka tests where the moved function is testable, and ./lint. Where a facade function is pure (path/name/constant selection) add a small unit test per platform implementation. The #847 ratchet lint baseline must go down by the count moved.

Part of #847.

Activity

  1. zackees commented on Oct 16, 2026

    @zackees
    MemberAuthor

    Claiming: text-freetype2 facade.

    Plan (one PR, ci-full):

    1. ft2_platform_source_flags() and ft2_platform_default_face(), declared in a new text-freetype2-platform.h, implemented in three new dependency-free files text-freetype2-platform-{windows,cocoa,unix}.c that CMake picks per OS like the find-font-* files. One change from the plan above: not inside find-font-*, because those pull in fontconfig/Cocoa/GDI, and the new functions are pure constants that should be unit-testable without them.
    2. A small cmocka test for the Linux/FreeBSD implementation (face "Sans Serif", no deprecated flag), built into the test with just that file. The Windows and macOS values are checked by their native builds compiling the same expectations.
    3. text-freetype2.c loses its 3 conditionals; the ci: ratchet lint for platform conditionals in shared C/C++ (#847 step 1) #848 baseline drops the file.
  2. added
    claimed
    on Oct 16, 2026
  3. github-actions commented on Oct 16, 2026

    @github-actions

    Claim bot: claimed by @zackees. It expires after 48 h (8 h on critical issues) without a progress comment here or a push, comment or review on a linked PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions