Drupal core now provides a core/font library that makes version 4.0 of the Inter variable font available to themes and modules.
Previously, the Navigation module and the Admin theme each shipped separate versions of Inter, resulting in duplicate font downloads. Both now depend on the shared core/font library.
The library incorporates several front-end performance optimizations:
- Font preloading to enable earlier discovery and downloading of the Latin font subset.
- Font subsetting using
unicode-rangeto reduce download sizes by loading additional character sets only when needed. font-display: swapto allow text to remain visible while the web font downloads.- Metric-adjusted fallback fonts that closely match Inter's font metrics, minimizing layout shifts and visual differences when the web font loads.
- Shared font assets that eliminate duplicate downloads and improve browser cache reuse across themes and modules.
Using Inter in themes and modules
Themes and modules can use Inter by declaring core/font as a library dependency in their *.libraries.yml file.
my-library:
css:
base:
css/styles.css: {}
dependencies:
- core/font
The library provides the --drupal-font-inter CSS custom property, which includes Inter and its metric-adjusted fallback font stack.
.my-component {
font-family: var(--drupal-font-inter);
}
Themes and modules that currently bundle their own copies of Inter are encouraged to use this library instead.