docs(sphinx_fonts): add multi-subset support, Mono weights, latin-ext#1034
Merged
docs(sphinx_fonts): add multi-subset support, Mono weights, latin-ext#1034
Conversation
why: Only weight 400 was downloaded. Bold monospace text (badge labels at font-weight 650, <strong> in code) used browser faux-bolding which looks noticeably worse than the real typeface weights. what: - Match IBM Plex Sans weight range: [400, 500, 600, 700]
why: Only the "latin" subset was downloaded. Characters outside basic Latin (accented letters like ñ, ř, ž common in contributor names and code comments) fell back to system fonts, breaking the typographic consistency of IBM Plex. what: - Add _UNICODE_RANGES dict mapping Fontsource subset names to CSS unicode-range descriptors for latin, latin-ext, cyrillic, cyrillic-ext, greek, and vietnamese - Add _unicode_range() lookup function with empty-string fallback for unknown subsets (omitting the descriptor = all codepoints) - Support "subsets" (list) config key alongside legacy "subset" (str) in _on_builder_inited — iterates all subsets in the download loop - Emit unicode-range in font_faces dict; template renders it in @font-face blocks so browsers only download subset files when characters from that range appear on the page (zero cost for pages that only use ASCII) - Preload uses the first (primary) subset only — typically "latin" - Update page.html template: conditional unicode-range line in @font-face blocks - Add 8 tests: _unicode_range (4), multi-subset builder-inited (2), legacy subset backward compat (1), preload primary subset (1)
why: Accented characters (ñ, ř, ž, ö) in contributor names, docstrings, and code comments fell back to system fonts. latin-ext covers U+0100-02FF and extended Latin ranges used across European languages. what: - Change "subset": "latin" to "subsets": ["latin", "latin-ext"] for both IBM Plex Sans and IBM Plex Mono - Total font files: 32 (2 fonts × 2 subsets × 4 weights × 2 styles) - Zero performance cost for ASCII-only pages: unicode-range descriptors tell the browser to skip latin-ext downloads when no extended chars appear on the page
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1034 +/- ##
=======================================
Coverage 81.02% 81.02%
=======================================
Files 28 28
Lines 2630 2630
Branches 492 492
=======================================
Hits 2131 2131
Misses 368 368
Partials 131 131 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
docs/_ext/sphinx_fonts.pyoverride with unicode-range supportTest plan
uv run py.test tests/docs/_ext/test_sphinx_fonts.py— 29 passeduv run ruff check .— all checks passeduv run mypy— no issues