/** * Prints the variable axes of the packaged Google Sans Flex subset. * * Run from the repository root with `node bin/check-font.mjs [woff2]`. * tests/Feature/FontTest.php runs it through the configured `node` binary and asserts the ranges * the CSS needs (wght, ROND — see that test for why), because PHP cannot open a woff2 without the * Brotli extension. * * Output is one JSON object on stdout — {file, postscriptName, numGlyphs, axes: {tag: {name, min, * default, max}}}. The exit status is 1, with the reason on stderr, only when the file itself * can't be opened. */ import { openSync } from 'fontkit' import { fileURLToPath } from 'node:url' const file = process.argv[2] ?? fileURLToPath(new URL('../resources/fonts/google-sans-flex/GoogleSansFlex-Latin.woff2', import.meta.url)) let font try { font = openSync(file) } catch (error) { process.stderr.write(`${file}: ${error.message}\n`) process.exit(1) } process.stdout.write(`${JSON.stringify({ file, postscriptName: font.postscriptName, numGlyphs: font.numGlyphs, axes: font.variationAxes ?? {}, })}\n`)