Μετάβαση στο περιεχόμενο
fontstay.dev
Πηγαίος κώδικας στο GitHub
Θέμα
Προσομοίωση όρασης

Για ελέγχους σχεδίασης· δεν διορθώνει την αντίληψη των χρωμάτων.

Βοηθήματα ανάγνωσης

fontstay.dev

Προσθήκη γραμματοσειράς

Τρόποι προσθήκης γραμματοσειράς:

  • πληκτρολογήστε όνομα και επιλέξτε γραμματοσειρά από τη λίστα
  • επικολλήστε CSS ή σύνδεσμο Google Fonts ή Fontsource
  • σύρετε αρχείο γραμματοσειράς ή CSS

Φόρτωση του καταλόγου…

Τα αρχεία διαβάζονται στη συσκευή σας και δεν ανεβαίνουν ποτέ πουθενά.

Σύγκριση
Προβολή
Προσομοίωση
μέτρηση…

Μην αφήνετε τη σελίδα να «πηδά» όταν φορτώνει η γραμματοσειρά σας

Οι περιηγητές εμφανίζουν πρώτα το κείμενο σε εναλλακτική γραμματοσειρά και μετά βάζουν τη γραμματοσειρά ιστού σας. Αν οι δύο διαφέρουν σε μέγεθος, οι γραμμές αναδιπλώνονται διαφορετικά και η σελίδα «πηδά» (μετατόπιση διάταξης, που η Google μετρά ως CLS). Το fontstay δημιουργεί μια εναλλακτική που ταιριάζει με τα μετρικά της γραμματοσειράς σας, ώστε η εναλλαγή να μην κουνά τίποτα.

Χωρίς προσαρμογή, οι γραμμές αναδιπλώνονται ξανά και το περιεχόμενο μετακινείται. Με την προσαρμοσμένη εναλλακτική, όλα μένουν στη θέση τους.

Δεν υπάρχει ακόμη γραμματοσειρά ιστού: το άρθρο χρησιμοποιεί τη στοίβα γραμματοσειρών του συστήματος. Επιλέξτε μια γραμματοσειρά ή αφήστε ένα αρχείο οπουδήποτε.

Field notes · №7 · Typography & performance

Why the page jumps when a font loads

A web font arrives a moment after the text is first painted. Until then the browser shows a fallback, and when the real font takes over, every line can change its width and every block its height.

  • Glyph width

    Every typeface sets its letters at a different width, so the same sentence wraps at a different word.

  • Line height

    The font’s own ascent and descent and the line-height rule decide how much room a line takes.

  • Vertical metrics

    Ascent, descent and line gap live in the font file; a substitute with other numbers shifts the baseline.

  • Scripts and fallbacks

    Characters missing from the web font come from another family, which can make one line taller than its neighbours.

What moves, and why

Take a plain paragraph. In the fallback font it fills four lines; in the web font the same words need five. Everything below slides down by one line: that is a layout shift.

Width is only half of the story. Each font carries its own ascent, descent and line gap. With line-height: normal the browser builds the line box from them, so another font means another height even at the same size.

Inline elements add their own pressure: a bold run, an italic phrase, a superscript2 or a symbol such as ™ may come from another face and stretch the line it sits on.

Headings are the most visible victims. A large title that jumps by a few pixels drags the whole article with it, which is why headings and body text deserve separate fallbacks.

Text can also be re-balanced. Modern text-wrap: balance and text-wrap: pretty change where lines break, so test with and without them.

The cure is boring and effective: scale the fallback with size-adjust and give it the web font’s vertical metrics with ascent-override, descent-override and line-gap-override.

The best layout shift is the one nobody notices.
— a rule of thumb

A checklist for the next release

  1. Pick the fallback per system, not one for everybody.
  2. Compare regular, bold and italic faces separately.
  3. Test long and short lines, and with text-wrap on.
  4. Check scripts you do not read: Arabic, Japanese, Cyrillic.

Where a line gets its height

CauseEffect
Font sizeScales every metric
line-heightOverrides the font’s own metrics
Ascent and descentSet the content area of the line
Fallback glyphsCan raise a single line
Superscript and subscriptPush the line box up or down

Special characters

& © ® ™ § ¶ † ‡ • … – — « » “ ” ‘ ’ № € £ ¥ ¢ % ‰ ° ± × ÷ ≈ ≠ ≤ ≥ ∞ √ π → ← ↑ ↓ ½ ¼ ¾ ¹ ² ³ ℃ fi fl 0123456789 1/2 3/4 1st 2nd office affluent

@font-face {
  font-family: "Brand Fallback";
  src: local("Arial");
  size-adjust: 104.5%;
  ascent-override: 92%;
  descent-override: 24%;
}
body {
  font-family: "Brand", "Brand Fallback", sans-serif;
}
Set in two typefaces: the headings and the text come from different families. Switch the view above to compare the web font with its adjusted fallback.

Διαβάθμιση μεγεθών

  • 12 pxWhy the page jumps when a font loads
  • 16 pxWhy the page jumps when a font loads
  • 20 pxWhy the page jumps when a font loads
  • 28 pxWhy the page jumps when a font loads
  • 36 pxWhy the page jumps when a font loads
  • 48 pxWhy the page jumps when a font loads
  • 64 pxWhy the page jumps when a font loads
  • 80 pxWhy the page jumps when a font loads

Η γραμματοσειρά ιστού βρίσκεται πριν από τη γραμμή και η εναλλακτική μετά. Σύρετε τη γραμμή για να τη μετακινήσετε.