-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·45 lines (40 loc) · 892 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/env node
import { generateFallbackFonts } from '../src/index.js'
// load file from args
const file = process.argv[2]
if (!file) {
console.error('Please provide a css file')
process.exit(1)
}
const fonts = generateFallbackFonts(file)
if (!fonts.length) {
console.error('No fonts found')
process.exit(1)
}
const fontPieCss = fonts
.map(
({
fontFamily,
fontStyle,
fontWeight,
fallbackFont,
ascentOverride,
descentOverride,
lineGapOverride,
sizeAdjust,
}) =>
`@font-face {
font-family: ${fontFamily};
font-style: ${fontStyle};
font-weight: ${fontWeight};
src: local('${fallbackFont}');
ascent-override: ${ascentOverride};
descent-override: ${descentOverride};
line-gap-override: ${lineGapOverride};
size-adjust: ${sizeAdjust};
}`
)
.join('\n\n')
console.log(
`/* Fallback fonts generated by fontpie-from-css */\n\n${fontPieCss}`
)