Generating .afm from .ttf [closed]

2020-08-22 03:40发布

I'm working with generating .pdf's from PHP using this library: http://www.fpdf.org/

I am currently hung up, though, on adding new fonts, specifically the step on generating the .afm file from a .ttf font file.

I'm following the instructions here: http://www.fpdf.org/en/tutorial/tuto7.htm Which state:

The first step for a TrueType consists in generating the AFM file. A utility exists to do this task: ttf2pt1. The Windows binary is available here. The command line to use is the following:

ttf2pt1 -a font.ttf font

For example, for Comic Sans MS Regular:

ttf2pt1 -a c:\windows\fonts\comic.ttf comic

Two files are created; the one we are interested in is comic.afm.

I can't - or am unsure how to - get ttf2pt1 to load. I'm on a mac but running Win XP via vmware... and when I run the ttf2pt1.exe file over in Windows it loads command line and then quickly closes. Is there some procedure I need to do to install it? I'm not well versed in Win command line.

6条回答
Melony?
2楼-- · 2020-08-22 03:55

If you are on linux, you can download the .tgz, untar it, and then run make all. It's pretty quick. Then, you can have a .afm file and a .pfa file by running

ttf2pt1 yourfont.ttf FontName

If you want a .pfb instead of a .pfa, you can run

ttf2pt1 -b yourfont.ttf FontName
查看更多
你好瞎i
3楼-- · 2020-08-22 03:59

FontForge worked, but then I also realized I didn't need to through any of this work. http://fpdf.fruit-lab.de/ will generate all the necessary files.

查看更多
Luminary・发光体
4楼-- · 2020-08-22 03:59

have you run the winbuild.bat in ttf2pt1 folder? Make sure you have C++ on Win machine. Which version of ttf2ptt1 you are using?

查看更多
贼婆χ
5楼-- · 2020-08-22 04:09

You can also do that using FontForge. It's a full-fledged font editor, that lets you convert between many formats. If you open your TrueType font in it, you can generate an AFM file by using Generate Font and choosing PFA or PFB, and checking “generate AFM”.

查看更多
Animai°情兽
6楼-- · 2020-08-22 04:10

Here is another page to generate an afm file from a ttf TTF to AFM Converter

查看更多
走好不送
7楼-- · 2020-08-22 04:13

This question really belongs on superuser.com, but I'll answer it here anyway.

There's no need to install the program. You need to open a command window and type the command out there. You can probably find this under Programs->Accessories->Command Prompt.

查看更多
登录 后发表回答