React pdf-renderer 不显示字符 č、ć 和 đ

React pdf-renderer does not display characters č, ć and đ

我正在使用 @react-pdf/renderer 版本“1.6.8”。但是,我无法获得以下字符:čćđ。取而代之的是空格。

字符来自克罗地亚语,可以在其官方页面上进行测试。

https://react-pdf.org/repl?example=page-wrap

可能有人知道要设置什么或如何解决问题。在他们的 official docs.

上没有找到任何东西

Github 问题:https://github.com/diegomura/react-pdf/issues/780

刚刚导入了这样的自定义字体,它对我有用:

import font from '/styles/localFonts/Poppins-Medium.ttf

Font.register({ family: 'Poppins', src: font })

试试这个

import { Page, Font, Text } from '@react-pdf/renderer';

// Register Font
Font.register({
  family: "Roboto",
  src:
    "https://cdnjs.cloudflare.com/ajax/libs/ink/3.1.10/fonts/Roboto/roboto-light-webfont.ttf"
});

// Create style with font-family
const styles = StyleSheet.create({
  page: {
    fontFamily: "Roboto"
  },
});

const MyDocument = () => (

    <Document > 
      <Page size="A4" style={styles.page} > <!--Add Font style to the page-->
          <Text >Some text čćđ</Text>
      </Page>
    </Document>
  )

它适用于我,适用于波兰语