Download fonts for local/offline delivery.
npm i @joncasey/google-fonts
const { getFont, downloadFont } = require('@joncasey/google-fonts')
getFont('Open Sans')
.then(font => downloadFont(font, 'Open Sans'))
.then(results => console.log(results))
.catch(error => console.log(`Error`, error))
You can just copy the dist files locally. They have ZERO-dependencies (other than NodeJS)
copy https://unpkg.com/@joncasey/google-fonts/dist/google-fonts.mjs Then just
import { getFont, downloadFont } from './google-fonts.mjs'
or, using require..
copy https://unpkg.com/@joncasey/google-fonts/dist/google-fonts.js
const { getFont, downloadFont } = require('./google-fonts.js')
let fontObject = await getFont (fontFamily)
/*
fontObject = {
css: "",
fonts: [
{
src: {
local: "",
woff: "",
woff2: ""
},
family: "",
style: "",
weight: ""
}
],
raw: []
}
*/