Skip to content

Commit

Permalink
Default to font-display: swap; closes KaTeX#2242
Browse files Browse the repository at this point in the history
Google fonts seem to default to swap, and mixing them with katex makes it so that katex is invisible briefly on page load, unlike google fonts which make use of fallbacks while loading. This would unify their behavior.

Ideally there'd be an option for this, and a ?display=swap in the cdn url (like google fonts: https://developers.google.com/fonts/docs/css2#use_font-display), but I don't know if jsdelivr supports that!
  • Loading branch information
FreyaHolmer committed Mar 21, 2024
1 parent 5677f37 commit 2258850
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fonts.less
Expand Up @@ -2,6 +2,7 @@
@use-ttf: true;
@use-woff: true;
@use-woff2: true;
@font-display: swap;

.use-woff2(@family, @family-suffix) when (@use-woff2 = true) {
src+: url('@{font-folder}/KaTeX_@{family}-@{family-suffix}.woff2') format('woff2')
Expand Down Expand Up @@ -37,6 +38,7 @@
.use-ttf(@family, @suffix);
font-weight: @weight;
font-style: @style;
font-display: @font-display;
}
}

Expand Down

0 comments on commit 2258850

Please sign in to comment.