Squirrel Logo

OpenOffice.org Font Tricks - Tweaking fonts.dir

Johan Vromans


Warning: Draft version.

Warning: All this information has been checked with OpenOffice.org version 1.1.2 on GNU/Linux (Red Hat 7.2).

As already described in article "OpenOffice.org and Fonts", working with fonts on X11-based systems like Linux is tricky, and can often lead to unexpected surprises. OpenOffice.org does a great job to make font use on these systems reliable, however, there are cases where a little help is necessary.

Tweaking fonts.dir

OpenOffice.org maintains information about custom fonts in the file fonts.dir.

For example, if I add the font family Nimbus Sans L in my personal fonts directory (which is $HOME/OpenOffice.org1.1.2/user/fonts), I have the 16 files, 8 with font code (.pfb), and 8 with font metrics (.afm):

      NimbusSanL-Bold.afm
      NimbusSanL-Bold.pfb
      NimbusSanL-BoldCond.afm
      NimbusSanL-BoldCond.pfb
      NimbusSanL-BoldCondItal.afm
      NimbusSanL-BoldCondItal.pfb
      NimbusSanL-BoldItal.afm
      NimbusSanL-BoldItal.pfb
      NimbusSanL-ReguCond.afm
      NimbusSanL-ReguCond.pfb
      NimbusSanL-ReguCondItal.afm
      NimbusSanL-ReguCondItal.pfb
      NimbusSanL-ReguItal.afm
      NimbusSanL-ReguItal.pfb
      NimbusSansL-Regu.afm
      NimbusSansL-Regu.pfb

After running OpenOffice.org once, the file fonts.dir is created (or modified, if it already exists), with the following information (slightly modified for clarity):

   NimbusSanL-Bold.pfb         -misc-Nimbus Sans L-bold-r--utf8-...
   NimbusSanL-BoldItal.pfb     -misc-Nimbus Sans L-bold-i--utf8-...
   NimbusSanL-ReguItal.pfb     -misc-Nimbus Sans L-normal-i--utf8-...
   NimbusSansL-Regu.pfb        -misc-Nimbus Sans L-normal-r--utf8-...
   NimbusSanL-BoldCond.pfb     -misc-Nimbus Sans L-bold-r--utf8-...
   NimbusSanL-BoldCondItal.pfb -misc-Nimbus Sans L-bold-i--utf8-...
   NimbusSanL-ReguCond.pfb     -misc-Nimbus Sans L-normal-r--utf8-...
   NimbusSanL-ReguCondItal.pfb -misc-Nimbus Sans L-normal-i--utf8-...

As you can see, OOo added the 8 fonts as expected. However, upon careful examination you'll notice that the font NimbusSanL-ReguCond.pfb is stored with exactly the same properties as font NimbusSanL-Regu.pfb. In other words, OOo does not recognize that one font is a normal font, and the other is a condensed font. The OOo font picker will only show 4 possibilities for this font.

Without going into too much details of the XLFD (X11 Long Font Description) format, every line is made up of fields separated by dashes. The second field contains the font family name Nimbus Sans L, the third field designates the weight, in this case bold or normal. Then there is the font slant, which is r for upright, or i for italic.

The next field is the font width info, and this is empty in all cases. It should have contained condensed for the condensed variants of the fonts.

So the first thing to try is to put the information there, manually. Using your favourite editor, change the lines to:

   NimbusSanL-Bold.pfb         -misc-Nimbus Sans L-bold-r--utf8-...
   NimbusSanL-BoldItal.pfb     -misc-Nimbus Sans L-bold-i--utf8-...
   NimbusSanL-ReguItal.pfb     -misc-Nimbus Sans L-normal-i--utf8-...
   NimbusSansL-Regu.pfb        -misc-Nimbus Sans L-normal-r--utf8-...
   NimbusSanL-BoldCond.pfb     -misc-Nimbus Sans L-bold-r-condensed-utf8-...
   NimbusSanL-BoldCondItal.pfb -misc-Nimbus Sans L-bold-i-condensed-utf8-...
   NimbusSanL-ReguCond.pfb     -misc-Nimbus Sans L-normal-r-condensed-utf8-...
   NimbusSanL-ReguCondItal.pfb -misc-Nimbus Sans L-normal-i-condensed-utf8-...

Now restart OOo, but first remove the file pspfontcache that resides in ../psprint. In fact, I always remove this file when starting OOo, just to make sure.

Okay, OOo is running again, but nothing has changed. It just does not know how to handle font variants like condensed.

So let's try another trick. Change the font family name:

   NimbusSanL-Bold.pfb         -misc-Nimbus Sans L-bold-r--utf8-...
   NimbusSanL-BoldItal.pfb     -misc-Nimbus Sans L-bold-i--utf8-...
   NimbusSanL-ReguItal.pfb     -misc-Nimbus Sans L-normal-i--utf8-...
   NimbusSansL-Regu.pfb        -misc-Nimbus Sans L-normal-r--utf8-...
   NimbusSanL-BoldCond.pfb     -misc-Nimbus Sans Condensed L-bold-r--utf8-...
   NimbusSanL-BoldCondItal.pfb -misc-Nimbus Sans Condensed L-bold-i--utf8-...
   NimbusSanL-ReguCond.pfb     -misc-Nimbus Sans Condensed L-normal-r--utf8-...
   NimbusSanL-ReguCondItal.pfb -misc-Nimbus Sans Condensed L-normal-i--utf8-...

Restarting OpenOffice.org (remember to remove ../psprint/pspfontcache first) reveals that this trick did work. The font picker now shows two distinct entries, Nimbus Sans L and Nimbus Sans Condensed L, each with 4 typefaces. You can now use all 8 variants of this font.

A final remark: TrueType fonts have a better internal design than Type1 fonts. They provide for more font properties to be stored in the font. When we had tried the above with TrueType fonts, OOo would have picked up the condensed property and put it in fonts.dir. However, OOo would still have been unable to actually do something with it.



© Copyright 2003-2018 Johan Vromans. All Rights Reserved.
OOo/oofonts02.html last modified 23:07:01 26-Feb-2007