refactor fonts
This commit is contained in:
parent
56375d7c57
commit
5b121f398b
21 changed files with 114 additions and 110 deletions
112
lib/fonts.js
Normal file
112
lib/fonts.js
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
import fs from 'node:fs'
|
||||||
|
|
||||||
|
export const DMSans = [
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Thin.ttf'),
|
||||||
|
weight: 100,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-ThinItalic.ttf'),
|
||||||
|
weight: 100,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-ExtraLight.ttf'),
|
||||||
|
weight: 200,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-ExtraLightItalic.ttf'),
|
||||||
|
weight: 200,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Light.ttf'),
|
||||||
|
weight: 300,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-LightItalic.ttf'),
|
||||||
|
weight: 300,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Regular.ttf'),
|
||||||
|
weight: 400,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Italic.ttf'),
|
||||||
|
weight: 400,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Medium.ttf'),
|
||||||
|
weight: 500,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-MediumItalic.ttf'),
|
||||||
|
weight: 500,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-SemiBold.ttf'),
|
||||||
|
weight: 600,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-SemiBoldItalic.ttf'),
|
||||||
|
weight: 600,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Bold.ttf'),
|
||||||
|
weight: 700,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-BoldItalic.ttf'),
|
||||||
|
weight: 700,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-ExtraBold.ttf'),
|
||||||
|
weight: 800,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-ExtraBoldItalic.ttf'),
|
||||||
|
weight: 800,
|
||||||
|
style: 'italic'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-Black.ttf'),
|
||||||
|
weight: 900,
|
||||||
|
style: 'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DM Sans',
|
||||||
|
data: fs.readFileSync('./assets/DMSans/DMSans-BlackItalic.ttf'),
|
||||||
|
weight: 900,
|
||||||
|
style: 'normal'
|
||||||
|
}
|
||||||
|
]
|
112
lib/render.js
112
lib/render.js
|
@ -1,119 +1,11 @@
|
||||||
import html2png, { renderHtml as htmlParser } from '@besties/html2png'
|
import html2png, { renderHtml as htmlParser } from '@besties/html2png'
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
|
import { DMSans } from './fonts.js'
|
||||||
|
|
||||||
const css = fs.readFileSync('./assets/style.css', 'utf8')
|
const css = fs.readFileSync('./assets/style.css', 'utf8')
|
||||||
|
|
||||||
const renderOptions = {
|
const renderOptions = {
|
||||||
fonts: [
|
fonts: DMSans
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Thin.ttf'),
|
|
||||||
weight: 100,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-ThinItalic.ttf'),
|
|
||||||
weight: 100,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-ExtraLight.ttf'),
|
|
||||||
weight: 200,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-ExtraLightItalic.ttf'),
|
|
||||||
weight: 200,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Light.ttf'),
|
|
||||||
weight: 300,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-LightItalic.ttf'),
|
|
||||||
weight: 300,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Regular.ttf'),
|
|
||||||
weight: 400,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Italic.ttf'),
|
|
||||||
weight: 400,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Medium.ttf'),
|
|
||||||
weight: 500,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-MediumItalic.ttf'),
|
|
||||||
weight: 500,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-SemiBold.ttf'),
|
|
||||||
weight: 600,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-SemiBoldItalic.ttf'),
|
|
||||||
weight: 600,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Bold.ttf'),
|
|
||||||
weight: 700,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-BoldItalic.ttf'),
|
|
||||||
weight: 700,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-ExtraBold.ttf'),
|
|
||||||
weight: 800,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-ExtraBoldItalic.ttf'),
|
|
||||||
weight: 800,
|
|
||||||
style: 'italic'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-Black.ttf'),
|
|
||||||
weight: 900,
|
|
||||||
style: 'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DM Sans',
|
|
||||||
data: fs.readFileSync('./assets/DMSans-BlackItalic.ttf'),
|
|
||||||
weight: 900,
|
|
||||||
style: 'normal'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function (html, options = {}) {
|
export default async function (html, options = {}) {
|
||||||
|
|
Loading…
Reference in a new issue