diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.66k stars 1.16k forks source link

External font is not working like Denmark Causten calibri #2779

Open Ayush2014Kira opened 3 months ago

Ayush2014Kira commented 3 months ago

import RobotoMedium from "../../../../assets/fonts/Roboto/Roboto-Medium.ttf"; import RobotoBold from "../../../../assets/fonts/Roboto/Roboto-Bold.ttf"; import Denmark from "../../../../assets/fonts/Denmark/DENMARK.ttf"; import CaustenExtraBold from "../../../../assets/fonts/Causten/CaustenExtraBold.ttf"; import CalibriBold from "../../../../assets/fonts/calibri/CalibriBold.ttf"; import CalibriRegular from "../../../../assets/fonts/calibri/CalibriRegular.ttf"; Font.register({ family: "Ageo-Regular", src: RobotoMedium, fontWeight: 400, });

Font.register({ family: "Ageo-Bold", src: RobotoBold, fontWeight: 700, });

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

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

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

Font.register({ family: "CalibriRegular", src: CalibriRegular, }); Font.register({ family: "Ageo-Italic", src: AgeoItalic, fontWeight: 400, });

onst styles = StyleSheet.create({ container: { width: "100%", height: window.innerHeight, }, body: { paddingTop: 10, paddingBottom: 130, paddingHorizontal: 35, fontSize: 12, fontFamily: "Ageo-Italic", },) in this code apply font is not working only roboto font working how to any other font add in this code

corbinday commented 3 months ago

I have a problem like this too. I have a project that has been using react-pdf successfully with various fonts but now, after one of the last few updates, they no longer work.

I don't think it necessarily has to do with the font type, since I tried a few different fonts of various types like .otf, .ttc, and .ttf and many did not work. From my limited testing, it seems that only specific fonts work.

The fonts I am trying to use are Century Gothic, Proxima Nova, and Helvetica.

corbinday commented 3 months ago

@Ayush2014Kira See this thread: https://github.com/diegomura/react-pdf/issues/2756#issuecomment-2165275094

Ayush2014Kira commented 3 months ago

@Ayush2014Kira See this thread: https://github.com/diegomura/react-pdf/issues/2756#issuecomment-2165275094

Yes , after I use google fonts And pdf working but this is a temporary solution .