diegomura / diegomura/react-pdf

fontFamily is not loaded / applied if it is only used in render callbacks

Open
#2,850 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

I'm registering two fonts, one is a logo type and the other is the font I want to use for the document body.

However, while the logo type works well, I think the other one is not (it's a bit difficult to tell because it doesn't look very different from the default one). Also, setting the fontWeight doesn't work at all - I have already tried the previously suggested solutions of specifiying the fontFamily alongside the fontWeight in inline styles and downgrading to `"@react-pdf/layout": "3.11.5", "@react-pdf/renderer": "3.4.2",`.

```ts
ReactPDF.Font.register({family: 'Logotype', src: Logotype});
ReactPDF.Font.register({family: 'Lato', fonts: [
{src: Lato},
{src: LatoBold, fontWeight: 'bold'},
{src: LatoBoldItalic, fontWeight: 'bold', fontStyle: 'italic'},
{src: LatoItalic, fontStyle: 'italic'},
{src: LatoLight, fontWeight: 'light'},
{src: LatoLightItalic, fontWeight: 'light', fontStyle: 'italic'},
]});
```

```tsx



{
if (pageNumber === 1) return (

TITLE
subTitle
NAME

)
}} />

{...}


```

I've also tried using another FontFamily for bold text with no success:
```ts
ReactPDF.Font.register({family: 'Lato-Bold', src: LatoBold});
```
```tsx
TITLE
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.