FPDF - 添加谷歌webfont

时间:2018-02-19 10:42:29

标签: php fpdf

我正在使用FPDF生成带有PHP的pdf,我想使用与我的网站Lato相同的字体。但在我的网站上,我使用google webfont链接:

http://fonts.googleapis.com/css?family=Lato%3A300%2C400%2C700%2C900%2C300italic%2C400italic%2C700italic

所以我没有这些文件,我想知道是否有办法在我的pdf中使用这种字体?

由于

1 个答案:

答案 0 :(得分:3)

您可以做的是下载字体并将其安装到您的系统中,并定义字体路径

define('FPDF_FONTPATH','/home/www/font');

然后相应地设置字体 - doc link

// Times regular 12
$pdf->SetFont('Times');
// Arial bold 14
$pdf->SetFont('Arial','B',14);
// Removes bold
$pdf->SetFont('');
// Times bold, italic and underlined 14
$pdf->SetFont('Times','BIU');

FPDF仅接受.ttf, .otf or .pfb文件类型。

快速Google搜索会为您提供Lato字体的links

也许您还必须检查此链接(Link