问题描述
我使用这种方式添加字体并打印 pdf,但字体顺序未更正。 在 pdf.PHP
require_once('tcpdf_include.PHP');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION,PDF_UNIT,PDF_PAGE_FORMAT,true,'UTF-8',false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage('P','A7');
$fontname = TCPDF_FONTS::addTTFfont('../fonts/Pyidaungsu-2.5.1_Regular.ttf','TrueTypeUnicode','',32);
$pdf->SetFont($fontname,14,true);
我写了正确的字体顺序但是
$block1 = <<<EOF
<table style="font-size:9px; text-align:center">
<tr>
<td style="width:160px;">
<div>
Date: $saledate
<p style="font-size:10px">Aung Kyaw Oo(တောင်းဖျာနှီးကုန်)</p>
</div>
</td>
</tr>
</table>
EOF;
$pdf->writeHTML($block1,false,'');
我在 utf_8general_ci 中使用了数据库
pdf တောင်းဖျာနှီးကုန်
中的缅甸字体(Pyidoungsu unicode 字体)的字体顺序错误为 "တောင်းဖျာနှီးကုန်"
解决方法
我们通过使用 Zawgyi 字体解决了这个问题。
因为 TCPDF 在缅甸 Unicode 字体中存在渲染问题,但在 Zawgyi 字体中没问题。所以我们使用 zawgyi 字体并使用 Rabbit Converter 将我们的原始 Unicode 内容转换为 Zawgyi。
你可以看到完整的源代码,这是我们的公共仓库。 https://github.com/aungkoman/pdf_generate/
testWidgets("Different widgets available",(WidgetTester tester) async {
await tester.pumpWidget(HomeFr()); //which widget to test
var text = find.byType(Text); //find what widget
expect(text,findsWidgets); // give expectation
print(text);
var button1 = find.text("Répondre à la question du jour");
expect(button1,findsOneWidget);
await tester.tap(button1,warnIfMissed: false);
await tester.pump();
expect(find.byType(Widget),findsOneWidget);