#Using next/font/local with Base64 strings

11 messages · Page 1 of 1 (latest)

pine cloud
#

I need to use fonts in base64 and I was thinking to do something like this:

import { Font } from './Font';
import localFont from 'next/font/local'

const myFont = localFont({
  src: `data:font/woff2;base64,${Font} `,
  display: 'swap',
})

Font.js is just a export of the base64 string.

The error Font loader values must be explicitly written literals.

Any ideas?

teal acornBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

pine cloud
#

any soul?

paper walrus
#

is there a reason why you don't have it saved as a file?

pine cloud
#

the client don't want to expose the typeface

#

its custom

paper walrus
#

by using next/font it will make it a file (if it was a valid import) - so i think it makes sense to only support file locations

#

but base64 isn't going to stop it from being exposed

pine cloud
#

I understand

paper walrus
#

its the same as file...

paper walrus
#

@pine cloud did you get this working (/did you make it a file)