Arial 字体看起来不同于 HTML 到 mpdf 转换

Arial font looks different from HTML to a mpdf conversion

关于字体的工作原理,肯定有一些我不知道的地方,实际上很多东西。可能有人可以解释为什么我的 css 中的字体设置为“font-family: Arial, Helvetica, sans-serif;”

为什么看起来有点不一样?在 pdf 中看起来更圆润。 是否有不同类型的相同字体?如果是这样,我该如何解决?

HTML 页面:

PDF 页面:

这就是我应用到 html 以使用 mpdf

打印的内容
h1
{
text-align: center;
margin-top: 90px;
margin-bottom: 90px;
text-transform: uppercase;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
font-size: 23vw;
}




$htmlStringView = view('pdf-view', ['content' => $content, 'cssString' => $cssString])->render();

$contract = $this->userContractRepository->show($id);
$mpdf = new Mpdf(['tempDir' => '/var/www/storage/temp', 'format' => [198, 280]]);
$contract = $this->addJsonDataToModelAttributes($contract);
$mpdf->SetHTMLFooter('<div style="text-align: right;">{PAGENO}/{nbpg}</div>');
$mpdf->WriteHTML($htmlStringView);
$mpdf->SetTitle($contract->title);
$mpdf->SetAuthor($contract->owner->email);
$mpdf->SetSubject(implode(", ", $contract->persons->pluck('full_name')->toArray()));
$mpdf->SetKeywords($id);
$mpdf->Output('/var/www/storage/app/' . $full_path);

默认情况下,Arial 不包含在 mPDF 发行版中,替代品是 DejavuSans。如果需要,您必须将 mPDF 实例指向字体文件。

$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];

$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];

$mpdf = new \Mpdf\Mpdf([
    'tempDir' => '/var/www/storage/temp',
    'format' => [198, 280],
    'fontDir' => array_merge($fontDirs, [
        __DIR__ . '/custom/font/directory',
    ]),
    'fontdata' => $fontData + [
        'arial' => [
            'R' => 'arial.ttf',
            'I' => 'arial-italic.ttf',
        ]
    ],
]);

https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html