How to register multiple fonts in React PDF and utilise them separately

173 Views Asked by At

I have registered two fonts in a react component as below

Font.register({
family: "Bold",
fonts: [
{
src: "path to file", 
}
]});

Font.register({
family: "Light",
fonts: [
{
src: "path to file",
}
]});

Now I have utilised them in my Text component as below

<Text style={{ fontFamily: "Bold" }}>Heading</Text>
<Text style={{ fontFamily: "Light" }}>Paragrpah</Text>

Now for both heading and paragraph, I am getting style set to Bold. How to resolve this and assign seperate fonts to both text? Also how to add fontSize to the font family?

0

There are 0 best solutions below