How to fix bdf or pcf fonts that cannot be used by xft

I installed dina-fonts from the aur after reading about it. It installed fine and I’m able to use it as the font in rxvt if i set this:

urxvt.font: -*-dina-medium-r-normal-*-13-*-*-*-*-*-iso8859-1

But the font wont work if I use it with xft, of from other GUI apps. For example, open office lists dina_r400-13.bdf.pcf.gz as of the available fonts. But selecting them shows another font instead (Monospace). I googled for the problem, and found this two threads:
Why can I not use Dina-font as a Xft font?(SOLVED)
Dina for Linux/X11 – solved
Basically, the problem is that the font does not have the correct headers needed by xft in them. The solution is simple, convert the font into bdf, and then add the needed header manually. There are two ways to convert them into bdf. If you have the original .fon files and wine, you can use the fon2bdf tool. Or you can use pcf2bdf to convert them from pcf.
After that open the bdf file in a text editor (I use vim) and add the correct header according to the second thread.
Here’s the wikipedia page for reference, look under the X Window Properties heading: Glyph Bitmap Distribution Format on Wikipedia
You also need to fix these lines:

SIZE -1 96 96 # these should be SIZE $(POINT_SIZE/10) RESOLUTION_X RESOLUTION_Y
SIZE 10 96 96 # Example for a font with POINT_SIZE 100
#and also
STARTPROPERTIES 10 # this is the number of lines between STARTPROPERTIES and ENDPROPERTIES
STARTPROPERTIES 14 # my dina-font has these many properties

If there is a lot of files to fix then this python script by Jay Bromley could be used to add the missing property – thank you very much for providing the script, I uploaded the script so it would be easier to get for other people, the link is just in case. Unfortunately it did not fix the SIZE line and set the number of properties in STARTPROPERTIES wrong for me. So I had to change them manually.
After that you could use the fonts as bdf fonts or convert them into pcf fonts using bdftopcf.


One thought on “How to fix bdf or pcf fonts that cannot be used by xft

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s