Sunday, May 17, 2009

Convert the OTF fonts to Postscript Type one (.pfb)

The conversion is lossless as the hinting remain, however you can't do this reliably for large fonts (with more than 256 characters or glyphs). Here is a sample script allowing to convert OpenType fonts to postscript Type One fonts, you will end up with a .afm and a .pfb file :

#!/usr/bin/fontforge
# Quick and dirty hack: converts a font to Postscript Type one (.pfb)
i=1

while ( i<$argc )
Print("Opening : " +$argv[i]);
if($argv[i]:e != "otf")
Print( "Skipping ... Expecting an OpenType font [.otf]" )
else
Open($argv[i])
Print("Saving : " +$argv[i]:r+".pfb");
# If the font is a cid keyed font, you may want to flatten the cid map
# To do this, uncomment the command below :
# CIDFlatten()
SetFontOrder(3)
SelectAll()
Simplify(128+32+8,1.5)
ScaleToEm(1000)
DontAutoHint()
Generate($argv[i]:r + ".pfb")
endif
i = i+1
endloop

Save this script as otf2pfb.sh and set the executable bit ( chmod +x otf2pfb.sh ). To launch this script, just do : ./otf2pfb.sh *.otf
or make otf2pfb
#!/bin/bash
for i in $@; do
fontforge -script /usr/bin/otf2pfb.sh $i
done

and make this executable
and go in terminal to font folder and type:
otf2pfb fontname.otf


For all fiels in a folder do:

otf2pfb *.otf otf


Now the only thing remaining to do is installing the Type1 fonts in the system. For this Mandriva users can use drakfont, others can use type1inst after having copyed the files in /usr/share/fonts/Type1/.

http://linux-wizard.net/index.php?id_blog=142

No comments:

Blog Archive

About Me

Exclusion of liability Regarding StillStupid: The use you make of the guides, tips and downloads that you listed on this web site or on another website to which I refer is entirely at your own risk. In no way can I be held liable for damage or consequential damages of any kind, which occurs as a result of that use.