Răsfoiți Sursa

fix(report): mPDF 周报改用 sun-exta 修复中文方块字

Made-with: Cursor
yemeishu 1 lună în urmă
părinte
comite
5940214267
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      scripts/report_teacher_weekly_stats_pdf.php

+ 5 - 2
scripts/report_teacher_weekly_stats_pdf.php

@@ -34,7 +34,8 @@ $bodyHtml = $converter->convert($markdown)->getContent();
 
 $css = <<<'CSS'
 <style>
-body { font-family: 'DejaVu Sans', sans-serif; font-size: 10pt; color: #111; }
+/* mPDF 内置 Sun-ExtA(sun-exta),覆盖中文、日文、韩文;勿用 DejaVu,否则会显示为方块 */
+body { font-family: 'sun-exta', sans-serif; font-size: 10pt; color: #111; }
 h2 { font-size: 14pt; margin: 0 0 8px 0; }
 h3 { font-size: 11pt; margin: 16px 0 8px 0; }
 blockquote { margin: 0 0 10px 0; padding: 6px 10px; background: #f9fafb; border-left: 3px solid #d1d5db; font-size: 9pt; color: #4b5563; }
@@ -61,7 +62,9 @@ $mpdf = new \Mpdf\Mpdf([
     'margin_bottom' => 14,
     'margin_left' => 12,
     'margin_right' => 12,
-    'default_font' => 'dejavusans',
+    'default_font' => 'sun-exta',
+    'autoScriptToLang' => true,
+    'autoLangToFont' => true,
 ]);
 $mpdf->WriteHTML($html);
 $mpdf->Output($outPath, \Mpdf\Output\Destination::FILE);