下面我们就使用 ttf2afm 工具生成这个字体对应的 .afm 文件 (由于前面提及对于 TrueType font,从 glyph name --> glyph index 这个mapping 是不靠谱的. 所以这里我们采用 unicode --> glyph index 这个靠谱的映射. 下面的 -u 参数就表示 unicode):
1
ttf2afm -u -e ec-uni.enc -o pala-t1.afm pala.ttf
This simple approach does not handle ligatures; see below.) This can be done easily enough by a script that reads the AGL (Adobe Glyph List)
运行这个命令对应的 log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Warning: ttf2afm (file pala.ttf): `unicode uni02DD' is not mapped to any glyph
Warning: ttf2afm (file pala.ttf): `unicode uni02DA' is not mapped to any glyph
Warning: ttf2afm (file pala.ttf): `unicode uni02C7' is not mapped to any glyph
...
Warning: ttf2afm (file pala.ttf): glyph 8 has multiple encodings (the first one being used): uni0025 uni2027 uni2028 uni2029 uni202A uni202B uni202C uni202D uni202E uni202F
Warning: ttf2afm (file pala.ttf): glyph 130 has multiple encodings (the first one being used): uni009F uni0178
Warning: ttf2afm (file pala.ttf): glyph 238 has multiple encodings (the first one being used): uni0111 uni20AB
Warning: ttf2afm (file pala.ttf): glyph 3 has multiple encodings (the first one being used): uni0020 uni2015 uni2016 uni2017 uni201B uni201F uni2023 uni2024 uni2025 uni2031
...
因为 glyph index --> unicode 这个 mapping 也不总是靠谱的,可能一个 glyph index 对应了多个 unicode.
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdftex) restricted \write18 enabled. entering extended mode (./test.tex{c:/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map} kpathsea: Running mktextfm pala-t1
The command name is C:\texlive\2024\bin\windows\mktextfm
kpathsea: Running mktexmf pala-t1.mf
The command name is C:\texlive\2024\bin\windows\mktexmf name = pala-t1, rootname = pala-t, pointsize = 1 mktexmf: empty or non-existent rootfile! Cannot find pala-t1.mf. kpathsea: Appending font creation commands to missfont.log.
! Font \f=pala-t1 not loadable: Metric (TFM) file not found. <to be read again> \f l.3 \f This is Palatino in the T1 encoding. ?
% pala-t1.pl (FAMILY pala-t1) (CODINGSCHEME FONTSPECIFIC) (DESIGNSIZE R 10.0) (DESIGNUNITS R 1000) (COMMENT DESIGNSIZE (1 em) IS IN POINTS) (COMMENT OTHER DIMENSIONS ARE MULTIPLES OF DESIGNSIZE/1000) (BOUNDARYCHAR O 5) (FONTDIMEN (SLANT R 0.000000) (SPACE D 500) (STRETCH D 250) (SHRINK D 166) (XHEIGHT D 469) (QUAD D 1000) (EXTRASPACE D 166) ) (LIGTABLE ) (CHARACTER O 0 (comment uni0060) (CHARWD R 333) (CHARHT R 676) ) (CHARACTER O 1 (comment uni00B4) (CHARWD R 333) (CHARHT R 676) ) (CHARACTER O 2 (comment uni02C6) (CHARWD R 333) (CHARHT R 676) ) (CHARACTER O 3 (comment uni02DC) (CHARWD R 333) (CHARHT R 640) )
...
(CHARACTER O 375 (comment uni00FD) (CHARWD R 556) (CHARHT R 670) (CHARDP R 283) ) (CHARACTER O 376 (comment uni00FE) (CHARWD R 601) (CHARHT R 726) (CHARDP R 280) ) (CHARACTER O 377 (comment uni00DF) (CHARWD R 556) (CHARHT R 730) (CHARDP R 8) )
.tfm 文件
然后再使用如下命令生成对应的 .tfm 文件:
1
pltotf pala-t1.pl
运行这个命令后,生成了 pala-tl.tfm 文件, 运行的 log 为:
1 2
I had to round some heights by 13.0000000 units. I had to round some depths by 2.5000000 units.
$ pdftex test.tex This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdftex) restricted \write18 enabled. entering extended mode (./test.tex{c:/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map} [1{ec-uni.enc}] )<pala.ttf><c:/texlive/2024/texmf-dist/fonts/type1/public/amsfo nts/cm/cmr10.pfb> Output written on test.pdf (1 page, 12444 bytes). Transcript written on test.log.