0

I'm having a hard time registering custom font in react-pdf/renderer. But I was able to make it work by declaring it as variable. const roboto = 'https://cdnjs.cloudflare.com/ajax/libs/ink/3.1.10/fonts/Roboto/roboto-bold-webfont.woff'

Font.register({family: "Roboto", src: roboto});

But the URL here is only for Roboto, do you have any idea where I can get links similar to the one above? I'm about to use Poppins font family but can't find any, even in the same site as above.

Note: tried to execute the same with google fonts but it ain't working.

Thank you.

Ced D
  • 3
  • 1

1 Answers1

0

here's what works for me. You will have to import Font from @react-pdf/renderer and use as below.

import {Font} from "@react-pdf/renderer";

Font.register({
  family: "Open Sans",
  src: "https://fonts.gstatic.com/s/opensans/v17/mem8YaGs126MiZpBA-UFVZ0e.ttf",
});

Font.register({
  family: "Lato",
  src: "https://fonts.gstatic.com/s/lato/v16/S6uyw4BMUTPHjx4wWw.ttf",
});
Ashiq Dey
  • 309
  • 5
  • 18