这是用于生成其他语言字体的 pdf 的代码:
\n\nfinal Uint8List fontData = File('fonts/shivaji05.ttf').readAsBytesSync();\nfinal ttf = Font.ttf(fontData.buffer.asByteData());\nRun Code Online (Sandbox Code Playgroud)\n\n这就是我在文本中使用定义字体的方式:
\n\nText('\xe0\xa4\xb8\xe0\xa4\xbe\xe0\xa4\x88 \xe0\xa4\xac\xe0\xa4\xbe\xe0\xa4\xac\xe0\xa4\xbe', textScaleFactor: 2, style: new TextStyle(font: ttf)),\nRun Code Online (Sandbox Code Playgroud)\n\n错误日志
\n\nE/flutter (26251): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:pdf/src/font.dart': Failed assertion: line 145 pos 14: 'false': \nE/flutter (26251): ---------------------------------------------\nE/flutter (26251): Can not decode the string to Latin1.\nE/flutter (26251): This font does not support Unicode characters.\nE/flutter (26251): If you want to use strings other than Latin strings, use a TrueType (TTF) font instead.</i>\nRun Code Online (Sandbox Code Playgroud)\n