Skip to content

GraphiteText: outline fonts through FreeType, a trait on by default - #22

Merged
colemancda merged 8 commits into
masterfrom
feature/text-freetype
Nov 26, 2026
Merged

colemancda merged 8 commits into
masterfrom
feature/text-freetype

Conversation

@colemancda

Copy link
Copy Markdown
Member

Phase 3, seventh of the stack, against master. Independent of #21 (layouts).

  • FreeType package trait, on by default. CFreeType is a system library (freetype2 by pkg-config; libfreetype-dev and brew install freetype as providers). swift build --disable-default-traits leaves it out, and text keeps the built-in bitmap font. I built and tested both ways.
  • FreeTypeFace loads a font from a path or from memory (with the face index of a collection). Its glyphs are 8-bit coverage in the GlyphImage the text engine already draws, its metrics are FontInfo's from FreeType's size metrics, and every FreeType call goes through one lock, since faces aren't thread-safe. A font that is bold or italic itself says so, and other styles are drawn from its glyphs.
  • FontFinder finds installed fonts by family name, in any case, in the folders fonts live in on macOS and Linux (XDG's included): FreeType reads each file's family and style once, on first use, including every face in a collection. Its lookUp plugs into FontRegistry, so classic names resolve to installed families through the substitutes list.
  • Deviation from the plan: the plan names FontConfig for lookup. FontConfig is Linux-only and an extra dependency, so this scans the font folders instead, which works the same on both platforms. A FontConfig-backed lookup can still be given to FontRegistry from outside.
  • Limit: one face per family is returned (its regular style); bold and italic of a family are drawn from it.
  • CI installs FreeType and DejaVu on Linux and FreeType on macOS, and runs the tests once more with the trait off.
  • Tests run against whatever fonts the machine has, and are skipped where there are none: glyphs and metrics across sizes, a missing character, loading from memory and the two load errors, the finder's case-insensitive lookup, and drawing through the registry.

@colemancda
colemancda force-pushed the feature/text-freetype branch from f69263b to 84ea90f Compare November 26, 2026 07:19
@colemancda
colemancda merged commit 0c71629 into master Nov 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant