Replies: 1 comment 1 reply
-
almost 1 year in the thinking process :) https://wakamaifondue.com/ has a nice solution in their CSS sample how to handle the many variations and layout features and how to enable/disable them for a font. It's similar to how box-shadows are constructed. For readers' convenience, here's their rendered style sheet for Spartan (a Futura clone) by The League of Moveable Type.
An excerpt:/* @font-face declaration removed, see example file */
/* Set custom properties for each layout feature */
:root {
--league-spartan-variable-aalt: "aalt" off;
--league-spartan-variable-frac: "frac" off;
--league-spartan-variable-ordn: "ordn" off;
--league-spartan-variable-salt: "salt" off;
--league-spartan-variable-ss01: "ss01" off;
--league-spartan-variable-ss02: "ss02" off;
--league-spartan-variable-sups: "sups" off;
}
/* If class is applied, update custom property and
apply modern font-variant-* when supported */
.league-spartan-variable-aalt {
--league-spartan-variable-aalt: "aalt" on;
}
.league-spartan-variable-frac {
--league-spartan-variable-frac: "frac" on;
}
@supports (font-variant-numeric: diagonal-fractions) {
.league-spartan-variable-frac {
--league-spartan-variable-frac: "____";
font-variant-numeric: diagonal-fractions;
}
}
/*
and so on more for the remaining features
*/
/* Apply current state of all custom properties
whenever a class is being applied */
.league-spartan-variable-aalt,
.league-spartan-variable-frac,
.league-spartan-variable-ordn,
.league-spartan-variable-salt,
.league-spartan-variable-ss01,
.league-spartan-variable-ss02,
.league-spartan-variable-sups {
font-feature-settings:
var(--league-spartan-variable-aalt), var(--league-spartan-variable-frac),
var(--league-spartan-variable-ordn), var(--league-spartan-variable-salt),
var(--league-spartan-variable-ss01), var(--league-spartan-variable-ss02),
var(--league-spartan-variable-sups);
} This would make a great addition whether variable (web) fonts are used or not, as this concept is not limited to variable fonts. Classic TTF/OFT fonts may also provide variations and feature settings such as "small-caps" or "kerning". However, users need to know which gimmicks the font of their choice supports. The wakamaifondue custom properties are namespaced per font, but I believe this is not necessary. A full generic set of property names can be declared, i.e. Not sure how practical the human readable standardised values of font-variant would be as an alternative to the abbreviations. I also have a |
Beta Was this translation helpful? Give feedback.
-
all sorts of important typography design decisions can be named and distributed via props for variable fonts. give name to those mysterious key/values or just share premade good decisions.
https://developer.mozilla.org/en-US/docs/Web/CSS/font-variation-settings
Beta Was this translation helpful? Give feedback.
All reactions