diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-24 14:04:48 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-24 14:04:48 -0400 |
| commit | c11ad211f5d72b6ee2b48d80f25d16e3e85248eb (patch) | |
| tree | dd0b3de315e5a84b73e837c964c34020fd26caa4 /scripts/theme-studio/Makefile | |
| parent | a9277128cb59372db966b2cc4532bc4573103b38 (diff) | |
| download | dotemacs-c11ad211f5d72b6ee2b48d80f25d16e3e85248eb.tar.gz dotemacs-c11ad211f5d72b6ee2b48d80f25d16e3e85248eb.zip | |
fix(theme-studio): render nerd-icon glyphs in previews instead of tofu
The legend, dashboard, and package previews drew nerd-icon glyphs as empty boxes. The font-family never reached them: PREVIEW_FONT was spliced into inline style="..." attributes with a double-quoted family name, so the inner quote closed the attribute early and the font was silently dropped. Dropping the quotes fixes it. A no-space family name needs none.
I embedded the glyph font directly: Symbols Nerd Font Mono, encoded with fontTools (woff2_compress output is rejected by headed Chrome and Firefox), inlined as a data: URI under the unique family name ThemeStudioNerd so it resolves to the embed rather than a system-installed copy of the same name. The page is self-contained and renders on any clone.
I added a #fonttest gate that parses previewLines output and asserts the resolved font-family plus glyph coverage, plus a make font target that re-encodes the woff2 with fontTools.
Diffstat (limited to 'scripts/theme-studio/Makefile')
| -rw-r--r-- | scripts/theme-studio/Makefile | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/theme-studio/Makefile b/scripts/theme-studio/Makefile index 7b8430182..02540720e 100644 --- a/scripts/theme-studio/Makefile +++ b/scripts/theme-studio/Makefile @@ -16,7 +16,13 @@ OUT ?= ../../themes EMACS ?= emacs EMACSCLIENT ?= emacsclient -.PHONY: help test check check-generated coverage gen open theme theme-load theme-reload face-coverage-dump face-coverage face-coverage-diff +# Source TTF for the embedded nerd-icon font. `make font` re-encodes it to the +# committed woff2 with fontTools — NOT woff2_compress, whose output headed Chrome +# and Firefox reject (they render tofu) even though old-headless Chrome accepts it. +NERD_TTF ?= /usr/share/fonts/TTF/SymbolsNerdFontMono-Regular.ttf +NERD_WOFF2 ?= SymbolsNerdFontMono-Regular.woff2 + +.PHONY: help test check check-generated coverage gen open theme theme-load theme-reload face-coverage-dump face-coverage face-coverage-diff font # Scratch path for the face-coverage Emacs data dump. FACE_DUMP ?= /tmp/face-coverage-data.json @@ -36,6 +42,15 @@ help: @echo " make theme-reload JSON=x - Convert JSON, then cleanly reload its theme in current Emacs" @echo " make face-coverage - Regenerate face-coverage.org from the live Emacs daemon" @echo " make face-coverage-diff - Show the coverage delta vs the committed face-coverage.org" + @echo " make font - Re-encode the embedded nerd woff2 from NERD_TTF (fontTools)" + +font: + @python3 -c "import os,sys; from fontTools.ttLib import TTFont; \ +src='$(NERD_TTF)'; \ +sys.exit('NERD_TTF not found: '+src) if not os.path.exists(src) else None; \ +f=TTFont(src); f.flavor='woff2'; f.save('$(NERD_WOFF2)'); \ +print('wrote $(NERD_WOFF2) (%d bytes) from %s' % (os.path.getsize('$(NERD_WOFF2)'), src))" + @echo "now run: make gen (re-inlines the woff2 as a data: URI into theme-studio.html)" test: @./run-tests.sh |
