- 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.
- 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.
- I scrolled and founded image example
- I added manually the "S" to HTTP. before ("http://... ")=> after("https://...").
- 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',
},
],
});