Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does wasm support multiple font families? #342

Open
AndrewAskins opened this issue Jun 10, 2024 · 0 comments
Open

Does wasm support multiple font families? #342

AndrewAskins opened this issue Jun 10, 2024 · 0 comments

Comments

@AndrewAskins
Copy link

I am trying to load multiple font families, and specific a different sans serif and monospace font. But my image is only using the first font loaded. It looks from resvg-js/wasm/index.d.ts like it should but that's not the behavior I'm seeing.

`
const inter400 = await fetch('https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-400-normal.woff2')
if (!inter400.ok) return
const bufferInter400 = new Uint8Array(await inter400.arrayBuffer())

  const inter700 = await fetch('https://cdn.jsdelivr.net/fontsource/fonts/inter@latest/latin-700-normal.woff2')
  if (!inter700.ok) return
  const bufferInter700 = new Uint8Array(await inter700.arrayBuffer())

  const lora400 = await fetch('https://cdn.jsdelivr.net/fontsource/fonts/lora@latest/latin-400-normal.woff2')
  if (!lora400.ok) return
  const bufferLora400 = new Uint8Array(await lora400.arrayBuffer())

  const lora700 = await fetch('https://cdn.jsdelivr.net/fontsource/fonts/lora@latest/latin-700-normal.woff2')
  if (!lora700.ok) return
  const bufferLora700 = new Uint8Array(await lora700.arrayBuffer())

  const ibmPlexMono400 = await fetch('https://cdn.jsdelivr.net/fontsource/fonts/ibm-plex-mono@latest/latin-400-normal.woff2')
  if (!ibmPlexMono400.ok) return
  const bufferIbmPlexMono400 = new Uint8Array(await ibmPlexMono400.arrayBuffer())

  const ibmPlexMono700 = await fetch('https://cdn.jsdelivr.net/fontsource/fonts/ibm-plex-mono@latest/latin-700-normal.woff2')
  if (!ibmPlexMono700.ok) return
  const bufferIbmPlexMono700 = new Uint8Array(await ibmPlexMono700.arrayBuffer())

  const opts = {
    dpi: 96,
    shapeRendering: 1,
    textRendering: 2,
    imageRendering: 0,
    font: {
      fontBuffers: [bufferInter400, bufferInter700, bufferLora400, bufferLora700, bufferIbmPlexMono400, bufferIbmPlexMono700], // New in 2.5.0, loading custom fonts
      monospaceFamily: 'IBM Plex Mono',
      sansSerifFamily: 'Inter',
      serifFamily: 'Lora',
      loadSystemFonts: false,
    },
  }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant