react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Valid fonts render as black dots

Open JamieGoodson opened this issue 11 months ago • 1 comments

Describe the bug When registering a valid custom font via URL, they render as black dots. It doesn't seem to matter whether .ttf or .woff fonts are used. Have tried various different fonts from various different sources. The fonts preview just fine in macOS (ie not using react-pdf, just the OS's own font previewer) when downloaded from the same source URL.

To Reproduce

Font.register({
  family: "Open Sans",
  src: "http://fonts.gstatic.com/s/opensans/v13/IgZJs4-7SA1XX_edsoXWog.ttf",
});

const styles = StyleSheet.create({
  wrapper: {
    fontFamily: "Open Sans",
  },
});


ReactPDF.render(
  <Document>
    <Page size="A4">
      <View style={styles.wrapper}>
        <Text>Test</Text>
      </View>
    </Page>
  </Document>,
  `${__dirname}/test.pdf`,
);

Font source: https://gist.github.com/karimnaaji/b6c9c9e819204113e9cabf290d580551

Expected behavior Fonts render normally

Screenshots image

Desktop (please complete the following information):

  • OS: macOS
  • Browser: N/A (node v22.6.0)
  • React-pdf version: 4.1.6 (latest version as of today)

JamieGoodson avatar Jan 04 '25 17:01 JamieGoodson

Any fixes? I have the same issue when using React Native Paper

Michota avatar Apr 22 '25 16:04 Michota