0.4.1 • Published 5 years ago

@glhd/postcss-font-stack v0.4.1

Weekly downloads
11
License
MIT
Repository
github
Last release
5 years ago

postcss-font-stack

A PostCSS plugin to use configured font stacks with fallback adjustments.

Getting Started

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:

Example Config

{
  stacks: {
    ui: {
      target: `Roboto`,
      fallbacks: `Arial, sans-serif`,
      adjustments: {
        letterSpacing: `-0.003125rem`,
        wordSpacing: `-0.009375rem`
      }
    }
  }
}

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:

const fontObserver = new FontFaceObserver(`Roboto`);
fontObserver.load().then(() => {
	document.documentElement.className += ` has-roboto-font`;
});

Your final CSS will look something like this:

Example Output

.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;
}
0.4.1

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago