Skip to content

Fonts over FreeType, HarfBuzz and Fontconfig - #22

Merged
colemancda merged 15 commits into
masterfrom
feature/fonts
Dec 3, 2026
Merged

colemancda merged 15 commits into
masterfrom
feature/fonts

Conversation

@colemancda

Copy link
Copy Markdown
Member

Adds LinuxFonts, the fonts contract (org.pureswift.fonts.Face) over FreeType, HarfBuzz and Fontconfig, through AppRuntime's HostFontFace. It needs PureSwift/AppRuntime#38, which adds DynamicFonts and RuntimeFonts.

  • Finding fonts: a name is looked up among the bundle's fonts, then with Fontconfig by PostScript, family or full name. Fontconfig always answers with something, so its match is checked against the name, and a name the system doesn't have is nil. The system font is Fontconfig's sans-serif, serif or monospace at the weight; rounded is sans-serif. The bundle's fonts are also added to Fontconfig with FcConfigAppFontAddFile.
  • Shaping: the line is split into runs by face, each scalar going to this face or to Fontconfig's match for it, with marks, joiners and variation selectors kept with the character before. HarfBuzz shapes each run in points. A line whose first run is right to left is laid out run by run from the right; mixed directions aren't reordered as a bidi algorithm would.
  • Glyphs: metrics come from the face's design units, with cap and x heights from H and x. Images are unhinted at the size times the scale: gray coverage, or premultiplied RGBA from FreeType's BGRA. For bitmap-only fonts, the nearest strike is used. Outlines are unscaled and converted to points.
  • Registered in the runner and listed among the packager's modules. New dependencies: swift-freetype, swift-harfbuzz and FontConfig.

Tests, from Inter in the fixtures: registration and names, the system font in each design, metrics in points, kerning and calt turned off by feature, fallback, images at two scales, outlines, and the contract's answers from HostFontFace.

They ran on macOS with Homebrew's FreeType, HarfBuzz and Fontconfig, in a package that links this branch's sources. This package doesn't resolve right now, on master too: Cacao's develop needs a StatusNotifier product that the pinned DBus revision lacks. They haven't run on Linux yet.

@colemancda
colemancda merged commit 11896c9 into master Dec 3, 2026
2 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