<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>High-Performance Web Fonts</title>
    <link>https://www.highperformancewebfonts.com</link>
    <description>Tools and resources on how to use web fonts without sacrificing page loading speeds</description>
    <lastBuildDate>Fri, 31 Jan 2025 08:24:45 +0000</lastBuildDate>
    <generator>Stoyan&apos;s first Rust program</generator>
    <item>
      <title>Font Jargon</title>
      <link>https://www.highperformancewebfonts.com/read/font-jargon</link>
      <description><![CDATA[<p>Typeface, font-face, font-family, font collection, web font... do all of these just mean <em>font</em>? And what <em>is</em> a font exactly? Let's take a minute to define some words more precisely, at least their use in web development context (as opposed to traditional printing). After all, unambiguous terms always help our understanding of a concept.</p>
<h2>Font and Typeface</h2>
<p>All in all, there are <em>two</em> biggies: <em>font</em> and <em>typeface</em>. A typeface is a <strong>design</strong> of all characters and glyphs and numbers and symbols that match the <em>type designer</em>'s aesthetic and vision. You cannot use a typeface directly, it's just the blueprint. A font is one particular <strong>implementation</strong> of the design. A font you can use.</p>
<p>If you think in terms of object-oriented programing, you can think of the typeface as a class and the font as an object. Typeface is the recipe, a font is a specific instance. For example, <em>Avenir</em> is a typeface, <em>Avenir Book</em> is a font. <em>Menlo</em> is a typeface, <em>Menlo Bold</em> is a font. So is <em>Menlo Italic</em>, as are <em>Menlo Regular</em> and <em>Menlo Bold Italic</em>.</p>
<p>As you can imagine a <em>font</em> can be a heavy (bold) implementation of the typeface, or a slanty (italicized) one. Or condensed, or narrow, or a version 2.0 of the original design. For example Helvetica Neue is a new version of the same Helvetica typeface. (Once upon a time in the printing world a font also meant an instance of the typeface of a specific <em>size</em>, like 12pt)</p>
<p>Let's take a look at Menlo:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/def-menlo2.png" alt="Menlo collection" /></p>
<p>The screenshot above shows opening the Font Book app on a Mac, finding Menlo, right-clicking and then selecting Validate. In the font validation you can see <code>Menlo.ttc</code> file. TTC stands for True Type Collection.</p>
<h2>Collection</h2>
<p>So we come to the definition of the next term - a collection. A <em>collection</em> is just a container file for a group of fonts.</p>
<p>Here's the Fonts directory on a Mac, you can see some <code>ttc</code> (true type collection), some <code>ttf</code> (true type font) and <code>otf</code> (open type font)</p>
<p><img src="https://highperformancewebfonts.com/i/posts/def-dir.png" alt="Fonts directory" width="300"></p>
<p>A font is a specific instance of a typeface and usually lives in a TTF, OTF, etc file. Or optimized for the web as WOFF2 (formerly WOFF). Whereas a <em>collection</em> is a bundle of <em>fonts</em>.</p>
<h2>Font-family</h2>
<p>In CSS we don't write "typeface" anywhere, but we do use <code>font-family</code>. These are very much synonymous but not quite the same.</p>
<p>For example <em>Avenir Next</em> and <em>Avenir Next Condensed</em> are two font-families but both are derived from the same Avenir typeface (design). There are several <em>fonts</em> within each <em>family</em>, all coming from the same <em>typeface</em>.</p>
<p><img src="https://highperformancewebfonts.com/i/posts/def-avenir-next.png" alt="Avenir Next" width="250"></p>
<p><img src="https://highperformancewebfonts.com/i/posts/def-avenir-next-condensed.png" alt="Avenir Next Condensed" width="300"></p>
<p>In these two particular cases there's one <em>family</em> per one <em>collection</em>, but it's not a rule. For example the <em>fonts</em> that make up the Arial Narrow <em>font-family</em> are spread around in their own TTF files:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/def-arial-narrow.png" alt="Arial Narrow" width="300"></p>
<p>What defines which fonts come together in a family? I don't think there's a rule, it's up to the designer or the design studio (a.k.a. a <em>type foundry</em>) to make that call. Could've "condensed" Avenir-based fonts be part of the Next family? Maybe. The common pattern seems to be that the weights (e.g. heavy, bold, regular, thin, ultra thin) and their italics versions together make up a family.</p>
<h2>Web font</h2>
<p>Also known as a "custom font", the term <em>web font</em> refers to a font that is transfered over the network as a file, as opposed to being read from the file system and being provided by the operating system. Sometimes you need to download two or three fonts to make up the family (e.g. regular, bold, italic)</p>
<p>(Believe it or not, my young padawan, there was a time when you were not able to fetch font files from the network and your only options were whatever is pre-installed on the user's computer. Hence the "custom" word, at least initially)</p>
<h2>Font face</h2>
<p>OK, so we have a typeface and a font. What's <code>@font-face</code> then, as seen in CSS?</p>
<p>You can think of font face as synonymous to font. It's still a specific implementation of a typeface with its boldness, italicize-ness, size and so on. The <code>@font-face</code> declaration needs a source (<code>src</code>) which is either a local <em>font</em> file or a remote <em>web font</em> file.</p>
<p>In these <code>@font-face</code> declarations you touch the real instances, the fonts. Otherwise you work with the families. Let's see.</p>
<h2>CSS</h2>
<p>To specify how text is rendered in CSS you either have a block that styles a specific selector in which case you refer to the <em>family</em>...</p>
<pre class="prettyprint">
.hello {
  font-family: Avenir;
}
</pre>
<p>... or a <code>@font-face</code> where you use a <em>font</em> in a <code>src</code></p>
<pre class="prettyprint">
@font-face {
  src: url('/SpecialElite-Regular.woff2') format('woff2');
}
</pre>
<h3>CSS: font-family</h3>
<p>In the first case you ask for a <em>family</em>. The browser then decides besed on your other CSS (bold, italics) which specific font to use. (It might even "fake" your desired font, if for example you ask for bold, but the operating system only has a regular.)</p>
<p>If you inspect this in your developer tools:</p>
<div style="text-align: center; border: 1px solid orange; font-family: Arial; font-weight: bold">font-family: Arial; font-weight: bold</div>
<p>In Chrome you'll get:</p>
<pre>
Family name: Arial
PostScript name: Arial-BoldMT
</pre>
<p>In Firefox:</p>
<pre>
Fonts used: Arial
Arial Bold
</pre>
<p>And if you do this:</p>
<div style="text-align: center; border: 1px solid orange; font-family: Arial; font-style: italic">font-family: Arial; font-style: italic</div>
<p>In Chrome you'll get:</p>
<pre>
Family name: Arial
PostScript name: Arial-ItalicMT
</pre>
<p>In Firefox:</p>
<pre>
Fonts used: Arial
Arial Italic
</pre>
<p>So you can see that the <em>family</em> is always Arial, that's what <code>font-family: Arial</code> asks for. But the specific <em>font</em> used depends on the other specs such as <code>font-weight</code> and <code>font-style</code>. The browser tools are a little cryptic and not always useful (hello Safari, why do you only give us the family?) but you get the picture.</p>
<h3>CSS: font-face</h3>
<p>Somewhat confusingly in <code>@font-face</code> you also have <code>font-family</code> but this time you decide how to name it. When you have a few fonts of the same family you load them in separate <code>@font-face</code> declarations but you keep the family name the same (e.g. "SoSpecial"):</p>
<pre class="prettyprint">
@font-face {
  font-family: SoSpecial;
  src: url('/SpecialElite-Regular.woff2') format('woff2');
  font-weight: normal;
}

@font-face {
  font-family: SoSpecial;
  src: url('/SpecialElite-Bold.woff2') format('woff2');
  font-weight: bold;
}

/* Later... */

.boo {
  font-family: SoSpecial;
}
</pre>
<h3>CSS local()</h3>
<p>In <code>@font-face</code> you can use <code>local()</code> fonts and tweak them. That's the basis of a font fallback technique (hey <a href="https://highperformancewebfonts.com/tools/fafofal">I have a tool!</a>). When using <code>local()</code> you must specify a <em>font</em>, not a <em>family</em>.</p>
<pre class="prettyprint">
@font-face {
  font-family: fallbackCourier;
  src: local("Courier New Bold");
  ascent-override: 78%;
  descent-override: 29.68%;
  line-gap-override: 0%;
  size-adjust: 92.64%;
}
</pre>
<p>This is the big distinction and, I think, the point of the whole article:</p>
<blockquote>
<p><strong>use families in <code>font-family</code> and fonts in <code>local()</code></strong></p>
</blockquote>
<h2>Wrapping up</h2>
<p>OK, now you know the terms:</p>
<ul>
<li>Typeface: the overall design of all squiggles</li>
<li>Font: a specific instance of a typeface</li>
<li>Font face: also an instance of typeface. Has special meaning in CSS.</li>
<li>Family: a bunch of fonts that make sense together. One typeface may have several families. One family has a several fonts.</li>
<li>Collection: a file that bundles a bunch of fonts, usually a whole family of them.</li>
<li>Web font: one you download over the web</li>
<li>Type foundry: a place where typefaces are born, fonts are forged and families are argued over</li>
</ul>
<h2>What's Arial?</h2>
<p>So knowing all of the above, can you answer the questions: what is Arial?</p>
<p>A typeface? A family? A font?</p>
<p>The answer is - all of the above. That's confusing. That's why this article is trying to shed some light on the definitions.</p>
<p>First of all Arial is a <em>typeface</em>. It's a design based on which a number of <em>families</em> are created: e.g. Arial Narrow, Arial Black and ... yup, one simply called Arial. And the Arial <em>font-family</em> consists of a few <em>fonts</em>: Arial Bold (.ttf), Arial Italic, Arial Bold Italic and... yup, one simply called <code>Arial.ttf</code> instead or maybe <em>Arial Regular</em>.</p>
<p>That's true for many of the most common fonts: Times New Roman, Helvetica... They exist simultaneously as typefaces, font-families and fonts. That's common so much so, that when you use <code>local()</code> you expect what you usually type in <code>font-family</code> to just work. E.g. <code>local(Arial)</code>, <code>local(Helvetica)</code>.</p>
<p>But then you go <code>local(Avenir)</code> and (boom!) it doesn't work in Chrome. Because Avenir is a typeface (and also a family) but not a font. <code>Avenir Roman</code> is a font, <code>Avenir Book</code> is a font, <code>Avenir</code> is not.</p>
<h2>Note on variable fonts</h2>
<p>A variable font format allows for continuous weights and other "axis". So for example you don't need a separate file for bold vs regular. Based on the definitions discussed in this article, you can see how one <em>variable font</em> file can host a whole <em>family</em>.<i class="circle"><s></s></i></p>
]]></description>
      <guid>https://www.highperformancewebfonts.com/read/font-jargon</guid>
      <pubDate>Mon, 27 Jan 2025 08:01:01 +0000</pubDate>
    </item>
    <item>
      <title>It&apos;s time to ditch BlinkMacSystemFont and -apple-system</title>
      <link>https://www.highperformancewebfonts.com/read/ditch-BlinkMacSystemFont-and-apple-system</link>
      <description><![CDATA[<blockquote>
<p>TL;DR: Delete <code>BlinkMacSystemFont</code> and <code>-apple-system</code> from all your CSS, replace with <code>system-ui</code></p>
</blockquote>
<p>When you peek under the hood of a popular site, say GitHub.com, you can probably see a <code>font-family</code> declaration like:</p>
<pre class="prettyprint">
font-family: -apple-system, BlinkMacSystemFont, ...[snip]... sans-serif,
</pre>
<p>Here's a peek into the aforementioned GitHub's source:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/blink-github.png" alt="Developer tools inspecting github.com" /></p>
<h2><code>-apple-system</code>?</h2>
<p>What is this funny looking font? Prefixed with a <code>-</code> even?</p>
<p>From what I can tell at some point (MacOS El Capitan) Apple introduced a lovely font called San Francisco and thought iOS and MacOS UIs should have a consistent modern look. And feel. And font. And so <code>-apple-system</code> was born. Kinda like: dear developer, you don't need to know the exact actual font, just call <code>-apple-system</code> and we'll take care. We may change San Francisco in the future, but don't you worry your pretty head, the generic <code>-apple-system</code> will always work.</p>
<p>And so <code>-apple-system</code> is not a specific font but acts as a generic family for CSS purposes, just like e.g. <code>serif</code>, <code>monospace</code> and <code>sans-serif</code>. It's not a W3C standard generic family keyword, of course. Who has time to go through a standards body? That's why probably the awkward <code>-</code> prefix, just like a non-standard CSS property or value.</p>
<p>El Capitan is ancient history BTW, it was released 2015. This is Safari 9 we're talking. Your site probably doesn't work very well on it. My site (the one you're reading) for example raises an invalid certificate warning in El Capitan (at least in the <a href="https://browserstack.com">browserstack</a>'s setup). That's how old.</p>
<p>Anyway, moving on.</p>
<h2><code>BlinkMacSystemFont</code>?</h2>
<p>At some point (v55) looks like Chrome jumped on the idea. But hey, they can't put an brand name like Apple (<code>-apple-system</code>) in their offering. Hence <code>BlinkMacSystemFont</code>. <em>Blink</em> as in the Chrome's rendering engine, <em>Mac</em> as in Macintosh, <em>System</em> as in <code>-apple-system</code> and <em>Font</em> for good measure.</p>
<p>Chrome 55 is old too, released 2016. Your site maybe doesn't work all that great in it.</p>
<h2><code>system-ui</code></h2>
<p>Eventually some sort of reason came into the picture. Maybe an adult entered the room, I don't know. But a W3C-proper generic family name <code>system-ui</code> came into being to replace both of <code>BlinkMacSystemFont</code> and <code>-apple-system</code>. From my testing <code>system-ui</code> shows up since Safari 11 in High Siera OS. And in Chrome 56.</p>
<p>That's still ancient history. Both browsers were released in 2017. Remember when you tested your site in Safari 11? I don't either.</p>
<p>Firefox also joined the <code>-apple-system</code> madness until version 92 added <code>system-ui</code> too.</p>
<h2>Current state</h2>
<p><a href="https://highperformancewebfonts.com/tests/blonk/blink.html">Here's a test page</a> I loaded in a bunch of browsers.</p>
<p>Today's FF and Safari still support <code>-apple-system</code> in addition to <code>system-ui</code>. Both of these generic font families render the same <code>.SF NS</code> font. They are aliases of each other.</p>
<p>Today's Chrome still supports <code>BlinkMacSystemFont</code> in addition to <code>system-ui</code>. Both render the same <code>.SF NS</code> font.</p>
<h3>What about Windows?</h3>
<p>No Windows users were hurt in this whole Apple-specific debacle. On Windows none of <code>BlinkMacSystemFont</code> or <code>-apple-system</code> ever worked. But <code>system-ui</code> works and renders Segoe UI. Ladies and gentlemen, here's my test page rendered in Edge:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/blink-edge.jpg" alt="Testing on Windows" /></p>
<h2>So what's a dev to do?</h2>
<p>(If you skimmed the content so far, let me summarize: <code>system-ui</code> was added looong time ago to replace both <code>BlinkMacSystemFont</code> and <code>-apple-system</code>. You don't need these two anymore.)</p>
<p>So.</p>
<ol>
<li>Search all your CSS for occurrences of <code>BlinkMacSystemFont</code> and replace with <code>system-ui</code> (if not already there).</li>
<li>Rinse, repeat the same with <code>-apple-system</code>: search all your CSS for occurrences of <code>-apple-system</code> and replace with <code>system-ui</code> (if not already there).</li>
</ol>
<p>Results! Cleaner, leaner CSS, no outdated remnants of Web history and no more confusion.</p>
<p>If you're not into fonts and just want a nice sans-serif font, use:</p>
<pre class="prettyprint">
font-family: system-ui, sans-serif;
</pre>
<p>... and move on with your life. This will make you page work in Chrome 1 and even earlier.</p>
<h3>Bonus random observations</h3>
<p>At some point SF (as in the <em>.SF NS</em> family name) was standing for <em>San Francisco</em>. Now it appears to stand for <em>System Font</em>. No biggie.</p>
<p><code>.SF NS</code> is a real font (you can actually locate the file <code>SFNS.ttf</code> on your Mac computer) but for some strange reason it cannot be used with <code>local()</code>. It's not a valid family name either (<code>font-family: .SF NS</code> doesn't work). It's a font that is there but not addressable by name. I hope Apple fixes this and let us use it with <code>local()</code> as a nice fallback font for web fonts.</p>
<p>In El Capitan the system font behind the scenes was actually named <code>.SF NS Text</code>. Since Catalina it's <code>.SF NS</code> (no "Text"). Whoop-de-doo.</p>
<p>Chrome 55 that introduced <code>BlinkMacSystemFont</code> also works on Mac OS versions <em>before</em> El Capitan, so before the whole system font debacle. What's a browser to use as a "system" font before the "system" fonts were introduced? Just pick another nice sans-serif. In Yosemite that happen to be a font called <code>.Helvetica Neue DeskInterface</code> (what's with them <code>.</code> dots, may I ask?)</p>
<p>Other generic family names are introduced later, such as <code>ui-monospace</code> and <code>ui-rounded</code>. That's nice, but the "ui" part turned into a prefix rather than a suffix. So we're "forever" cursed to double-guess ourselves... was it <code>system-ui</code> or was it <code>ui-system</code>. Welp.</p>
<p>An <a href="https://booking.design/implementing-system-fonts-on-booking-com-a-lesson-learned-bdc984df627f">article</a> by booking.com reveals a funny thing where some IE (remember IE!?) and Edge versions see the <code>-</code> in <code>-apple-system</code> and decide the whole thing that follows is a non-standard value they can safely ignore. Times New Roman here we come!</p>
<h3>Note</h3>
<p>The history bits in this post are my deduction of what happened based on testing. If I got something wrong, please correct me<i class="circle"><s></s></i></p>
]]></description>
      <guid>https://www.highperformancewebfonts.com/read/ditch-BlinkMacSystemFont-and-apple-system</guid>
      <pubDate>Sat, 25 Jan 2025 09:12:05 +0000</pubDate>
    </item>
    <item>
      <title>Extreme Font Subsetting</title>
      <link>https://www.highperformancewebfonts.com/read/extreme-subsetting</link>
      <description><![CDATA[<p>Font subsetting is when you create a smaller version of a font with <em>some</em> of the characters from an source font. <strong>Extreme</strong> font subsetting is like normal font subsetting but up a notch (or is it <em>down</em> a notch?) - where <em>only a handful</em> of characters are supported.</p>
<p>Think of a logo. Instead of an image, you can use a font file where only the characters that make up the name of the company are present. That's pretty extreme as subsettings go, but it may be handy sometimes.</p>
<p>In this site for example, I've subset the web font <em>Special Elite</em> to only contain the characters "H, i, g, h, -, P, e, r, f, o, m, a, n, c, (space), W, b, F, t, s" which are enough to spell the site name "High-Performance Web Fonts" and the logo <strong>HPWF</strong>.</p>
<p>Here's how the characters look in the tool <a href="https://wakamaifondue.com">wakamaifondue.com</a>:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/extreme-waka.png" alt="20 characters" /></p>
<p>And the glyphs shown in <a href="https://fontdrop.info">fontdrop.info</a>:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/extreme-drop.png" alt="24 glyphs" /></p>
<p>As you can see characters are not the same as glyphs.</p>
<h2>A new font is born</h2>
<p>So naturally, when I tried to use the same extremely subset font for any other H1 titles, I have missing characters:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/ransom-cou.png" alt="Ransom-like" /></p>
<p>For example my subset has no T, A, I, p, (, ) and so on. Probably a bit more obvious with <em>Menlo</em> fallback:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/ransom-menlo.png" alt="Ransom-like" /></p>
<p>But I kinda like it. Gives you that murdery ransom letter vibe.</p>
<p>And so, by accident a new "font" is born: let's call it <em>Ransom</em>. A combination of extremely subset <em>Special Elite</em> and a fallback.</p>
<p>Good idea? I dunno. But certainly an option<i class="circle"><s></s></i></p>
]]></description>
      <guid>https://www.highperformancewebfonts.com/read/extreme-subsetting</guid>
      <pubDate>Fri, 24 Jan 2025 08:10:29 +0000</pubDate>
    </item>
    <item>
      <title>On the Origin of Cross</title>
      <link>https://www.highperformancewebfonts.com/read/on-the-origins-of-cross</link>
      <description><![CDATA[<p>A browser decides to download a web font after:</p>
<ol>
<li>Content is ready</li>
<li>CSS is ready</li>
<li>It appears that some content will indeed need the web font</li>
</ol>
<p>It's often late enough in the page rendering that the content in question is initially rendered in a fallback font (or not shown at all, depending on <code>font-display</code>). To prevent this you can preload the font using an HTTP header or a <code>link</code> in the <code>head</code> of the document. Like so:</p>
<pre class="prettyprint">
&lt;link
  rel="preload"
  href="https://highperformancewebfonts.com/SpecialElite-Regular-subset.woff2"
  as="font"
  type="font/woff2"
  crossorigin="anonymous"
/&gt;
</pre>
<p>This way you warn the browser that the font is going to be needed very soon and the browser can download it early for you.</p>
<p>This article is about the importance of <code>crossorigin</code> part of the code above.</p>
<p>The chunk of time (the initial download of resources) especially resources in the <code>head</code> (known as "tight mode" in Chrome) is critically important. And if you lie to the browser by making it download someting that won't be needed, it will complain. Like so:</p>
<blockquote>
<p>The resource https://highperformancewebfonts.com/SpecialElite-Regular-subset.woff2 was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate <code>as</code> value and it is preloaded intentionally.</p>
</blockquote>
<p>We don't want that.</p>
<p>But we do get that if we forget the <code>crossorigin</code> in the <code>link</code> tag. <strong>Even if the font is on the same domain.</strong></p>
<p>See for yourself with these couple of test pages:</p>
<ul>
<li><a href="https://highperformancewebfonts.com/tests/xorigin/xorigin.html">With a <code>crossorigin</code></a> - all peachy</li>
<li><a href="https://highperformancewebfonts.com/tests/xorigin/no-xorigin.html">Without a <code>crossorigin</code></a> - two console warnings</li>
</ul>
<p>Here's what the result of omitting the <code>crossorigin</code> looks like:</p>
<p><img src="https://highperformancewebfonts.com/i/posts/on-the-origins-of-cross.png" alt="Screenshot of preloading with no crossorigin" /></p>
<p>There are two error messages:</p>
<ul>
<li>one complaining that the preload is not used and directly pointing the blame at the <code>crossorigin</code>.</li>
<li>second one complaining that the preloaded font was unused</li>
</ul>
<p>Additionally <strong>the font is downloaded twice</strong>! So the first error message is actually kinda wrong. Found but not used, you say? Well, it's sorta used because it causes the extra download. And we know that because the "initiator" of the first download points to the <code>link preload</code>. (The second download initiator points to the ether, to the end of the html file, past the closing <code>/html</code>)</p>
<p><img src="https://highperformancewebfonts.com/i/posts/on-the-initiation.png" alt="Network initiation" /></p>
<h2>To summarize</h2>
<p>Always add <code>crossorigin</code>, even if the font is on the same domain. If you don't, not only you don't win anything, but you add an extra download at the worst possible time (initial tight-mode downloads)</p>
<h2>Browsers</h2>
<p>Firefox and Chrome exhibit this behavior. Safari is happy without the <code>crossorigin</code>, when the font is on the same domain at least.</p>
<h2><code>crossorigin</code> value</h2>
<p>The proper use is <code>crossorigin="anonymous"</code>. The attribute <code>crossorigin</code> without a value is fine. So is <code>crossorigin="crossorigin"</code> or <code>crossorigin="anything your heart desires"</code>. They all mean <code>crossorigin="anonymous"</code><i class="circle"><s></s></i></p>
]]></description>
      <guid>https://www.highperformancewebfonts.com/read/on-the-origins-of-cross</guid>
      <pubDate>Thu, 23 Jan 2025 08:54:54 +0000</pubDate>
    </item>
    <item>
      <title>Testing for local() support with the FontFace API</title>
      <link>https://www.highperformancewebfonts.com/read/testing-for-locally-installed-fonts</link>
      <description><![CDATA[<p>Sometimes you want to know if a certain font is available on the user's device. This can be used for evil (hello fingerprinting!) but maybe also for good (hello <a href="https://highperformancewebfonts.com/tools/fafofal/">FaFoFal</a>!).</p>
<p>Usually people use rendering text to a hidden "canvas" (e.g. a <code>div</code>) and measuring the expected width compared to a default font.</p>
<p>There's a better way - using the <code>FontFace</code> constructor:</p>
<pre class="prettyprint">
const hasAvenir = await new FontFace('meh', 'local("Avenir Book")').load().then(
  () =&gt; true,
  () =&gt; false
);
</pre>
<p>What's going on here?</p>
<ul>
<li><code>meh</code> is just string, useless in this case</li>
<li>usually we use <code>url()</code> to load an external font file, but here the trick is to use <code>local()</code></li>
<li>we're trying to load a local font that goes by the name "Avenir Book"</li>
<li>the <code>load()</code> method returns a promise where you can return <code>true</code> if the font is available or <code>false</code> if there's a <code>NetworkError</code> exception. (Funny that it's a <em>network</em> exception for a local load, but that's not really important)</li>
</ul>
<h2><code>local()</code> vs <code>font-family</code></h2>
<p>There are differences between using <code>local('Font name')</code> and <code>font-family: Font name</code>. See <a href="https://calendar.perfplanet.com/2024/fabulous-font-face-fallbacks/">this writeup</a> for details.</p>
<p>In practice for example <code>font-family: Avenir</code> works fine across browsers (on systems that have Avenir, e.g. Mac OS), but <code>local('Avenir')</code> may not. At the time of writing, it works in Firefox but not in Chrome. However <code>local('Avenir Book')</code> works in both.</p>
<p>The code above works just like the browser would when using <code>local()</code> for real and not just for testing. If that's what you want (I know I do, for the Fafofal tool) -- great. If not, it's back to measuring widths<i class="circle"><s></s></i></p>
]]></description>
      <guid>https://www.highperformancewebfonts.com/read/testing-for-locally-installed-fonts</guid>
      <pubDate>Thu, 16 Jan 2025 06:56:12 +0000</pubDate>
    </item>
    <item>
      <title>Is there such a thing as a web-safe font?</title>
      <link>https://www.highperformancewebfonts.com/read/web-safe-fonts</link>
      <description><![CDATA[<p>Says <a href="https://en.wikipedia.org/wiki/Web_typography#Web-safe_fonts">Wikipedia</a>: "Web-safe fonts are computer fonts that may reasonably be expected to be present on a wide range of computer systems, and used by Web content authors to increase the likelihood that content displays in their chosen font."</p>
<p>Yes, reasonably expected. But that doesn't mean really expected. For example <a href="https://medium.com/emails-hteumeuleu/fonts-in-html-emails-2a554a24edfb">this article</a> points out that even Arial and Times New Roman are not present on some Android distributions.</p>
<p>And, as I found out today (Thanks <a href="https://www.tunetheweb.com/">Barry</a>!) working on this here web site, Courier New is not available on iOS. Let's repeat this again.</p>
<p>Courier.</p>
<p>Arial.</p>
<p>Times New stinkin' Roman!</p>
<p>If these are not "safe", <em>there is no such thing as a web-safe font</em>.</p>
<p>On this site I use a web font for headings and I had a local Courier fallback:</p>
<pre class="prettyprint">
@font-face {
  font-family: fallbackCourier;
  src: local("Courier New Bold");
  ascent-override: 78%;
  descent-override: 29.68%;
  line-gap-override: 0%;
  size-adjust: 92.64%;
}
</pre>
<p>Now I've added Menlo as a fallback too:</p>
<pre class="prettyprint">
@font-face {
  font-family: fallbackMenlo;
  src: local("Menlo Regular");
  ascent-override: 77.2%;
  descent-override: 30.8%;
  line-gap-override: 0%;
  size-adjust: 92.34%;
}
</pre>
<p>Note: "Menlo Regular". Because <code>local("Menlo")</code> doesn't work, at least not in Chrome. As with the <a href="https://calendar.perfplanet.com/2024/fabulous-font-face-fallbacks/#how_we_can_do_even_better_or_8220that8217s_enough_arial8221">Avenir debacle</a>, Menlo is a collection of fonts, not a font itself.</p>
<p>Here's a Font Book screenshot to to show the Menlo <em>ttc</em> (<em>c</em> as in <em>collection</em>)</p>
<p><img src="https://highperformancewebfonts.com/i/posts/menlo.png" alt="Menlo collection of fonts" /></p>
<p>Time to lay this "web-safe" expression (that has been with us since forever) to sleep<i class="circle"><s></s></i></p>
]]></description>
      <guid>https://www.highperformancewebfonts.com/read/web-safe-fonts</guid>
      <pubDate>Thu, 16 Jan 2025 06:28:07 +0000</pubDate>
    </item>
  </channel>
</rss>