Closed dhwaj1902 closed 1 month ago
Describe the bug I want to register multiple fonts in react-pdf, but blank screen is coming. Only Roboto font is working while creating the pdf.
To Reproduce Steps to reproduce the behavior including code snippet (if applies): Using the code: Font.register({ family: 'Lato', fonts: [ { src: '/font/Lato-Regular.ttf', fontWeight: 400, }, { src: '/font/Lato-Italic.ttf', fontStyle: 'italic', }, { src: '/font/Lato-Bold-Italic.ttf', fontWeight: 500, fontStyle: 'italic', }, { src: '/font/Lato-Bold.ttf', fontWeight: 600, }, { src: '/font/Lato-Bold.ttf', fontWeight: 700, }, { src: '/font/Lato-Bold.ttf', fontWeight: 800, }, ], });
Font.register({ family: 'Lato', fonts: [ { src: '/font/Lato-Regular.ttf', fontWeight: 400, }, { src: '/font/Lato-Italic.ttf', fontStyle: 'italic', }, { src: '/font/Lato-Bold-Italic.ttf', fontWeight: 500, fontStyle: 'italic', }, { src: '/font/Lato-Bold.ttf', fontWeight: 600, }, { src: '/font/Lato-Bold.ttf', fontWeight: 700, }, { src: '/font/Lato-Bold.ttf', fontWeight: 800, }, ], });
Font.register({ family: 'Roboto', fonts: [ { src: '/font/Roboto-Regular.ttf', fontWeight: 400, }, ... same ], });
Font.register({ family: 'Inter', fonts: [ { src: '/font/Inter-Regular.ttf', fontWeight: 400, }, ... same ], });
Expected behavior If used any of the above registered fonts in the body font-family, then the font should come.
Desktop (please complete the following information):
I had the same issue and solved it with this : https://github.com/diegomura/react-pdf/issues/2675#issuecomment-1999002409
Thanks a lot that works for me!
Describe the bug I want to register multiple fonts in react-pdf, but blank screen is coming. Only Roboto font is working while creating the pdf.
To Reproduce Steps to reproduce the behavior including code snippet (if applies): Using the code:
Font.register({ family: 'Lato', fonts: [ { src: '/font/Lato-Regular.ttf', fontWeight: 400, }, { src: '/font/Lato-Italic.ttf', fontStyle: 'italic', }, { src: '/font/Lato-Bold-Italic.ttf', fontWeight: 500, fontStyle: 'italic', }, { src: '/font/Lato-Bold.ttf', fontWeight: 600, }, { src: '/font/Lato-Bold.ttf', fontWeight: 700, }, { src: '/font/Lato-Bold.ttf', fontWeight: 800, }, ], });
Font.register({ family: 'Roboto', fonts: [ { src: '/font/Roboto-Regular.ttf', fontWeight: 400, }, ... same ], });
Font.register({ family: 'Inter', fonts: [ { src: '/font/Inter-Regular.ttf', fontWeight: 400, }, ... same ], });
Expected behavior If used any of the above registered fonts in the body font-family, then the font should come.
Desktop (please complete the following information):