<small id='fPl81'></small><noframes id='fPl81'>

      <tfoot id='fPl81'></tfoot>

      <legend id='fPl81'><style id='fPl81'><dir id='fPl81'><q id='fPl81'></q></dir></style></legend>
      • <bdo id='fPl81'></bdo><ul id='fPl81'></ul>
    1. <i id='fPl81'><tr id='fPl81'><dt id='fPl81'><q id='fPl81'><span id='fPl81'><b id='fPl81'><form id='fPl81'><ins id='fPl81'></ins><ul id='fPl81'></ul><sub id='fPl81'></sub></form><legend id='fPl81'></legend><bdo id='fPl81'><pre id='fPl81'><center id='fPl81'></center></pre></bdo></b><th id='fPl81'></th></span></q></dt></tr></i><div id='fPl81'><tfoot id='fPl81'></tfoot><dl id='fPl81'><fieldset id='fPl81'></fieldset></dl></div>
    2. TCPDF,“无法包含字体定义文件"使用 OpenType 字体

      TCPDF, quot;Could not include font definition filequot; with OpenType fonts(TCPDF,“无法包含字体定义文件使用 OpenType 字体)
      • <bdo id='Q7aMP'></bdo><ul id='Q7aMP'></ul>
        <legend id='Q7aMP'><style id='Q7aMP'><dir id='Q7aMP'><q id='Q7aMP'></q></dir></style></legend>
              <tbody id='Q7aMP'></tbody>

              1. <i id='Q7aMP'><tr id='Q7aMP'><dt id='Q7aMP'><q id='Q7aMP'><span id='Q7aMP'><b id='Q7aMP'><form id='Q7aMP'><ins id='Q7aMP'></ins><ul id='Q7aMP'></ul><sub id='Q7aMP'></sub></form><legend id='Q7aMP'></legend><bdo id='Q7aMP'><pre id='Q7aMP'><center id='Q7aMP'></center></pre></bdo></b><th id='Q7aMP'></th></span></q></dt></tr></i><div id='Q7aMP'><tfoot id='Q7aMP'></tfoot><dl id='Q7aMP'><fieldset id='Q7aMP'></fieldset></dl></div>

                <small id='Q7aMP'></small><noframes id='Q7aMP'>

                <tfoot id='Q7aMP'></tfoot>
                本文介绍了TCPDF,“无法包含字体定义文件"使用 OpenType 字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我是一名 Web 程序员,对字体没有深入了解,正在努力让 TCPDF 包含我们的自定义 OpenType 字体.我们购买了不受任何 DRM 保护的 OpenType 字体文件 (.oft).

                I am a web programmer with no in-depth knowledge of fonts and am struggling to get TCPDF to include our custom OpenType font. We have bought OpenType font files (.oft), which are not protected by any kind of DRM.

                很多关于此错误消息的问题最终都得到了相同的建议.我已经为 TCPDF (755) 使用的文件夹设置了正确的文件权限,并且使用 addTTFfont() 来包含 .ttf TrueType 字体没有问题,如下所示:

                A lot of questions regarding this error message end up getting the same advice. I've set the correct file permissions for the folders used by TCPDF (755) and I have no trouble using the addTTFfont() to including .ttf TrueType fonts like so:

                $pdf->addTTFfont('/path-to-font/DejaVuSans.ttf', 'TrueTypeUnicode', '', 32);

                所以我编写了以下代码来包含我们的 OpenFont 类型.addTTFfont() 文档似乎表明支持 OpenTypeUnicode 和 OpenType 参数.

                So I've made up the following code to include our OpenFont type. The addTTFfont() documentation seems to indicate support of OpenTypeUnicode and OpenType parameters.

                $pdf->addTTFfont('/path-to-font/customfont.otf', 'OpenTypeUnicode', '', 96);

                结果:

                TCPD 错误:无法包含字体定义文件:

                我们使用的是 TCPDF v6.0.020,我一直在阅读 TCPPDF 字体信息页面 到目前为止运气不佳.我注意到 TCPDF 也有 addFont() 函数 (此处的文档) 使用起来似乎更明显,因为它不包含对任何字体类型的任何引用.但是,我无法使用它所拥有的小文档来使用此功能.

                We're using TCPDF v6.0.020 and I've been reading the TCPDF Fonts information page with no luck so far. I've noticed TCPDF also has the addFont() function (documentation here) which seems more obvious to use as it does not include any reference to any font type. However, I was unable to get this function to work with the little documentation it has.

                任何帮助将不胜感激.

                推荐答案

                您确定在调用 addTTFfont() 时遇到该错误吗?我问的原因是因为我检查了 TCPDF 代码(只是对无法包含字体定义文件"进行了全局搜索)并且该消息仅出现在 addFont() 方法中.

                Are you sure that you are getting that error when calling addTTFfont()? The reason I ask is because I checked the TCPDF code (just did a global search on "Could not include font definition file") and that message only appears in the addFont() method.

                这两种方法可能有点混乱,但我几个月前给自己写了一些笔记,下面我会部分复制,希望对你有所帮助:

                These two methods can be a bit confusing, but I wrote myself some notes a few months ago, which I will partially reproduce below in the hope that it helps you somehow:

                • addTTFfont() - 此方法的主要功能是将字体从 TTF(或 OTF)转换为 TCPDF 需要的原始"版本.理论上,此功能的实现方式可以用作向文档添加字体的主要方法.它将首先检查 tcpdf 字体文件夹,如果转换后的文件不存在,它将继续进行转换.这只是多一点开销,但仍然不是我向文件添加字体的首选方法,因为您需要知道要转换的字体样式才能使该过程成功运行.IMO,最好使用此方法预先转换您计划使用的任何字体,只需使用 addFont() 将原始"版本添加到文档中.

                • addTTFfont() - The primary function of this method is to convert a font from TTF (or OTF) to the "raw" version that TCPDF needs. The way this function is implemented you could, in theory, use it as your primary method of adding fonts to a document. It will check the tcpdf font folder first and if the converted files aren't there it will go ahead and do the conversion. It is only a little bit more overhead, but still not my preferred method of adding fonts to files, as you need to know what style of font you are converting for the process to even work successfully. IMO, it is better to use this method to pre-convert any fonts that you plan on using and simply use addFont() to add the "raw" versions to the document.

                AddFont() - 这会向文档添加原始"(即已转换)字体,这意味着它随后可用于编写文本.

                AddFont() - This adds a "raw" (ie. already converted) font to the document, which means it is then available for writing text.

                SetFont() - 这会为您编写的下一段文本设置字体.

                SetFont() - This sets the font for the next chunk of text that you write.

                所以我会使用 addTTFfont() 将字体预转换为原始"版本,然后使用 addFont()setFont() 在实际创建 PDF 的代码中.

                So I would use addTTFfont() to pre-convert the font to the "raw" version, then use addFont() and setFont() in the code that actually creates the PDF.

                如果 addFont() 失败并显示上述错误消息,则意味着它找不到字体定义文件.请记住,如果您使用样式集('i'、'b'、'bi' 等)调用 addFont(),它所做的只是将其附加到文件名(在扩展名之前)).

                If addFont() is failing with the error message above, it means it cannot find the font definition file. Keep in mind that if you call addFont() with style set ('i', 'b', 'bi', etc), all it does is append this to the file name (before the extension).

                最重要的是,您需要确保对 addTTFFont() 的调用正在生成原始"字体文件并将它们保存到您的字体文件夹中.每个样式应该有三个文件,扩展名为 .php.z.ctg.z.所以如果你转换了一个名为 blah.ttf 的字体,你最终会得到 blah.phpblah.zblah.ctg.z.如果你转换 blah bold.ttf,TCPDF 会判断它是粗体,并在文件名的末尾附加b":blahb.phpblahb.zblahb.ctg.z.

                Most importantly, you need to make sure that your call to addTTFFont() is producing the "raw" font files and saving them into your fonts folder. There should be three files per style, with extensions of .php, .z and .ctg.z. So if you converted a font called blah.ttf you will end up with blah.php, blah.z and blah.ctg.z. If you convert blah bold.ttf, TCPDF will figure out that it is a bold font and append the 'b' to the end of the file names: blahb.php, blahb.z and blahb.ctg.z.

                希望这里会有一些有用的金块!祝你好运!

                Hopefully there will be some nugget in here that will help! Good luck!

                这篇关于TCPDF,“无法包含字体定义文件"使用 OpenType 字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How do I pass parameters into a PHP script through a webpage?(如何通过网页将参数传递给 PHP 脚本?)
                PHP - include a php file and also send query parameters(PHP - 包含一个 php 文件并发送查询参数)
                Where can I read about conditionals done with quot;?quot; and quot;:quot; (colon)?(我在哪里可以阅读有关使用“?完成的条件的信息?和“:(冒号)?)
                Accessing arrays whitout quoting the key(在不引用键的情况下访问数组)
                What is the name for the quot;lt;lt;lt;quot; operator?(“lt;lt;lt;的名字是什么?操作员?)
                default as first option in switch statement?(默认为 switch 语句中的第一个选项?)

                • <bdo id='ZFgHy'></bdo><ul id='ZFgHy'></ul>
                  <tfoot id='ZFgHy'></tfoot>

                    <tbody id='ZFgHy'></tbody>
                  <i id='ZFgHy'><tr id='ZFgHy'><dt id='ZFgHy'><q id='ZFgHy'><span id='ZFgHy'><b id='ZFgHy'><form id='ZFgHy'><ins id='ZFgHy'></ins><ul id='ZFgHy'></ul><sub id='ZFgHy'></sub></form><legend id='ZFgHy'></legend><bdo id='ZFgHy'><pre id='ZFgHy'><center id='ZFgHy'></center></pre></bdo></b><th id='ZFgHy'></th></span></q></dt></tr></i><div id='ZFgHy'><tfoot id='ZFgHy'></tfoot><dl id='ZFgHy'><fieldset id='ZFgHy'></fieldset></dl></div>

                  <small id='ZFgHy'></small><noframes id='ZFgHy'>

                • <legend id='ZFgHy'><style id='ZFgHy'><dir id='ZFgHy'><q id='ZFgHy'></q></dir></style></legend>