A site names the fonts it uses in site.yaml, and Hypertekt does the rest. Each font is downloaded when the site is
built and served from the site itself, with the @font-face rules written for you. Fonts come from
Fontsource, which has every Google Font and more.
Name a font
The examples here use Slow Blink, a cat cafe. Slow Blink sets its text in Inter and its headings in Fraunces:
fonts:
Inter: 400 700
Fraunces: 600
Each line is a family, by its name as Fontsource has it, then the weights wanted. Then use each family by its name in your CSS, as you would any font:
:root {
--sans: Inter, system-ui, sans-serif;
--display: Fraunces, Georgia, serif;
}
body {
font-family: var(--sans);
}
h1,
h2 {
font-family: var(--display);
}
List the font your text is in first. Its regular weight is preloaded on every page, so the text shows in it as soon as it can.
Weights and italics
Name each weight the site’s CSS uses, and only those, since visitors download each one:
400 700is the regular and bold weights.400iis the italic of the 400 weight:Source Sans 3: 400 400i 700.italicat the end adds the italics of every weight listed:Lora: 400 700 italic.
A family’s name can end in a number, like Source Sans 3. The name is the line’s key, so it isn’t read as a weight.
Variable fonts
A variable font has every weight in one file. For a font that’s variable, a range is often smaller than three or more separate weights:
fonts:
Fraunces: 300..900 italic
A variable font can have other axes too, like Fraunces’s optical size (opsz) and softness (SOFT). Name those in the
long form, then set them in CSS with font-variation-settings:
fonts:
Fraunces:
weights: 300..900
axes: { SOFT: 0..100 }
h1 {
font-family: Fraunces, Georgia, serif;
font-variation-settings: "SOFT" 100;
}
A file with other axes in it is bigger than one with only weights, so only name the axes the site uses. Optical size follows the text’s size automatically.
Other alphabets
Fonts come with Latin and extended Latin, which covers English and most European languages. For others, name the alphabets in the long form:
fonts:
Noto Sans:
weights: 400 700
subsets: [latin, cyrillic, greek]
Each alphabet is its own file, and a visitor’s browser only downloads the files with characters the page uses. Naming an alphabet a page doesn’t use costs visitors nothing.
What Hypertekt does for you
- Serves the fonts from your site. Linking
fonts.googleapis.comsends every visitor’s address to Google, and adds two connections before the text shows in its font. A site that still links Google Fonts gets a warning saying to name the family infontsinstead. - Writes the
@font-facerules in every page’s<head>, before your stylesheets, withfont-display: swap. Text shows right away in a fallback, then changes to the font when it arrives. - Makes a fallback the same size as the font. Each family gets
"<Family> fallback": Arial, Times New Roman or Courier New, scaled to the font’s own measurements, so text doesn’t move when the font arrives. Hypertekt adds the fallback after the family wherever your stylesheets name it, so you don’t have to. - Caches the files for good. Each file’s address has the font’s version, so browsers keep it.
What’s checked
- A family Fontsource doesn’t have is an error, with the closest names. So is a weight, an axis, italics or an alphabet the family doesn’t have, with what it does have.
- A weight no
font-weightin your CSS uses is a warning, since visitors would download it for nothing. - A family your CSS uses with no bold is a warning when the site has headings, strong text or a
font-weightof 600 or more, since browsers fake the bold by smearing the regular. The same goes for italics in the font listed first, when the site has emphasis.
The Code tab offers Fontsource’s families as you type a family’s name, then that family’s own weights, italics and
axes, and checks how fonts is written. Whether a family has what’s asked of it is checked when the site
builds, so it shows in the Checks tab and in tekt build.
Everything fonts can say is in the reference, under
Fonts.