我正在创建用于生成pdf的magento扩展。我需要使用Verdana Bold,Verdana Reg…字体到我的pdf文件,该文件使用Zend_pdf生成。任何人都可以解释如何使用正确的路径访问TTF类型的字体。
首先,您应该将所需的字体文件上传到一个目录中。上传字体的最佳位置是lib
文件夹中,因此在本演示中,我将使用lib
文件夹中名为customfonts
的创建目录,并在中上传我的字体文件
现在在所需的php文件上调用它(例如:内部Shipment.php),并像下面的一样使用它
$chevinFontBold = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/customfonts/chevin-bold.ttf');
$page->setFont($chevinFontBold, 8);
这里8是字体大小
//load font from file system
$font = Zend_Pdf_Font::fontWithPath("/path/to/myfont.ttf");
//add $font to page
$page->setFont($font, $fontSize);
希望这能帮助