无法使用React-PDF用阿拉伯语呈现文本

发布于 2025-01-28 11:59:47 字数 676 浏览 5 评论 0 原文

我试图使用React-PDF在PDF中显示阿拉伯文本,但它显示了不适当的文本,

以下是我试图用阿拉伯语和英语显示的PNG中的文本,但仅显示英文字母,但不显示阿拉伯语文本。

,以下是我用于设置字体系列的小片段

import FontBold from '@assets/fonts/Inter/Inter-Bold.ttf';

import {styles} from './styles';

Font.register({
  family: 'Inter',
  fonts: [
    {
      src: FontRegular,
    },
    {
      src: FontMedium,
      fontWeight: 500,
    },
    {
      src: FontSemiBold,
      fontWeight: 600,
    },
    {
      src: FontBold,
      fontWeight: 700,
    },
  ],
});

I am trying to display Arabic text in pdf using react-pdf but it shows un-appropriate text

Following is the text in png that I have tried to show in Arabic and English but only English letters are displayed but not the Arabic text.

enter image description here

And Following is the small snippet which I have used for setting the font family

import FontBold from '@assets/fonts/Inter/Inter-Bold.ttf';

import {styles} from './styles';

Font.register({
  family: 'Inter',
  fonts: [
    {
      src: FontRegular,
    },
    {
      src: FontMedium,
      fontWeight: 500,
    },
    {
      src: FontSemiBold,
      fontWeight: 600,
    },
    {
      src: FontBold,
      fontWeight: 700,
    },
  ],
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心清如水 2025-02-04 11:59:47

许多字体没有阿拉伯语字符,在您的情况下,如果不改用其他字体或修改,这将是不可能的。

您是否有任何计划在字体上特别支持阿拉伯语中的其他语言?!

nope!感谢您的询问。如果熟悉阿拉伯语脚本的人将其作为一个单独的项目,那将很酷: - )

也阅读 https://github.com/rsms/inters/issues/391

建议使用 https ://github.com/ryanoasis/nerd-fonts

以后的编辑
最近,提出了一种通过范围应用两种字体的手段
https://github.com.com.com/rsms/rsms/rsms/rsms/inter/inter/inter/issues/391#issuecomment--391#issuecomment-- 1475339407

Many fonts do not have arabic characters and in your case that is not going to be possible without changing to another font, or modifications.

https://github.com/rsms/inter/issues/358

Do you have any plans for supporting other languages in the typeface especially Arabic ?!

Nope! Thanks for asking. It would be cool if someone familiar with Arabic script would take this on as a separate project :–)

read also https://github.com/rsms/inter/issues/391

which suggests using https://github.com/ryanoasis/nerd-fonts

Later edit
Most recently suggests a means to apply two fonts by ranges see
https://github.com/rsms/inter/issues/391#issuecomment-1475339407

彼岸花似海 2025-02-04 11:59:47

尝试此尝试作为src

它对我有用,我从Google Fonts响应中得到了font

Try this one as a src https://fonts.gstatic.com/s/tajawal/v10/Iura6YBj_oCad4k1rzaLCr5IlLA.ttf

It works for me, I got it from google fonts response when downloading the font

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文