In TCPDF, there are only a few fonts to choose from, to create pdf files. I want to set Tahoma
as my pdf font. How can I include Tahoma
in TCPDF??
在TCPDF中,只有少数字体可供选择,以创建pdf文件。我想把Tahoma设置为pdf字体。我如何在TCPDF中包括Tahoma ?
13 个解决方案
#1
59
The latest TCPDF version automatically convert fonts into TCPDF format using the addTTFfont() method. For example:
最新的TCPDF版本使用addTTFfont()方法自动将字体转换为TCPDF格式。例如:
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = TCPDF_FONTS::addTTFfont('/path-to-font/FreeSerifItalic.ttf', 'TrueTypeUnicode', '', 96);
// use the font
$pdf->SetFont($fontname, '', 14, '', false);
For further information and examples, please check the TCPDF Fonts documentation page.
有关进一步的信息和示例,请检查TCPDF字体文档页。
NOTE: Once the font has been converted, TCPDF no longer requires the TTF file or the above call to addTTFfont()
!
注意:一旦字体被转换,TCPDF不再需要TTF文件或上面的调用addTTFfont()!
#2
23
I have discovered a very good tool online. The only thing you need to do is to upload your .ttf file and then download the files and copy then into the /fonts folder.
我在网上发现了一个很好的工具。你唯一需要做的就是上传你的.ttf文件,然后下载文件,然后拷贝到/字体文件夹。
http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf
http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf
#3
8
The addTTFfont method is not available on TCPDF main class so following worked for me.
addTTFfont方法在TCPDF主类上是不可用的,所以下面的方法对我有用。
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = TCPDF_FONTS::addTTFfont('pathto/arial.ttf', 'TrueTypeUnicode', '', 96);
// use the font
$pdf->SetFont($fontname, '', 14, '', false);
Hope this helps!
希望这可以帮助!
#4
3
I don't know anything about tcpdf or php, but I found this:
我对tcpdf或php一无所知,但我发现:
http://www.tcpdf.org/examples/example_033.phps
http://www.tcpdf.org/examples/example_033.phps
Apparently you just use the font's name, not the file name.
显然,您只是使用了字体的名称,而不是文件名。
Strike one!
罢工一个!
Okay, how about this page. To prep a font to be used by TCPDF, you have to run the file through a command line utility and a PHP script.
好吧,这一页怎么样?要准备TCPDF使用的字体,您必须通过命令行实用程序和PHP脚本运行该文件。
$ ttf2ufm -a -F myfont.ttf
$ ttf2ufm -F myfontttf。
And then:$ php -q makefont.php myfont.ttf myfont.ufm
orMakeFont(string $fontfile, string $fmfile [, boolean $embedded [, $enc="cp1252" [, $patch=array()]]])
然后是:$ php -q makefont。php myfont。ttf myfont。ufm或MakeFont(字符串$fontfile, string $fmfile[,布尔$嵌入[,$enc="cp1252" [, $patch=array()]])
ttf2ufm is distributed with TCPDF in the TCPDF/fonts directory.
ttf2ufm在TCPDF/字体目录中与TCPDF一起发布。
#5
3
the below lines will generate 3 files in ur fonts folder 1.rotisserifi56.php 2.rotisserifi56.ctg 3.rotisserifi56.rar
下面的行将生成3个文件在ur字体文件夹1.rotisserifi56。php 2. rotisserifi56。ctg 3. rotisserifi56.rar
use this to generate the required php and other files
$fontname = $this->pdf->addTTFfont('D:/wamp/www/projectname/sites/all/modules/civicrm/packages/tcpdf/fonts/Rotis Serif Italic 56.ttf', 'TrueTypeUnicode', '', 32);
// use the font
$this->pdf->SetFont($fontname, '', 14, '', false);
Now,
现在,
use the fonts like this:
使用如下字体:
$this->pdf->AddFont('rotisserifi56', '', 'rotisserifi56.php');
$this->pdf->SetFont('rotisserifi56');
--hope this helps some one :)
——希望这对你有帮助
#6
2
I found the addTTFfont method a little finicky (ok, probably didn't try very hard) and the online tool mentioned above works for FPDF but misses the ctg.z file that TCPDF requires.
我发现addTTFfont方法有点过分(好吧,可能不是很努力),上面提到的在线工具适用于FPDF,但却忽略了ctg。TCPDF需要的z文件。
This one - http://fonts.snm-portal.com/ - generates the 3 required files (.php, .z and .ctg.z) for TCPDF. Convert the TTF, upload the three files to your fonts folder and you're good to go.
这个- http://fonts.snm-portal.com/ -生成3个必需的文件(。TCPDF的php、.z和.ctg.z。转换TTF,将三个文件上载到你的字体文件夹,你就可以走了。
#7
2
First create .php ,.afm,.z from http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf and move all three in same directory containing .ttf file. then Use This :
首先创建。php,.afm。从http://www.xml-convert.com/en/convert- tff-toafm -fpdf-tcpdf中,将所有三个文件都移到包含.ttf文件的同一个目录中。然后用这个:
$pdf->AddFont(path-to/universe.ttf','',path-to/universe.php');
$pdf->SetFont(path-to/universe.ttf','',10);
#8
2
Latest TCPDF supports custom fonts.
最新的TCPDF支持定制字体。
Documentation about using custom fonts with TCPDF can be read here.
关于使用自定义字体和TCPDF的文档可以在这里阅读。
#9
1
the best way i have been tried and worked 100% put your TTF
font in fonts folder and then use this constant K_PATH_FONTS + FONT NAME
我尝试过的最好的方法是100%地将TTF字体放在字体文件夹中,然后使用这个常量k_path_字体+字体名称。
$font1 = $this->pdf->addTTFfont(K_PATH_FONTS . 'arial.ttf', 'TrueTypeUnicode', '', 8);
$this->pdf->SetFont($font1, '', 15, '', false);
#10
0
There is no point in using addTTFfont() if you don't have the .ttf file.
如果您没有.ttf文件,那么使用addTTFfont()是没有意义的。
And the whole point is: if there is NO ttf file, how can someone use addTTFfont() function?
重点是:如果没有ttf文件,如何使用addTTFfont()函数?
For example, there is no cid0cs file in font/ directory (TCPDF 6.0.20), only cid0cs.php, which is NOT a font file.
例如,在字体/目录中没有cid0cs文件(TCPDF 6.0.20),只有cid0cs。php,它不是一个字体文件。
#11
0
I wasn't able to find addTTFFont() in the latest release of tcpdf. However, I was able to include a custom TTF file by myself. Within the tcpdf folder is a folder named tools
which include a PHP file called tcpdf_addfont.php
.
在tcpdf的最新版本中,我无法找到addTTFFont()。但是,我可以自己包含一个定制的TTF文件。在tcpdf文件夹中有一个名为tools的文件夹,其中包括一个名为tcpdf_addfont.php的PHP文件。
I symlinked it to my home directory (you can omit this step) and run it like this: shell ./addfont.php -b -t TrueTypeUnicode -f 32 -i myfont.ttf
我将它链接到我的主目录(您可以省略此步骤)并像这样运行它:shell ./addfont。php -b -t TrueTypeUnicode - f32 - myfontttf。
That's it, it will dump something similar to this: ```
就是这样,它会把类似的东西倒出来
Converting fonts for TCPDF: *** Output dir set to /Users/pascalraszyk/XXX/XXX/pdf/vendor/tecnick.com/tcpdf/fonts/ +++ OK : /Users/pascalraszyk/XXX/XXX/pdf/myfont.ttf added as myfont Process successfully completed! ```
转换字体为TCPDF: ***输出目录设置为/用户/pascalraszyk/XXX/ pdf/供应商/tecnick.com/tcpdf/fonts/ ++ OK: /用户/pascalraszyk/XXX/XXX/pdf/myfont。ttf添加为myfont过程成功完成!' ' '
Note: There are more examples within the tools
folder for various font types. I used composer to checkout tcpdf.
注意:在工具文件夹中有更多不同字体类型的示例。我使用了composer来检查tcpdf。
As long as you put your font definition files in the tcpdf/fonts
folder you should be good to go!
只要你把你的字体定义文件放在tcpdf/字体文件夹里,你就应该去!
I used HTML2PDF which uses tcpdf under the hood and it worked like a charm.
我使用的是HTML2PDF,它使用的是tcpdf在引擎盖下,它的工作就像一个魅力。
#12
0
I had this problem despite having all the right files. I had to change the file names to all lower case
尽管有所有的文件,我还是遇到了这个问题。我必须把文件名改成小写字母。
#13
0
When was not possible convert font GothamRounded standard way, I was looking for another tool and only this one http://fonts.snm-portal.com/ worked for me.
当不可能转换字体时,我正在寻找另一个工具,只有这个http://fonts.snm-portal.com/为我工作。
#1
59
The latest TCPDF version automatically convert fonts into TCPDF format using the addTTFfont() method. For example:
最新的TCPDF版本使用addTTFfont()方法自动将字体转换为TCPDF格式。例如:
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = TCPDF_FONTS::addTTFfont('/path-to-font/FreeSerifItalic.ttf', 'TrueTypeUnicode', '', 96);
// use the font
$pdf->SetFont($fontname, '', 14, '', false);
For further information and examples, please check the TCPDF Fonts documentation page.
有关进一步的信息和示例,请检查TCPDF字体文档页。
NOTE: Once the font has been converted, TCPDF no longer requires the TTF file or the above call to addTTFfont()
!
注意:一旦字体被转换,TCPDF不再需要TTF文件或上面的调用addTTFfont()!
#2
23
I have discovered a very good tool online. The only thing you need to do is to upload your .ttf file and then download the files and copy then into the /fonts folder.
我在网上发现了一个很好的工具。你唯一需要做的就是上传你的.ttf文件,然后下载文件,然后拷贝到/字体文件夹。
http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf
http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf
#3
8
The addTTFfont method is not available on TCPDF main class so following worked for me.
addTTFfont方法在TCPDF主类上是不可用的,所以下面的方法对我有用。
// convert TTF font to TCPDF format and store it on the fonts folder
$fontname = TCPDF_FONTS::addTTFfont('pathto/arial.ttf', 'TrueTypeUnicode', '', 96);
// use the font
$pdf->SetFont($fontname, '', 14, '', false);
Hope this helps!
希望这可以帮助!
#4
3
I don't know anything about tcpdf or php, but I found this:
我对tcpdf或php一无所知,但我发现:
http://www.tcpdf.org/examples/example_033.phps
http://www.tcpdf.org/examples/example_033.phps
Apparently you just use the font's name, not the file name.
显然,您只是使用了字体的名称,而不是文件名。
Strike one!
罢工一个!
Okay, how about this page. To prep a font to be used by TCPDF, you have to run the file through a command line utility and a PHP script.
好吧,这一页怎么样?要准备TCPDF使用的字体,您必须通过命令行实用程序和PHP脚本运行该文件。
$ ttf2ufm -a -F myfont.ttf
$ ttf2ufm -F myfontttf。
And then:$ php -q makefont.php myfont.ttf myfont.ufm
orMakeFont(string $fontfile, string $fmfile [, boolean $embedded [, $enc="cp1252" [, $patch=array()]]])
然后是:$ php -q makefont。php myfont。ttf myfont。ufm或MakeFont(字符串$fontfile, string $fmfile[,布尔$嵌入[,$enc="cp1252" [, $patch=array()]])
ttf2ufm is distributed with TCPDF in the TCPDF/fonts directory.
ttf2ufm在TCPDF/字体目录中与TCPDF一起发布。
#5
3
the below lines will generate 3 files in ur fonts folder 1.rotisserifi56.php 2.rotisserifi56.ctg 3.rotisserifi56.rar
下面的行将生成3个文件在ur字体文件夹1.rotisserifi56。php 2. rotisserifi56。ctg 3. rotisserifi56.rar
use this to generate the required php and other files
$fontname = $this->pdf->addTTFfont('D:/wamp/www/projectname/sites/all/modules/civicrm/packages/tcpdf/fonts/Rotis Serif Italic 56.ttf', 'TrueTypeUnicode', '', 32);
// use the font
$this->pdf->SetFont($fontname, '', 14, '', false);
Now,
现在,
use the fonts like this:
使用如下字体:
$this->pdf->AddFont('rotisserifi56', '', 'rotisserifi56.php');
$this->pdf->SetFont('rotisserifi56');
--hope this helps some one :)
——希望这对你有帮助
#6
2
I found the addTTFfont method a little finicky (ok, probably didn't try very hard) and the online tool mentioned above works for FPDF but misses the ctg.z file that TCPDF requires.
我发现addTTFfont方法有点过分(好吧,可能不是很努力),上面提到的在线工具适用于FPDF,但却忽略了ctg。TCPDF需要的z文件。
This one - http://fonts.snm-portal.com/ - generates the 3 required files (.php, .z and .ctg.z) for TCPDF. Convert the TTF, upload the three files to your fonts folder and you're good to go.
这个- http://fonts.snm-portal.com/ -生成3个必需的文件(。TCPDF的php、.z和.ctg.z。转换TTF,将三个文件上载到你的字体文件夹,你就可以走了。
#7
2
First create .php ,.afm,.z from http://www.xml-convert.com/en/convert-tff-font-to-afm-pfa-fpdf-tcpdf and move all three in same directory containing .ttf file. then Use This :
首先创建。php,.afm。从http://www.xml-convert.com/en/convert- tff-toafm -fpdf-tcpdf中,将所有三个文件都移到包含.ttf文件的同一个目录中。然后用这个:
$pdf->AddFont(path-to/universe.ttf','',path-to/universe.php');
$pdf->SetFont(path-to/universe.ttf','',10);
#8
2
Latest TCPDF supports custom fonts.
最新的TCPDF支持定制字体。
Documentation about using custom fonts with TCPDF can be read here.
关于使用自定义字体和TCPDF的文档可以在这里阅读。
#9
1
the best way i have been tried and worked 100% put your TTF
font in fonts folder and then use this constant K_PATH_FONTS + FONT NAME
我尝试过的最好的方法是100%地将TTF字体放在字体文件夹中,然后使用这个常量k_path_字体+字体名称。
$font1 = $this->pdf->addTTFfont(K_PATH_FONTS . 'arial.ttf', 'TrueTypeUnicode', '', 8);
$this->pdf->SetFont($font1, '', 15, '', false);
#10
0
There is no point in using addTTFfont() if you don't have the .ttf file.
如果您没有.ttf文件,那么使用addTTFfont()是没有意义的。
And the whole point is: if there is NO ttf file, how can someone use addTTFfont() function?
重点是:如果没有ttf文件,如何使用addTTFfont()函数?
For example, there is no cid0cs file in font/ directory (TCPDF 6.0.20), only cid0cs.php, which is NOT a font file.
例如,在字体/目录中没有cid0cs文件(TCPDF 6.0.20),只有cid0cs。php,它不是一个字体文件。
#11
0
I wasn't able to find addTTFFont() in the latest release of tcpdf. However, I was able to include a custom TTF file by myself. Within the tcpdf folder is a folder named tools
which include a PHP file called tcpdf_addfont.php
.
在tcpdf的最新版本中,我无法找到addTTFFont()。但是,我可以自己包含一个定制的TTF文件。在tcpdf文件夹中有一个名为tools的文件夹,其中包括一个名为tcpdf_addfont.php的PHP文件。
I symlinked it to my home directory (you can omit this step) and run it like this: shell ./addfont.php -b -t TrueTypeUnicode -f 32 -i myfont.ttf
我将它链接到我的主目录(您可以省略此步骤)并像这样运行它:shell ./addfont。php -b -t TrueTypeUnicode - f32 - myfontttf。
That's it, it will dump something similar to this: ```
就是这样,它会把类似的东西倒出来
Converting fonts for TCPDF: *** Output dir set to /Users/pascalraszyk/XXX/XXX/pdf/vendor/tecnick.com/tcpdf/fonts/ +++ OK : /Users/pascalraszyk/XXX/XXX/pdf/myfont.ttf added as myfont Process successfully completed! ```
转换字体为TCPDF: ***输出目录设置为/用户/pascalraszyk/XXX/ pdf/供应商/tecnick.com/tcpdf/fonts/ ++ OK: /用户/pascalraszyk/XXX/XXX/pdf/myfont。ttf添加为myfont过程成功完成!' ' '
Note: There are more examples within the tools
folder for various font types. I used composer to checkout tcpdf.
注意:在工具文件夹中有更多不同字体类型的示例。我使用了composer来检查tcpdf。
As long as you put your font definition files in the tcpdf/fonts
folder you should be good to go!
只要你把你的字体定义文件放在tcpdf/字体文件夹里,你就应该去!
I used HTML2PDF which uses tcpdf under the hood and it worked like a charm.
我使用的是HTML2PDF,它使用的是tcpdf在引擎盖下,它的工作就像一个魅力。
#12
0
I had this problem despite having all the right files. I had to change the file names to all lower case
尽管有所有的文件,我还是遇到了这个问题。我必须把文件名改成小写字母。
#13
0
When was not possible convert font GothamRounded standard way, I was looking for another tool and only this one http://fonts.snm-portal.com/ worked for me.
当不可能转换字体时,我正在寻找另一个工具,只有这个http://fonts.snm-portal.com/为我工作。