Problem/Motivation

The "Inter" font is loaded twice. Once for the Navigation module, and once for the Admin theme.

Changes

  • Added a core/font library. It provides Inter v4 (variable), taken from the Navigation module.
  • Split the font into unicode-range subsets in core/misc/fonts/: latin, latin-ext, cyrillic, cyrillic-ext, greek, greek-ext, vietnamese, and symbols.
  • Preloaded inter-latin.woff2 through the library fonts key.
  • Added inter-variables.css. It defines --font-inter and --font-inter-size-adjust.
  • Added metric-adjusted fallback faces for Helvetica Neue and Arial, regular and bold. They use size-adjust, ascent-override, descent-override
    and line-gap-override.
  • Navigation and Default Admin now depend on core/font. They no longer ship their own Inter files.

Testing steps

  1. Walk through the theme as normal. There should be minimal visual differences (v4 of the font is oh-so-slightly-narrower than the previous version that the theme used)
  2. Look at DevTools. The font should be preloaded.
  3. Ensure the proper font is pulled down (this should be the latin variation for most people)

Performance improvements

(note these were generated by Claude.

Measured with Playwright and headless Chrome for Testing. Values are medians of 5 cold loads per page. The browser cache was off, and each run used a new session. Viewport: 1440×900. Network: Chrome DevTools "Slow 4G" preset. Before: main. After: the issue branch.

Before After
Font files 2: default_admin/font/inter.woff2 (219.5 KB), navigation/assets/fonts/inter-var.woff2 (337.5 KB) 1: core/misc/fonts/inter-latin.woff2 (103.6 KB)
Font preloads 2 1
Font bytes 557.0 KB 103.6 KB (−81%)
Total bytes, /admin/content 868 KB 416 KB (−52%)
Total bytes, /node/add/page 749 KB 297 KB (−60%)
Page Metric (Slow 4G) Before After Change
/admin/content FCP / LCP 3756 ms 3664 ms −92 ms
Fonts loaded 6825 ms 4225 ms −2600 ms (−38%)
Load event 6842 ms 4972 ms −1870 ms (−27%)
CLS 0.0087 0.0062 −0.0025
/node/add/page FCP / LCP 2844 ms 2764 ms −80 ms
Fonts loaded 5892 ms 3308 ms −2584 ms (−44%)
Load event 5904 ms 3314 ms −2590 ms (−44%)
CLS 0.0001 0.0000 −0.0001
  • LCP is a text element and equals FCP on both branches. With font-display: swap, paint does not wait for fonts.
  • Without throttling, timings on the local ddev site are within noise on both branches.
  • The test pages contain English text only, so only inter-latin.woff2 loads. Pages with Cyrillic, Greek or Vietnamese text also load those subsets (17–41 KB each).
  • CSS and JS aggregation was off. This adds the same bytes to both totals.

Visual differences

There are visual differences, which come from moving it from Inter v3 (which was used by default_admin) to Inter v4 (which was used by Navigation). Most of the text-width change comes from v4's new optical size axis. Navigation already used v4, so it looks the same as before.

In practice:

  • Body and form text (13–14px) is almost unchanged.
  • 16px text is about 1% narrower.
  • Headings are noticeably narrower and tighter. A 32px page title is 6–9% narrower.

AI Disclosure

I used Claude for the majority of this work. I manually reviewed and tested the code personally

Issue fork drupal-3578936

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

catch created an issue. See original summary.

godotislate’s picture

Core Navigation uses inter-var as well, so it'd make sense to share between default_admin and navigation somehow and make it available to Mercury.

Per @catch in slack:

We could subset the font, so non-roman glyphs go in their own files then are loaded conditionally based on brower locale.

We might need to ship the files in core/assets or something.

Looking at inter docs it has > 2000 glyphs so subsetting ought to help a lot

mherchel’s picture

Yeah, this definitely needs to be tackled.

We need some discussion on how, though.

Requirements

  1. Same font needs to load when Navigation and Admin are loaded
  2. Same font needs to load when only Navigation is loaded
  3. Same font needs to load when only Admin is loaded

My first thought is to move the font file + accompanying CSS into core.libraries.yml. Then both the module and theme (and any other contrib) can reference them. Thoughts?

catch’s picture

My first thought is to move the font file + accompanying CSS into core.libraries.yml. Then both the module and theme (and any other contrib) can reference them. Thoughts?

I'd thought about moving the font itself, but not the CSS yet, on the basis that if the font file is cached different font declarations would probably not result in a double load. But adding a core library for the CSS itself makes a lot of sense. If we subset the font it will increase the complexity of the CSS too so much easier to maintain in one place, will also mean preloading is centralised too etc.

pameeela’s picture

Issue tags: +DrupalSouth 2026
bernardm28’s picture

Recommended architecture

Instead of:

  • Gin
    • themes/contrib/gin/dist/media/font/inter.woff2
  • Mercury
    • themes/.../fonts/inter-var.woff2
  • Navigation/default_admin
    • core/themes/default_admin/font/inter.woff2

have:

core/assets/vendor/inter/
├── InterVariable.woff2
└── inter.css

or equivalent.

Then expose it through something like:

# core/core.libraries.yml

inter:
  version: VERSION
  css:
    base:
      assets/vendor/inter/inter.css: {}

And:

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./InterVariable.woff2") format("woff2");
}

Inter's current variable font supports the wght axis from 100–900, so that declaration is appropriate.

Then consumers depend on:

dependencies:
  - core/inter

rather than defining their own copy.

So:

core/navigation
↓
core/inter
↑
default_admin
↑
Gin
↑
Mercury

The important benefit is that all of them end up requesting something like:

/core/assets/vendor/inter/InterVariable.woff2

the exact same URL.

That is what actually eliminates the network duplication.

Why merely changing Gin isn't enough

Suppose you change this: /gin/fonts/inter.woff2 to: /gin/fonts/inter-var.woff2
while Mercury has: /mercury/fonts/inter-var.woff2

You still have:
GET /themes/contrib/gin/fonts/inter-var.woff2
GET /themes/mercury/fonts/inter-var.woff2

Even if those files are byte-for-byte identical, they're different resources from the browser's perspective.

So you'd potentially still download Inter twice.

This is why the comment on the core issue suggesting a shared core.libraries.yml asset is stronger than simply standardizing filenames.

Then subset it

Once there is one canonical Inter library, then subsetting becomes very attractive.

The Drupal discussion mentions that Inter contains more than 2,000 glyphs and specifically proposes putting non-Roman glyphs into separate subsets.

For example:

core/assets/vendor/inter/
├── inter-latin.woff2
├── inter-latin-ext.woff2
├── inter-cyrillic.woff2
└── inter.css

With:

/* Latin */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./inter-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF,
    U+0131,
    U+0152-0153,
    U+02BB-02BC,
    U+02C6,
    U+02DA,
    U+02DC,
    U+2000-206F,
    U+2074,
    U+20AC,
    U+2122;
}

Then another @font-face handles Cyrillic, etc.

The browser only downloads the ranges needed for the page.

For example:

/* Latin Extended */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./inter-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-024F,
    U+1E00-1EFF;
}

/* Basic Latin */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./inter-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF;
}
body {
  font-family: "Inter", sans-serif;
}

The browser handles the rest.

I'd consider this phase 2, though.

Phase 1 should be deduplication

The order I'd recommend for the Drupal issue is:

Standardize on Inter Variable.
Move the canonical font file into core.
Move the canonical @font-face CSS into core too.
Navigation/default_admin depend on that library.
Gin removes its bundled inter.woff2 and uses the core library.
Mercury uses the same library rather than its own copy.
Verify only one Inter request when combinations of those components are present.
Then add Unicode subsets.

That also satisfies the requirements raised in the issue:

same font when Navigation + Admin load, Navigation alone, or Admin alone.

Looks after chatting with AI.

The steps be:

  1. Create the new core library and just switch the current implementation there.
  2. Subset the font and try and get baseline on unicode characters.
mherchel’s picture

  • The fonts and CSS should live in core/misc/fonts
  • The library name should be font
  • We should also preload the font (see https://www.drupal.org/node/3588509). Lets start with preloading inter-latin.woff2, and we might want to create a followup to load the others if certain languages are active.
mherchel’s picture

Title: Use a variable inter font in the admin theme » Navigation module and Admin theme should use the same Inter font

mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Status: Active » Needs review
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes
catch’s picture

Issue tags: +front end performance

Is there something we can link to for the ascent/descent/line-gap overrides? I've seen this general technique discussed (making a system font take the same horizontal/vertical space as a web font so that there is no render blocking from the font) but not sure where to point. Ideally we'd link to both the technique and how the numbers were derived.

Also is there a way to do screenshots for before/after Inter loads to see what the effect is like? Maybe deleting Inter from disk would work so it ends up being a 404?

mherchel’s picture

StatusFileSize
new1.8 MB

Also is there a way to do screenshots for before/after Inter loads to see what the effect is like? Maybe deleting Inter from disk would work so it ends up being a 404?

The way I tested this is to set the font-inter variable to the fallback. If you add the following to line 84 of inter-variables.css, you can then use dev tools to toggle on/off inter, and also try the fallback fonts vs the non-modified fallback fonts.

  --font-inter: "Helvetica Neue", Arial, sans-serif;
  --font-inter: "Inter Fallback Helvetica Neue", "Inter Fallback Arial", sans-serif;

mherchel’s picture

StatusFileSize
new4.35 KB

Is there something we can link to for the ascent/descent/line-gap overrides? I've seen this general technique discussed (making a system font take the same horizontal/vertical space as a web font so that there is no render blocking from the font) but not sure where to point. Ideally we'd link to both the technique and how the numbers were derived.

I pointed Claude at https://developer.chrome.com/blog/font-fallbacks to do this, and had it use Chrome MCP server to use devtools to adjust the fonts to be as close as possible.

I'm also attaching a python script that it used to derive the numbers.

Ready for re-review!

mherchel’s picture

Another option (that i've done before) is use font-display: block instead of swap.

When using that, the browser will wait for the font for three seconds. Only then will it use the fallback instead of immediately showing the fallback.

markconroy’s picture

I haven’t tested this in a browser, but the MR code looks spot on to me.

If I had one gripe (but this might be more about all our CSS variables) it’s that instead of --font-inter we should preface all our variable names with --drupal-* such as --drupal-font-inter to lessen the possibility of variable name clashing.

I know with LocalGov Drupal, if we use Claro as a base theme, our --color-button clashes with Claro’s and ends up making node edit form buttons a dark purple with (unreadable) black text 

mherchel’s picture

Changes made! I also removed the unused --font-inter-size-adjust variable.

markconroy’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

catch’s picture

Status: Reviewed & tested by the community » Needs work

One comment nit and one real question on the MR.

mherchel’s picture

Status: Needs work » Needs review

Changes made!

markconroy’s picture

Status: Needs review » Reviewed & tested by the community

LGTM (again!)

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new98 bytes

The Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

alexpott’s picture

Spotted a double word in the MR comments that needs fixing too.

catch’s picture

Status: Needs work » Reviewed & tested by the community

Rebased for performance tests and resolved @alexpott's comment suggestion. Aiming to commit this once the pipeline is green again, moving to RTBC for now.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 3875e93cfd9 to main. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 3875e93c on main
    task: #3578936 Navigation module and Admin theme should use the same...
mherchel’s picture

Status: Fixed » Patch (to be ported)

Going to backport this to 12.0.x, 11.x, and 11.5.x.

Running into conflicts with the perf tests, so I'm going to set up some MRs first to ensure the tests pass.

mherchel changed the visibility of the branch 3578936-12.0 to hidden.

mherchel changed the visibility of the branch 3578936-inter-11.x to hidden.

  • mherchel committed 70ba90e4 on 12.0.x
    fix: #3578936 Navigation module and Admin theme should use the same...

  • mherchel committed 94035fde on 11.x
    fix: #3578936 Navigation module and Admin theme should use the same...

  • mherchel committed 9c18d2fe on 11.5.x
    fix: #3578936 Navigation module and Admin theme should use the same...
mherchel’s picture

Status: Patch (to be ported) » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

catch’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

godotislate’s picture

Title: Navigation module and Admin theme should use the same Inter font » [reopened for CR] Navigation module and Admin theme should use the same Inter font
Status: Closed (fixed) » Needs work

Consulted with other RMs, and this could use a CR documenting the new core/font library and how to use it.

godotislate’s picture

Issue tags: +Needs change record
mherchel’s picture

Title: [reopened for CR] Navigation module and Admin theme should use the same Inter font » Navigation module and Admin theme should use the same Inter font
Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.