fix: load fontconfig via dlopen on Linux and fix bundled fallback font#21
Merged
Conversation
Two Linux-only fixes that together let `cargo install termdown` work on bare servers and make headings degrade gracefully when no system font is available: - font-kit now uses the `source-fontconfig-dlopen` feature on Linux, so building requires neither the fontconfig dev package nor pkg-config; the shared library is loaded lazily at runtime. CI now installs only the runtime `libfontconfig1` to prove this. - Probe for libfontconfig via dlopen before using SystemSource; when it's absent at runtime, degrade to the bundled font instead of panicking deep in the FFI layer. - Replace the corrupt bundled fallback (an HTML file shipped as a font since v0.1.0) with OFL-licensed Source Serif 4 SemiBold, and add a test that parses the bundled font so a bad asset can't regress. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
font-kit pulls freetype-sys unconditionally on Linux (no feature gates it off), and freetype-sys links the host libfreetype whenever pkg-config finds a freetype2.pc. The ubuntu-latest image ships that .pc but not the matching libfreetype.so dev symlink, so dropping libfontconfig1-dev broke linking with `unable to find library -lfreetype` (clippy passed because it never links). Point pkg-config at an empty dir in the Linux CI steps so freetype-sys compiles its bundled copy statically instead — the same path a real `cargo install` takes on a bare server with no dev packages. Document the freetype-from-source behavior in README/CHANGELOG. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Why
Two Linux-only problems that bit
cargo install termdownon bare servers:cargo install termdownfailed on any machine withoutlibfontconfig1-dev/fontconfig-devel.What changed
source-fontconfig-dlopenfeature so building needs neither the fontconfig dev package norpkg-config; the shared library is loaded lazily at runtime. macOS/Windows use CoreText/DirectWrite and never pull fontconfig.libfontconfig.so.1/libfontconfig.soviadlopenbefore constructingSystemSource. If it's missing at runtime, fall back to the bundled font instead of panicking deep in the FFI layer.fonts/LICENSE-SourceSerif4.md), plus a regression test that parses the bundled font and checks it renders a glyph, so a bad asset can't regress.libfontconfig1(no-dev), proving the build doesn't need the dev package while still exercising the runtime font-discovery path.[Unreleased]entry.Test plan
make checkgreen locally (fmt-check + clippy-D warnings+ tests).bundled_fallback_font_is_a_valid_fonttest guards the asset.libfontconfig1.🤖 Generated with Claude Code