Skip to content

fontconfig: use what fontconfig gives when no listed system font exists - #254

Open
danjboyd wants to merge 1 commit into
gnustep:masterfrom
danjboyd:ai-policy/fontconfig-sans-fallback
Open

danjboyd wants to merge 1 commit into
gnustep:masterfrom
danjboyd:ai-policy/fontconfig-sans-fallback

Conversation

@danjboyd

@danjboyd danjboyd commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

With none of the fonts on the fontconfig backend's list installed, -defaultSystemFontName ended on "Helvetica", which such a system usually doesn't have. A machine with Noto and no DejaVu then found no system font and drew no text, though usable fonts were installed:

The font specified for NSFont, Helvetica, can't be found.
GSHorizontalTypesetter - Glyph generation with no font.

This finishes what #172 and #178 left of #170. They made -defaultBoldSystemFontName and -defaultFixedPitchFontName ask fontconfig; this asks it for sans-serif too, after the list, so systems which have a listed font look as they did. "Helvetica" stays as the name to end on when fontconfig has nothing.

Testing: Tests/cairo/defaultsystemfont.m gives fontconfig a directory holding one installed font that isn't on the list, and skips if there is none. It checks that the system font and the user font exist and that the system font has glyphs, which guards against the default naming a font nothing has. Against master d378734, with the cairo backend under Xvfb: without this change 3 of its 4 checks fail; with it all 4 pass. The whole test suite goes from 287 passed, 3 failed to 290 passed, 0 failed, and those 3 failures are this test.

Not covered: a system with no fonts at all, where there is still no font.

Investigated, reproduced and written up with AI assistance (Claude).

-defaultSystemFontName ended on "Helvetica", which a system with Noto and no
DejaVu doesn't have, so NSFont found no system font and no text was drawn,
though usable fonts were installed.  The bold and fixed-pitch defaults already
ask fontconfig.  Ask it for sans-serif here too, after the list, so that systems
which have one of the listed fonts look as they did.  "Helvetica" stays as the
name to end on when fontconfig has nothing.

Testing: Tests/cairo/defaultsystemfont.m gives fontconfig a directory holding
one installed font that isn't on the list, and skips if there is none.  It checks
that the system font and the user font exist and that the system font has glyphs,
which guards against the default naming a font nothing has.  Without this change
3 of its 4 checks fail; with it all 4 pass.

Not covered: a system with no fonts at all, where there is still no font.

AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code).
Co-Authored-By: Claude <noreply@anthropic.com>
@danjboyd
danjboyd requested a review from fredkiefer as a code owner November 6, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant