Google Fonts CSS2
This package is supposed to be an agnostic and fast helper package to interact with Google Fonts API version 2.
React Component
: https://github.com/adriano-tirloni/react-google-fonts-css2
URL Builder:
URL Builder for V2 has 2 functions:
assembleCommom
- working
assembleFull
- to be developed as needed
-
assembleCommon
: This function works as described below, and will request fonts with styles varying on weight and being italic. It was developed to be fast and not to include all possible scenarios. For the full flexible API there is the assembleFull
function.
-
assembleFull
: not developed - This function will take a different structure from assembleCommon to be able to render the full spec of Google Font API axis:
- Italic -
ital
- Optical Size -
opsz
- Slant -
slnt
- Weight -
wght
- Width -
wdth
- Casual -
CASL
- Cursive -
CRSV
- Expression -
XPRN
- Grade -
GRAD
- Monospace -
MONO
- Softness -
SOFT
- Wonkiness -
WONK
https://developers.google.com/fonts/docs/css2
https://fonts.google.com/variablefonts
Usage:
const { assembleCommon } = require("google-fonts-css2"
import { assembleCommon } from "google-fonts-css2"
let url = assembleCommon([
{
family: "Cabin",
styles: [
"600..700",
"100..200italic",
"300italic",
"regular",
"italic",
"500",
444
]
},
{
family: "Roboto",
styles: [
"300italic",
"regular",
"italic",
"500",
100
]
},
], 'swap')
"https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400;0,444;0,500;0,600..700;1,100..200;1,300;1,400;1,600..700&family=Roboto:ital,wght@0,100;0,400;0,500;1,300;1,400&display=auto"
Check it here: https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400;0,444;0,500;0,600..700;1,100..200;1,300;1,400;1,600..700&family=Roboto:ital,wght@0,100;0,400;0,500;1,300;1,400&display=auto
Example | Test
Run:
git clone git@github.com:adriano-tirloni/google-fonts-css2.git
yarn
yarn build:dev
node ./src/example.js