Unable to load local font file with Font.register in Next.js
OS: Windows 11 React-pdf version: 3.1.6
Description: Hello, I've been trying to register a font for the document from the local file system (since I'm using Nex.js). What i've noticed is that if I use the following, the document is never generated
Font.register({
family: "Helvetica Neue",
fonts: [{ src: "/public/fonts/helveticaNeue-std.woff2" }],
});
I need to use local font because Helvetica font is not on google fonts, but it doesn't read the from the local Could you give me the solution for this?
Thank you
@diegomura , could you help me on this please? Thank you
@leonace924 remove public from the font path
@jeetiss
Main problem is font glyph doesn't work, like this symbol
do you have any solution for this?
I used Helvetica Neue font, it works fine on local but doesn't work on pdf even I import the same font

This shows same on playground too - https://react-pdf.org/repl

Still having an issue with this.
In NextJS, I can't do
import font from './font.ttf';
To load a local font, the doc recommends doing
import localFont from 'next/font/local'
const font = localFont({ src: './font.ttf' })
However, I am not able to use font in React-pdf's Font.register() like this
Font.register({
family: "Font",
src: font
});
Is there any way to make NextJS and React-PDF work together?
Hi,
Is there any update?
I am having the same issue... :(
Same here
any update ?
Though this is closed, let me just leave this here incase someone needs it. I managed to make it work through trial and error by registering like this:
Font.register({
family: "FontName",
src: "/fonts/font-file.otf",
});
I have my fonts on $root/public directory. Using relative path .../.../public/font/font-file didn't work for me. probably related to nextjs's webpack config. After figuring out the solution, I saw this documentation from next.js, pointing out how to access public files.
same here , can't load the font (be it ttf, otf or woff2):
import {
Page,
View,
Document,
StyleSheet,
Text,
Font,
} from "@react-pdf/renderer";
Font.register({
family: "inter",
src: "/fonts/Inter-Regular.otf",
});
// Create styles
const styles = StyleSheet.create({
page: {
backgroundColor: "#ffffff",
padding: "48px",
fontSize: "16px",
fontFamily: "inter",
},
header: {
height: "27%",
display: "flex",
alignItems: "stretch",
},
headerLeft: {
width: "60%",
display: "flex",
flexDirection: "column",
gap: "16px",
justifyContent: "space-between",
},
});
Same issue. Can this be reopened @leonace924?
@
Though this is closed, let me just leave this here incase someone needs it. I managed to make it work through trial and error by registering like this:
Font.register({ family: "FontName", src: "/fonts/font-file.otf", });I have my fonts on
$root/publicdirectory. Using relative path.../.../public/font/font-filedidn't work for me. probably related to nextjs's webpack config. After figuring out the solution, I saw this documentation from next.js, pointing out how to access public files.
This works for me, i moved my fonts file from app to public and directly use it on the register function like this:
Font.register({
family: 'Calibri',
format: 'truetype',
src: "/fonts/calibri.ttf",
});
it works, but only if I wrote string in src (NextJs 12.2.4, "@react-pdf/renderer": "3.3.8")
Though this is closed, let me just leave this here incase someone needs it. I managed to make it work through trial and error by registering like this:
Font.register({ family: "FontName", src: "/fonts/font-file.otf", });I have my fonts on
$root/publicdirectory. Using relative path.../.../public/font/font-filedidn't work for me. probably related to nextjs's webpack config. After figuring out the solution, I saw this documentation from next.js, pointing out how to access public files.
Thanks so much ! it works for me !
@
Though this is closed, let me just leave this here incase someone needs it. I managed to make it work through trial and error by registering like this:
Font.register({ family: "FontName", src: "/fonts/font-file.otf", });I have my fonts on
$root/publicdirectory. Using relative path.../.../public/font/font-filedidn't work for me. probably related to nextjs's webpack config. After figuring out the solution, I saw this documentation from next.js, pointing out how to access public files.This works for me, i moved my fonts file from app to public and directly use it on the register function like this:
Font.register({ family: 'Calibri', format: 'truetype', src: "/fonts/calibri.ttf", });
Thanks this worked for me
I am having the same issue... :(
I'm having this issue as well, even with the relative path that is supposed to start from the public directory. Currently running nextjs 14.2.4 and version 9.0.0 of react pdf. Tried "/fonts/my-font.otf" and various levels of drilling up directories with "../" without success. This works just fine for other relative references, like the @font-face lines in the website css, but for whatever reason fails when loading it with Font.register.
I'm having this issue as well, even with the relative path that is supposed to start from the public directory. Currently running nextjs 14.2.4 and version 9.0.0 of react pdf. Tried "/fonts/my-font.otf" and various levels of drilling up directories with "../" without success. This works just fine for other relative references, like the @font-face lines in the website css, but for whatever reason fails when loading it with Font.register.
i have same problem in next 14.2.3 and add font.register do you find any solotion?
I am having the same issue. Currently running nextjs 14.2.5 and react-pdf/renderer 3.4.4. When I use the I get the following error in the console.