Skip to content

fix(fonts): subset Inter by script with unicodeRange - #250

Open
faisalahammad wants to merge 1 commit into
WordPress:trunkfrom
faisalahammad:fix/194-subset-inter-fonts
Open

faisalahammad wants to merge 1 commit into
WordPress:trunkfrom
faisalahammad:fix/194-subset-inter-fonts

Conversation

@faisalahammad

Copy link
Copy Markdown

Description

Fixes #194

Inter is the text font, so it loads on every page. The theme shipped the full variable fonts (341 KiB normal, 376 KiB italic), with every script and every stylistic set, even on pages with only Latin text.

This PR splits each Inter file into one file per script (latin, latin-ext, cyrillic, cyrillic-ext, greek, greek-ext, vietnamese, plus a symbols file for everything else) and gives each fontFace in theme.json a unicodeRange. The browser now only downloads the files a page needs.

File loaded on a Latin page Before After
Inter normal 341 KiB 71 KiB
Inter italic 376 KiB 78 KiB

What changed:

  • assets/fonts/inter/: 16 subset files replace the 2 full files. Both variable axes (opsz, wght) and the copyright and license strings are kept. Stylistic sets and character variants are dropped, since the theme turns none of them on. tnum and case are kept.
  • theme.json: one fontFace per subset with its unicodeRange. Latin is listed last, so it wins where ranges overlap.
  • bin/subset-inter.py: regenerates the subsets from an Inter release and prints the fontFace entries. It exits with an error if any character from the original font ends up in no subset.
  • CONTRIBUTING.md: a short "Updating Inter" section.

bin/ and CONTRIBUTING.md stay in this repository and don't ship with the theme.

Screenshots

No visual change. The text renders the same, only the downloaded files are different.

Testing Instructions

  1. Activate the theme and open the home page with DevTools open. In the Network panel, turn on "Disable cache" and filter by "Font".
  2. Reload. Only inter-var-normal-latin.woff2 (about 71 KiB) loads for Inter.
  3. Open a post with italic text. Only inter-var-italic-latin.woff2 (about 78 KiB) loads for italic Inter.
  4. Check that weights, headings, italics and numbers look the same as on trunk.
  5. Add a paragraph with Привет мир, Γειά σου κόσμε and Tiếng Việt. Each renders in Inter, and the matching -cyrillic, -greek and -vietnamese files load.
  6. Add → ½ ① to a paragraph. These render in Inter from the -symbols file.
  7. In the Site Editor, open Styles > Typography and check that Inter shows and renders in the canvas.
  8. Switch to a style variation with another text font and check that no Inter file loads for body text.

npm run lint passes (stylelint, PHPCS, theme validation).

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus
Used for: Writing the subsetting script and the theme.json entries. I reviewed the changes and tested the theme myself.

- Split Inter into per-script woff2 subsets
- Add bin/subset-inter.py to regenerate them
- Document the update steps in CONTRIBUTING.md

Inter is the text font, so it loads on every page. The browser now only
downloads the scripts a page uses. Latin pages load about 71 KiB of Inter
instead of 341 KiB.

Fixes WordPress#194
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: faisalahammad <faisalahammad@git.wordpress.org>
Co-authored-by: elphizu <suryakantupadhyay@git.wordpress.org>
Co-authored-by: courtneyr-dev <courane01@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions github-actions Bot added documentation Improvements or additions to documentation [Area] Assets Issues or PRs that touch theme assets (fonts, images, audio, or the screenshot) [Area] Global Styles Issues or PRs that touch theme.json or the base stylesheet. labels Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Assets Issues or PRs that touch theme assets (fonts, images, audio, or the screenshot) [Area] Global Styles Issues or PRs that touch theme.json or the base stylesheet. documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inter font files aren't subset: 341 KiB loads on every page

1 participant