Remove embedded font blobs, improve font hinting#2
Open
kdedev wants to merge 1 commit intomarchaesen:mainfrom
Open
Remove embedded font blobs, improve font hinting#2kdedev wants to merge 1 commit intomarchaesen:mainfrom
kdedev wants to merge 1 commit intomarchaesen:mainfrom
Conversation
Remove 56MB of JetBrainsMono Nerd Font data embedded as C arrays in wld/font.c header files. The FT_New_Memory_Face fallback that loaded these embedded fonts is replaced with an error path - system-installed fonts via fontconfig should always be used. Additionally improve font rendering quality: - Use FT_LOAD_TARGET_NORMAL instead of FT_LOAD_DEFAULT for glyph loading, which enables the font's native hinting program for sharper glyphs - Use hintstyle=hintfull instead of autohint=true in the font string, preferring the font's own hinting instructions over FreeType's auto-hinter (better results for well-hinted fonts like JetBrains Mono) Binary size: 9.4MB -> 212KB (97.8% reduction) Repository size: ~56MB smaller (the .h files alone were 14MB each)
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.
Summary
Two related improvements to font handling: remove embedded font data that bloats the binary by 97%, and fix font rendering to produce sharp, legible text.
1. Remove embedded JetBrainsMono Nerd Font blobs
The problem
Four header files in
wld/embed the entire JetBrainsMono Nerd Font family as C arrays (Regular, Bold, Italic, BoldItalic). Each file is ~14MB, totaling 56MB of font data compiled into the binary.Why the embedded fonts aren't needed
The
FT_New_Memory_Facefallback inwld_font_open_pattern()only triggers whenmatchis NULL -- meaning fontconfig couldn't resolve any font at all. In practice:What changed
.hfiles fromwld/fontdatas[]andfontdatasizes[]arrays fromwld/font.cFT_New_Memory_Facefallback withDEBUGPRNT+goto error1(clean error path)2. Improve font rendering clarity
The problem
Text in st-wl is noticeably fuzzier than in other terminals (foot, kitty, alacritty). Characters with fine details --
m,w,0vsO,lvs1vsI,:vs;-- are harder to read, especially at common terminal sizes (12-16px) on 1080p displays.This is because st-wl uses suboptimal FreeType settings that produce blurry, poorly-hinted glyphs.
Root cause
Two settings work against each other:
FT_LOAD_DEFAULTfor glyph loading -- this doesn't specify a hinting target, so FreeType doesn't optimize glyph outlines for the actual rendering mode. Stem widths and character edges don't snap cleanly to pixel boundaries.autohint=truein the font string -- this tells fontconfig to ignore the font's own hand-tuned hinting instructions and use FreeType's generic auto-hinter instead. For well-hinted professional fonts like JetBrains Mono (which ships with carefully crafted TrueType hinting), the auto-hinter produces objectively worse results.Fix
FT_LOAD_DEFAULTFT_LOAD_TARGET_NORMALautohint=truehintstyle=hintfullFT_LOAD_TARGET_NORMALtells FreeType to optimize hinting specifically for the rendering mode being used (greyscale anti-aliasing). Glyph stems snap to pixel boundaries, producing sharper, more defined characters.hintstyle=hintfulluses JetBrains Mono's own hinting instructions -- professionally designed to maximize legibility at screen sizes -- instead of FreeType's one-size-fits-all algorithm.The result is noticeably crisper text that matches the rendering quality of other modern terminals.
Build verification
Clean build, zero warnings. Tested on Arch Linux with JetBrainsMono Nerd Font installed via system packages.