【问题标题】:Using Georgia Font in PDFLib on a Mac (El Capitan)在 Mac 上的 PDFLib 中使用 Georgia 字体 (El Capitan)
【发布时间】:2016-08-09 15:41:09
【问题描述】:

我正在使用 PDFLib 创建一个 PDF 文件,不幸的是,我似乎无法让它能够使用 Georgia 文件。除了那个字体,我几乎可以使用任何其他字体。

我已尝试加载文件以及更改搜索路径,但似乎仍然无法正常工作。到目前为止我尝试过的:

$searchPath = "/Library/Fonts";
$p->set_option("searchpath= {" . $searchPath . "}");
$scoreFont = $p->load_font("Georgia", "unicode", "");
if ($scoreFont == 0){
    die("Error: " . $p->get_errmsg());
}

每当我包含此内容时,它都会给我一个“页面不工作”错误。

我不确定它是否相关,但我确实在 Library/Font 目录中看到了 Georgia.ttf 文件,但在 System/Library/Font 目录中没有看到。有人对这个问题有任何经验吗?任何帮助将不胜感激。

提前谢谢你!

编辑

我检查了我的 apache 日志,发现有一个错误,列为:

Tue Aug 09 11:23:48 2016] [notice] child pid 11501 exit signal Segmentation fault (11)

另外,我检查了 PDFLib 日志文件,我看到了:

PDF_load_font[----------------------------------------------------------------   --------------]
[ PDFlib 9.0.5  PHP5 binding on Mac OS X-10.6 64 (le) 2016-08-09 11:23:48      ]
[ Classes: api=1 warning=1                                                     ]
[ Enter in vi to compile it:                                                   ]
[ %s/)$/);/g   and   %s/"(NULL)"/NULL/g   and   %s/\[[^]]*\]//g                ]
[ Program should run on a little-endian platform                               ]
[------------------------------------------------------------------------------]

PDF_set_option(p_0x1097619a8, "searchpath= {/Library/Fonts}")
[New category:resource "SearchPath:/usr/local/PDFlib"]
[New category:resource "SearchPath:/usr/local/PDFlib/PDFlib"]
[New category:resource "SearchPath:/usr/local/PDFlib/PDFlib/9.0"]
[New category:resource "SearchPath:/usr/local/PDFlib/PDFlib/9.0/resource/cmap"]
[New category:resource   "SearchPath:/usr/local/PDFlib/PDFlib/9.0/resource/codelist"]
[New category:resource "SearchPath:/usr/local/PDFlib/PDFlib/9.0/resource/fonts"]
[New category:resource "SearchPath:/usr/local/PDFlib/PDFlib/9.0/resource/glyphlst"]
[New category:resource "SearchPath:/usr/local/PDFlib/PDFlib/9.0/resource/icc"]
[New category:resource "SearchPath:/Users/{username}/PDFlib"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib/9.0"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib/9.0/resource/cmap"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib/9.0/resource/codelist"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib/9.0/resource/fonts"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib/9.0/resource/glyphlst"]
[New category:resource "SearchPath:/Users/{username}/PDFlib/PDFlib/9.0/resource/icc"]
[New category:resource "SearchPath:/Library/Fonts"]

我不确定这些条目的真正含义。在 PDFLib 日志中,实际存在于最后一个目录中的唯一目录,即 /Library/Fonts 目录。在该目录中是 Georgia.ttf 文件。

有什么想法吗?

谢谢!

【问题讨论】:

    标签: pdf fonts pdflib


    【解决方案1】:

    使用上述代码和当前 OSX 上的 PDFlib 9.0.7 进行快速测试可以正常工作。因此,检查您的网络服务器/PHP 的错误日志文件可能是个好主意。也许您的网络服务器没有正确给出 die() 案例中的消息。

    当您在网络服务器日志文件中没有看到任何错误原因时,您可以启用 PDFlib 日志记录,

    $p->set_option("logging {filename {/tmp/PDFlib.log}}");
    

    作为您的第一个 PDFlib 调用。然后你应该看到,如果 load_font() failed (0) 和可能的错误消息。

    编辑:感谢您分享您的日志文件中的更多详细信息。条目

    Tue Aug 09 11:23:48 2016] [notice] child pid 11501 exit signal Segmentation fault (11)
    

    可能表明 Mac 上的 HostFont 问题与 PHP 和 Webserver 结合使用。能否请您禁用主机字体支持。在 PDFlib PHP 示例中,此调用已被注释掉,因此启用调用很简单:

     /* Enable the following line if you experience crashes on OS X
      * (see PDFlib-in-PHP-HowTo.pdf for details):
      */
      $p->set_option("usehostfonts=false");
    

    【讨论】:

    • 感谢您的帮助。在再次遇到错误后,我编辑了上述问题以添加这些日志的内容。他们可能告诉我的任何想法?
    • 您,先生,真是个天才!非常感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 2016-10-10
    • 1970-01-01
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多