我正在使用Berryvdh/Laravel-dompdf
在全新安装中vendor/dompdf/dompdf/lib/php-font-lib
是空的,所以我求助于使用作曲家phenx/php-font-lib (0.2.2)
安装它并将库复制到项目中并运行
`php load_font.php 'LiHei' 'LiHei.ttf`,
脚本创建了一个dompdf_font_family_cache.php
而不是我需要的dompdf_font_family_cache.dist.php
,所以我修改并添加它
'lihei' => array(
'normal' => DOMPDF_FONT_DIR . 'LiHei',
'bold' => DOMPDF_FONT_DIR . 'LiHei',
'italic' => DOMPDF_FONT_DIR . 'LiHei',
'bold_italic' => DOMPDF_FONT_DIR . 'LiHei',
到数组,但比我得到这个错误
Undefined index: Cat HandleExceptions->handleError('8', 'Undefined index: C', ...在课堂上.pdf.php 2260行
在课堂上.pdf.php 2260行
foreach ($font['C'] as $num => $d) {
if (intval($num) > 0 || $num == '0') {
if (!$font['isUnicode']) {
// With Unicode, widths array isn't used
if ($lastChar>0 && $num>$lastChar+1) {
for ($i = $lastChar+1; $i<$num; $i++) {
$widths[] = 0;
}
}
}
$widths[] = $d;
if ($font['isUnicode']) {
$cid_widths[$num] = $d;
}
if ($firstChar == -1) {
$firstChar = $num;
}
$lastChar = $num;
}
}
lihei.ufm,其中包含以下内容
StartFontMetrics 4.1
Notice Converted by PHP-font-lib
Comment https://github.com/PhenX/php-font-lib
EncodingScheme FontSpecific
Copyright ⡣⤠䍯灹物杨琠䑹湡䍯海慲攠䍯牰⸠㈰〳
FontName 쓗뛂⁐牯
FontSubfamily Media
UniqueID 䱩䡥椠偲漻‶⸰搴攲㬠㈰ㄴⴱㄭ㈶
FullName 쓗뛂⁐牯
Version 㘮つ㑥
PostScriptName 䱩䡥楐牯
Trademark 呲慤敭慲欠批⁄祮慃潭睡牥⁃潲瀮
Weight Medium
ItalicAngle 0
IsFixedPitch false
UnderlineThickness 50
UnderlinePosition -110
FontHeightOffset 0
Ascender 860
Descender -140
FontBBox -60 -171 1003 860
EndFontMetrics
当我检查默认附带的 UFM 时,它包含一个数据矩阵,其中一个是 [C]。
所以
,我只是不断尝试不同的字体,直到我找到能够创建可读 ufm 的字体。 仅供将来参考,我最终使用的字体是Microsoft雅黑。