Skip to content
Downloads webfont stylesheets and adds font-display properties
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Fix readme Jan 3, 2019
index.js Initial commit Jan 3, 2019
package-lock.json Initial commit Jan 3, 2019
package.json Change bin name Jan 3, 2019

README.md

Local Webfont

Downloads webfont stylesheets and adds font-display properties.

Usage

npx local-webfont source target [<font-display>]

The third argument, font-display is optional and defaults to fallback. Any valid font-display value can be passed, i.e. auto, block, swap, fallback, or optional.

Example

npx local-webfont https://fonts.googleapis.com/css?family=Merriweather /tmp/merriweather.css

Result

Original webfont CSS:

@font-face {
  font-family: 'Merriweather';
  font-style: normal;
  font-weight: 400;
  src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-ciZMdeX3rsHo.woff2) format('woff2');
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

Downloaded CSS:

@font-face {
  font-display: fallback;
  font-family: 'Merriweather';
  font-style: normal;
  font-weight: 400;
  src: local('Merriweather Regular'), local('Merriweather-Regular'), url(https://fonts.gstatic.com/s/merriweather/v19/u-440qyriQwlOrhSvowK_l5-ciZMdeX3rsHo.woff2) format('woff2');
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
You can’t perform that action at this time.