I had this issue as well. I was able to resolve it by importing the font file as a variable then using that as the src value.

import font from "./font.ttf"

Font.register({
  family: "FamilyName",
  format: "truetype",
  src: font 
});


const styles = StyleSheet.create({
  page: {
    fontFamily: "FamilyName",
  },
 });

this worked for me.

Answer from Design Freek on Stack Overflow
🌐
npm
npmjs.com › package › @react-pdf › fontkit
react-pdf/fontkit
Fontkit is an advanced font engine for Node and the browser, used by PDFKit. It supports many font formats, advanced glyph substitution and layout features, glyph path extraction, color emoji glyphs, font subsetting, and more.
      » npm install @react-pdf/fontkit
    
Published   Jul 03, 2022
Version   2.1.2
Author   Devon Govett
🌐
React-pdf
react-pdf.org › fonts
React-pdf
React-pdf is shipped with a Font module that enables to load fonts from different sources, handle how words are wrapped and defined an emoji source to embed these glyphs on your document.
🌐
CodeSandbox
codesandbox.io › examples › package › @react-pdf › fontkit
react-pdf/fontkit examples
Use this online @react-pdf/fontkit playground to view and fork @react-pdf/fontkit example apps and templates on CodeSandbox.
🌐
Reactarchitect
reactarchitect.ai › examples › @react-pdf › fontkit
React Architect - Generate documentation automatically and visualize your javascript, react or nextjs projects using the power of AI
Unlock the Potential of React Code: Generate documentation automatically and visualize your javascript, react or nextjs projects using the power of AI
Top answer
1 of 3
31
  1. in my case, I import the fonts as normal and it works. You can download the google fonts here . However, it is probably that you have to set up the webpack configuration.
    import FontUbuntuRegular from './styles/pdfFonts/ubuntuRegular.ttf';
    import FontUbuntuItalic from '.7styles/pdfFonts/ubuntuItalic.ttf';
    import FontUbuntu700 from './styles/pdfFonts/ubuntu700.ttf';
    
    Font.register({
      family: 'Ubuntu',
      fonts: [
        {
          src: FontUbuntuRegular,
        },
        {
          src: FontUbuntuItalic,
          fontWeight: 'bold',
        },
        {
          src: FontUbuntu700,
          fontWeight: 'normal',
          fontStyle: 'italic',
        },
      ],
    });

2. (RECOMMENDED) EASY, and simple, NO webpack configuration.

I found another way to add the src, it was to look for the Webfont.

  1. I had to scroll to make an API call with sort by ALPHA (alphabetic ordered) Google Api Fonts click Here to look for your font image example.
  2. I scrolled and founded image example
  3. I added manually the "S" to HTTP. before ("http://... ")=> after("https://...").
  4. I added to my code easily, and it is working perfectly.
Font.register({
  family: 'Ubuntu',
  fonts: [
    {
      src: 'https://fonts.gstatic.com/s/questrial/v13/QdVUSTchPBm7nuUeVf7EuStkm20oJA.ttf',
    },
    {
      src: 'https://fonts.gstatic.com/s/questrial/v13/QdVUSTchPBm7nuUeVf7EuStkm20oJA.ttf',
      fontWeight: 'bold',
    },
    {
      src: 'https://fonts.gstatic.com/s/questrial/v13/QdVUSTchPBm7nuUeVf7EuStkm20oJA.ttf',
      fontWeight: 'normal',
      fontStyle: 'italic',
    },
  ],
});
2 of 3
4

This worked for me!

Font.register({
  family: 'Roboto',
  fonts: [
    {
      src: '/fonts/Roboto-Regular.ttf',
      fontWeight: 400,
    },
    {
      src: '/fonts/Roboto-Bold.ttf',
      fontWeight: 700,
    }
  ]
})

const styles = StyleSheet.create({
  page: {
    fontFamily: 'Roboto',
  }
 })
🌐
npm
npmjs.com › package › @react-pdf › pdfkit
react-pdf/pdfkit
You can also try out an interactive in-browser demo of PDFKit here. Installation uses the npm package manager. Just type the following command after installing npm. ... Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts ... See fontkit for more details on advanced glyph layout support.
      » npm install @react-pdf/pdfkit
    
Published   Sep 23, 2025
Version   4.0.4
Author   Devon Govett
🌐
GitHub
github.com › react-pdf › fontkit
GitHub - react-pdf/fontkit: [DEPRECATED] Now in: https://github.com/diegomura/react-pdf/tree/master/packages/fontkit
[DEPRECATED] Now in: https://github.com/diegomura/react-pdf/tree/master/packages/fontkit - react-pdf/fontkit
Forked by 7 users
Languages   JavaScript 99.8% | Makefile 0.2%
🌐
npm
npmjs.com › package › @react-pdf › font
react-pdf/font
Register font and emoji source for react-pdf document. Latest version: 4.0.3, last published: 3 months ago. Start using @react-pdf/font in your project by running `npm i @react-pdf/font`. There are 37 other projects in the npm registry using @react-pdf/font.
      » npm install @react-pdf/font
    
Published   Sep 23, 2025
Version   4.0.3
Author   Diego Muracciole
Find elsewhere
🌐
GitHub
github.com › diegomura › react-pdf › issues › 233
Enable adding fonts by path name when using react-pdf node binding · Issue #233 · diegomura/react-pdf
*OS: Any React-pdf version: From 1.0 Description: react-pdf core v1.0 will include a custom fontkit build that does not includes all the node dependencies. Because of this, loading a font by path n...
Published   May 16, 2018
Author   diegomura
🌐
GitHub
github.com › diegomura › react-pdf › issues › 2015
Console error: Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). after upgrading @react-pdf/renderer to 3.0.0 · Issue #2015 · diegomura/react-pdf
September 9, 2022 - Console error: Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). after upgrading @react-pdf/renderer to 3.0.0#2015
Published   Sep 09, 2022
🌐
Lightrun
lightrun.com › answers › diegomura-react-pdf-console-error-attempted-import-error-create-is-not-exported-from-fontkit-imported-as-fontkit
Console error: Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). after upgrading @react-pdf/renderer to 3.0.0
js Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). I tried to use different versions of this package, ...Read more > ... An advanced font engine for Node and the browser.
🌐
jsDelivr
jsdelivr.com › package › npm › @react-pdf › fontkit
@react-pdf/fontkit CDN by jsDelivr - A CDN for npm and GitHub
July 3, 2022 - A free, fast, and reliable CDN for @react-pdf/fontkit. An advanced font engine for Node and the browser
Published   Apr 19, 2018
🌐
GitHub
github.com › diegomura › react-pdf › issues › 1991
Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit'). · Issue #1991 · diegomura/react-pdf
August 30, 2022 - diegomura / react-pdf Public · There was an error while loading. Please reload this page. Notifications · You must be signed in to change notification settings · Fork 1.3k · Star 16.2k · New issueCopy link · New issueCopy link · Closed · #2023 · Closed · Attempted import error: 'create' is not exported from 'fontkit' (imported as 'fontkit').#1991 ·
Published   Aug 30, 2022
🌐
Stack Overflow
stackoverflow.com › questions › 69697808 › how-to-use-custom-fonts-in-react-pdf-pdfkit
reactjs - How to use custom fonts in @react-pdf/pdfkit - Stack Overflow
import utils from "./utils"; const SVGtoPDF = require("svg-to-pdfkit"); const PDFDocument = require("@react-pdf/pdfkit").default; const { Base64Encode } = require("base64-stream"); const generatePDF = async (width, height, canvas, fonts) => { const canvasSvg = canvas.toSVG(); return await new Promise((resolve, reject) => { try { var doc = new PDFDocument({ bufferPages: true, size: [width * 0.75, height * 0.75], }); utils.getFont(fonts).forEach(async (font) => { doc.registerFont(font.family, font.path, font.family); }); doc.font("Pacifico").text("Hello Message"); let finalString = ""; const stream = doc.pipe(new Base64Encode()); SVGtoPDF(doc, canvasSvg, 0, 0); stream.on("data", (chunk) => (finalString += chunk)); stream.on("end", () => { resolve(finalString); }); doc.end(); } catch (err) { reject(err); } }); }; export default generatePDF;
🌐
jsDelivr
cdn.jsdelivr.net › @react-pdf/[email protected]
@react-pdf/fontkit CDN by jsDelivr - A free, fast, and reliable Open Source CDN
Looking for a nice landing page for your package? https://www.jsdelivr.com/package/npm/@react-pdf/fontkit
🌐
GitHub
github.com › diegomura › react-pdf › discussions › 1621
How to add custom font in react-pdf/pdf · diegomura/react-pdf · Discussion #1621
I tried to use doc.registerFont(path, font_family) But its showing an error like Unhandled Rejection (Error): fontkit.openSync unavailable for browser build · Can anyone help me? I dont want to render the pdf. Instead I am trying to create and download it. So I cant use react-pdf/renderer.
Author   diegomura
🌐
GitHub
github.com › react-pdf › pdfkit
GitHub - react-pdf/pdfkit: [DEPRECATED] Now in: https://github.com/diegomura/react-pdf/tree/master/packages/pdfkit
You can also try out an interactive in-browser demo of PDFKit here. Installation uses the npm package manager. Just type the following command after installing npm. ... Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts ... See fontkit ...
Starred by 7 users
Forked by 9 users
Languages   JavaScript
🌐
Telerik
telerik.com › components › drawing › pdf output › unicode and embedded fonts
React Drawing PDF Output Unicode and Embedded Fonts - KendoReact
All characters (glyphs), which are not available in the set font are substituted by the browser with characters from a fallback font. The PDF Export module has no access to the information about these substitutions. As a result, the substituted characters are rendered as the default glyph which is typically a rectangle.