A PostCSS plugin to use configured font stacks with fallback adjustments
npm install @glhd/postcss-font-stackA PostCSS plugin to use configured font stacks with fallback adjustments.
First, you need to figure out for fallback configuration using the wonderful
font style matcher.
Next, configure your font stack using the adjustments from the font style matcher:
``jsRoboto
{
stacks: {
ui: {
target: ,Arial, sans-serif
fallbacks: ,-0.003125rem
adjustments: {
letterSpacing: ,-0.009375rem
wordSpacing: `
}
}
}
}
Use your font stack in anywhere in your CSS:
`css`
.btn {
font-stack: ui;
}
If you're using Typekit, everything else is set up for you. If not, check out
the font face observer library, and set up something
along the lines of:
`jsRoboto
const fontObserver = new FontFaceObserver(); has-roboto-font
fontObserver.load().then(() => {
document.documentElement.className += ;`
});
Your final CSS will look something like this:
`css``
.wf-loading .btn, .wf-inactive .btn {
font-family: Arial, sans-serif;
letter-spacing: -0.003125rem;
word-spacing: -0.009375rem;
}
.wf-active .btn {
font-family: Roboto, Arial, sans-serif;
}