如何在单个文本中包含多种字体

Ulm*_*aev 3 dart flutter

我有一个 pdf 文件中的阿拉伯语文本。当我将文本复制到 Text Widget 时,它会变成奇怪的字符。当我检查 pdf 文件属性时,我发现它使用 HQPB1、HQPB2、HQPB3、HQPB4 字体,因此我将所有这些字体导入到我的 pubsec.yaml 文件中。问题是我一次只能使用这 4 种字体中的一种,但 pdf 文件同时使用所有这 4 种字体。

这是pdf的原文

当我只添加 HQPB1.ttf 时

当我只添加 HQPB2.ttf 时

所以我想将所有这 4 种字体都包含在一个文本中,以便在需要时应该使用每个单独的字体,就像 pdf 一样。

Cop*_*oad 9

RichText(
  text: TextSpan(
    children: <TextSpan>[
      TextSpan(text: 'Hello ', style: TextStyle(fontFamily: "Serif", fontSize: 30, color: Colors.black)),
      TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue, fontSize: 30)),
      TextSpan(text: ' world!', style: TextStyle(fontFamily: "Roboto", fontSize: 30, color: Colors.red)),
    ],
  ),
)
Run Code Online (Sandbox Code Playgroud)

输出:

在此处输入图片说明