【问题标题】:React pdf-renderer does not display characters č, ć and đReact pdf-renderer 不显示字符 č、ć 和 đ
【发布时间】:2020-03-30 17:26:37
【问题描述】:

我正在使用 @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

【问题讨论】:

    标签: javascript reactjs pdf react-pdf


    【解决方案1】:

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

    import font from '/styles/localFonts/Poppins-Medium.ttf
    
    Font.register({ family: 'Poppins', src: font })
    

    【讨论】:

      【解决方案2】:

      试试这个

      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>
        )
      

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

      【讨论】:

      • 添加此代码后我的代码崩溃了很多:( 获取 nbind.externalList[num].dereference 不是函数错误。
      猜你喜欢
      • 2014-01-13
      • 2019-10-29
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多