Typefaces for the Web
- State of Text Rendering:
Subsetting:
-
What does vertical-align do?
-
☐ Gothic Fonts
-
☐ Disable font-synthesis. Force use the fonts/font-weights provided
Guidance on Choosing a Font
- Font choices
- UI Fonts
- Src: How to pick a Typeface for User Interface and App Design? - Pimp my Type
- Clear distinctions → lowercase L and uppercase I.
- Open Shapes
- Little contrast
- Tip: Uppercased small font-size is hard to read.
- Src: How to pick a Typeface for User Interface and App Design? - Pimp my Type
- UI Fonts
Font size
- Based on cap-size
- Deep dive CSS: font metrics, line-height and vertical-align - Vincent De Oliveira (iamvdo.me)
- Font size is useless; let’s fix it @ tonsky.me
Mono Font Choices
- weiweihuanghuang/fragment-mono: Helvetica Monospace Coding Font (github.com)
- The JuliaMono Typeface
- Commit Mono. Neutral programming typeface.
- displaay/Azeret: GF font from Displaay (github.com)
- Twilio Sans Mono (⭐)
OpenType
- Required Layout Features Guide:
- ccmp: Glyph Composition/Decomposition. This feature is used to compose or decompose one or more glyphs into a single glyph or multiple glyphs. For example, this feature can be used to create ligatures or split diacritics from base glyphs 12.
- locl: Localized Forms. This feature is used to substitute glyphs with forms that are preferred or required by a specific language or locale. For example, this feature can be used to change the shape of a letter depending on the language setting 1.
- mark: Mark Positioning. This feature is used to position diacritic marks relative to base glyphs. For example, this feature can be used to adjust the placement of an accent above a letter 1.
- mkmk: Mark to Mark Positioning. This feature is used to position diacritic marks relative to other diacritic marks. For example, this feature can be used to stack multiple accents above a letter 12.
- http://webtypography.net/toc/
- https://www.smashingmagazine.com/2022/10/typographic-hierarchies/
- Shorthand: font-variant
- font-variant-alternates
- font-kerning
- font-variant-caps
- scmp, c2sc, pcap, c2pc, unic, titl
- font-variant-ligatures
- clig, liga
- dlig
- hlig (Medieval font thing)
- calt
- font-variant-numeric
Ligatures
/* Keyword values */font-variant-ligatures: normal;font-variant-ligatures: none;font-variant-ligatures: common-ligatures; /* <common-lig-values> */font-variant-ligatures: no-common-ligatures; /* <common-lig-values> */font-variant-ligatures: discretionary-ligatures; /* <discretionary-lig-values> */font-variant-ligatures: no-discretionary-ligatures; /* <discretionary-lig-values> */font-variant-ligatures: historical-ligatures; /* <historical-lig-values> */font-variant-ligatures: no-historical-ligatures; /* <historical-lig-values> */font-variant-ligatures: contextual; /* <contextual-alt-values> */font-variant-ligatures: no-contextual; /* <contextual-alt-values> */
/* Global values */font-variant-ligatures: inherit;font-variant-ligatures: initial;font-variant-ligatures: revert;font-variant-ligatures: revert-layer;font-variant-ligatures: unset;Numeric
font-variant-numeric: normal;font-variant-numeric: ordinal;font-variant-numeric: slashed-zero;font-variant-numeric: lining-nums; /* <numeric-figure-values> */font-variant-numeric: oldstyle-nums; /* <numeric-figure-values> */font-variant-numeric: proportional-nums; /* <numeric-spacing-values> */font-variant-numeric: tabular-nums; /* <numeric-spacing-values> */font-variant-numeric: diagonal-fractions; /* <numeric-fraction-values> */font-variant-numeric: stacked-fractions; /* <numeric-fraction-values> */font-variant-numeric: oldstyle-nums stacked-fractions;
/* Global values */font-variant-numeric: inherit;font-variant-numeric: initial;font-variant-numeric: revert;font-variant-numeric: revert-layer;font-variant-numeric: unset;Variable Font
- font-optical-size
- font-stretch
- font-weight
- font-variation-settings
Font Stretch (Width | wdth)
| Absolute keyword value | Numeric value |
|---|---|
| ultra-condensed | 50% |
| extra-condensed | 62.5% |
| condensed | 75% |
| semi-condensed | 87.5% |
| normal | 100% |
| semi-expanded | 112.5% |
| expanded | 125% |
| extra-expanded | 150% |
| ultra-expanded | 200% |
Typography on Web. Amazeballs links. ⭐
Links on Typography | CSS-Tricks
List of topics in the 👆🏼article:
- How to pick fonts for UI and App Design
- Uniwidth typefaces for interface design (this one’s really good)
Uniwidth typefaces for interface design
- On legibility and Readability
- Font size is useless, let’s fix it
- The sans selection - Huge selection of fonts
- Plymouth Press - SVG Fonts/Characters
- Why should you self-host your Google Fonts in 2021
Font Performance
- ⭐ --- Best of the best article on subsetting:
- Maybe opt for sf-mono on MacOS, instead of loading twiliosansmono.
[!important] > Best practices for fonts (web.dev) Inlining font declarations and adjusting stylesheets may be a more effective approach.
Aftab’s notes: Inlining critical subset font for headers (for LCP/FCP) and above the fold text might work out. then later on we can use the full(latin + extended + symbols), which maybe won’t need preload.
- ☐ Need to experiment and see if preload / prefetch / early hints are required for the second set of subset fonts
- pixel-point/fontpie: Get your layout shifts optimized with a CLI-generated piece of CSS (github.com)
- ⭐ Best practices for fonts (web.dev)
Subsetting
-
What layout features can be removed, since we’re not serving content in any other language than English.
-
Remove the un-kerned set, and other required layout features for other languages.
-
Remove hinting and test.
-
⭐Creating font subsets | Dev Diary (markoskon.com)
- Archived here: Wayback Machine (archive.org)
-
☐ Create different subsets
- Latin
- Latin Extended
- etc.
-
Unicode Range Interchange (zachleat.com)
- Read more about this: Unicode Range Interchange---zachleat.com
- [[css/how-to-use-unicode-interchange]]
-
Unicode Character Reference:
-
⭐ --- Create subsets based on character/alphabets. Probably what I’ll end up using. Instead of alphabets though, I might need to do different ones for Headings (latin1 + a few symbols + layout features, all other categories of things in other font subsets): Font Subsetting Strategies: Content-Based vs Alphabetical — Cloud Four
-
Opentype font-features how to add them to the subset: ⭐How to subset a variable font | Clagnut by Richard Rutter - The
layout-featuresoption specifies which OpenType layout features to include, such as kerning, ligatures, numerals and alternate characters. In this example I’m usinglayout-features='*'to include all the features available. Instead, you can also add selected features to the default set. For examplelayout-features+=onum,pnum,ss01will keep the default set of features and addonum,pnumandss01(old-style and proportional numerals, and styleset 1). The default features includecalt,clig,kernandligaamong others. See the fonttools Documentation for more info onlayout-features.↑The command he used.
pyftsubset LiterataTT.ttf -unicodes="U+0020-007F, U+00A0-00FF, U+0100-017F, U+2000-206F, U+2070-209F, U+20A0-20CF, U+2100-214F, U+2200-22FF, U+FB00-FB4F" -layout-features='*' -flavor="woff2" -output-file="LiterataTT.woff2"[!info]
Character(s) Unicode (range) Basic Latin U+0020-007F Latin-1 Supplement U+00A0-00FF Euro sign U+20AC Apostrophe U+20BC Hyphen U+2010 En dash U+2013 Em dash U+2014 Left quote U+2018 Right quote U+2019 Single low quote U+201A Left double quote U+201C Right double quote U+201D Double low quote U+201E Bullit U+2022 Ellipsis U+2026 Single left pointing angle U+2039 Single right pointing angle U+203A
Tools
- zachleat/glyphhanger: Your web font utility belt. It can subset web fonts. It can find unicode-ranges for you automatically. It makes julienne fries. (github.com)
- Unicode Range Interchange (zachleat.com)
- Munter/subfont: Command line tool to optimize your webfont loading. Aggressive subsetting based on your font use, self-hosting of Google fonts and preloading (github.com)
- Free apps by Glyphs
- FontGoggles
- FontTableViewer
- fonttools/fonttools: A library to manipulate font files from Python. (github.com)
Font Fallback
#cls #fallback #fout #foit
Tools
- danielroe/fontaine: Automatic font fallback based on font metrics (github.com)
- pixel-point/fontpie: Get your layout shifts optimized with a CLI-generated piece of CSS (github.com)
Upcoming Features
- font-size-adjust (safari | webkit)
Font Caching
- ☐ max-age??
- ☐ immutable??
- ☐ CF only saves it for 24 hours.
- ☐ Does it get browser-cached, if so, for how long?≤m
Inline Layout | Text Box Adjustments
#trim #vertical-baseline #baseline
- CSS text-box-trim & text-box-edge | Can I use… Support tables for HTML5, CSS3, etc
- Deep dive --- calculating font metric overrides: [Notes on calculating font metric overrides [SHARED EXTENTALLY] (google.com)](https://docs.google.com/document/d/e/2PACX-1vRsazeNirATC7lIj2aErSHpK26hZ6dA9GsQ069GEbq5fyzXEhXbvByoftSfhG82aJXmrQ_sJCPBqcx_/pub
[!note] Overrides should ideally be calculated automatically by the browser. But in the meantime, until Safari’s font-size-adjust is implemented in all 3, other tools like fontaine need to be utilized.
Tools
Upcoming features
text-box-trim: both- `text-box-edge: cap alphabetic
- Reference: CSS
Checklist
- Create a tiny base subset, which has latin, and other things.
- Use the font-feature-settings to aggressively remove unnecessary layout features
- Use union interchange to create a second, third subset of other features
- LATIN + Punctuation + Common Symbols.
- LATIN A + LATIN B
- LATIN-ext
- ()
- Symbols
- LATIN-ext
- Greek, Cyrillic (based on the typeface support)
- Everything else