@react-pdf/renderer Encountering "Unknown encoding: x-mac-roman" Error During Text Rendering

27 views Asked by At

I'm encountering an issue with @react-pdf/renderer in one of my React projects. While it works perfectly fine in other projects, I'm getting an "Unknown encoding x-mac-roman" error in this particular project.

Error Details:

The error occurs in the encodingWidth method (line 106) of the String.js file. I suspect this file is used by @react-pdf/renderer for text rendering.

enter image description here

Font Registration:

Here's how I'm registering the font:

Font.register({
  family: 'MyFontFamily',
  src: 'http://my-cdn-path/MyFontFamily.ttf',
  format: 'truetype'
})

Font Usage:

And this is how I'm including the font family in styles:

const styles = StyleSheet.create({
  label: {
    fontSize: 12,
    color: 'red',
    fontFamily: 'MyFontFamily'
  }
})

Question:

Has anyone else encountered this issue with @react-pdf/renderer? Any insights or solutions would be greatly appreciated.

Furthermore

It looks like is an issue with the font I'm using (Gilmer), I try with a random one and works.

0

There are 0 answers