0.2.0 • Published 12 months ago

unplugin-font-to-buffer v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

unplugin-font-to-buffer

Import font files as Buffer. Meant to be used with satori.

Install

pnpm add unplugin-font-to-buffer -D
// vite.config.ts
import FontToBuffer from 'unplugin-font-to-buffer/vite'

export default defineConfig({
  plugins: [FontToBuffer()],
})

// rollup.config.js
import FontToBuffer from 'unplugin-font-to-buffer/rollup'

export default {
  plugins: [FontToBuffer()],
}

// nuxt.config.js
export default defineNuxtConfig({
  // Applied on Nitro only
  modules: ['unplugin-font-to-buffer/nuxt'],
})

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-font-to-buffer/webpack')()
  ]
}

// esbuild.config.js
import { build } from 'esbuild'
import FontToBuffer from 'unplugin-font-to-buffer/esbuild'

build({
  plugins: [FontToBuffer()],
})

import satori from 'satori'
import Roboto from './lib/fonts/Roboto-Regular.ttf'

const svg = await satori(
  <div style={{ color: 'black' }}>hello, world</div>,
  {
    width: 600,
    height: 400,
    fonts: [
      {
        name: 'Roboto',
        data: Roboto,
        weight: 400,
        style: 'normal',
      },
    ],
  },
)

License

MIT

0.2.0

12 months ago

0.1.4

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago