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

How to use a custom font? #12

Open
TimotheAlbouy opened this issue Feb 19, 2019 · 1 comment
Open

How to use a custom font? #12

TimotheAlbouy opened this issue Feb 19, 2019 · 1 comment

Comments

@TimotheAlbouy
Copy link

I know that we can use the option.font property to change the font, but it only searches for web-safe fonts. How can I use a custom font that I stored on the server, let's say /public/fonts/Wurmics_Bravo.ttf?

@rubillionaire
Copy link

Using the FontFace API you can load a font, and then reference the name (first argument to FontFace) within your vectorize text options.

// load your font
const font = new FontFace('Fredoka', "url('fonts/Fredoka-SemiBold.ttf')")
await font.load()
document.fonts.add(font)
// make a mesh from it
const mesh = vectorizeText(char, {
  triangles: true,
  textBaseline: "alphabetic",
  font: 'Fredoka',
  size: '10px',
  textAlign: 'center',
})

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

2 participants