OpenOffice.Org Font De-uglification Mini-Howto

Herman Oosthuysen

25 June 2002

System: Mandrake Linux 8.2


General

There are many de-uglification howtos on the web. Each one tells part of the story. I therefore need to explain a few things so you will know how to debug the font issues.


X

X fonts are kept in /usr/share/fonts

The font search path is shown with the command:

# chkfontpath

If a certain font is called for and it cannot be found, then X will substitute something from the top of the list. This will usually be an ugly font. Mandrake ships with font de-uglification turned on. So, if the fonts look ugly, it means that the application cannot find the Anti-Aliased fonts.

OOo is supposed to be able to find any fonts listed by the chkfontpath utility. Unfortunately that doesn't work correctly yet. The workarounds are described below.


Microsoft TTF Fonts

The most commonly used MS fonts are available for free download from Microsoft. If you don't live on an island, then you need to exchange documents with Microsoft Office users. Download and install the MS fonts to resolve this issue.

Get a script here: http://gongolo.usr.dsi.unimi.it/%7Evigna/ Look for "WebFonts4Linux"

The fonts will be installed in /usr/share/fonts/Monotype/TrueType


OOo Spadmin

Use spadmin to force feed fonts to OOo.

Go to the OOo installation directory:

$ cd /home/username/OpenOffice.org1.0

Run the spadmin utility to add the MonoType fonts to OOo.

$ ./spadmin

Click Fonts, Add and select the directory

/usr/share/fonts/Monotype/TrueType

then click OK to add the fonts.

OOo should now work, but may still be tripped up by another bug (depends on your version).


The Font Cache

If you find that the anti-aliased fonts work once and never again, then you have to delete the font cache and prevent a new cache from being created again.

Close any running instances of the OpenOffice.org and Change to the directory that contains your OpenOffice.org installation. If you made a multi user installation (i.e. you installed OpenOffice.org with the /net or -net command line argument) then change to the directory of the user-installation.

Delete the font cache and make anew empty one that is read only:

$ cd /home/username/OpenOffice.org1.0/share/psprint

$ rm pspfontcache

$ touch pspfontcache

$ chmod 444

Restart OpenOffice.org. All problems should be gone now.

When all else fails, read the Installation Guide from page 59...


WebFonts.sh Script

The WebFonts download script is copied here in case the original disappears due to bit rot:

http://gongolo.usr.dsi.unimi.it/%7Evigna/

#!/bin/bash

#
# This is webFonts 1.02, a font installer for Linux.
#
# Copyright (C) 2001 Sebastiano Vigna 
#
#   This program is free software; you can redistribute it and/or modify it
#   under the terms of the GNU General Public License as published by the Free
#   Software Foundation; either version 2 of the License, or (at your option)
#   any later version.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
#   for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

# This directory is used to download the CAB files.

echo
echo "Welcome to webFonts4Linux! (http://gongolo.usr.dsi.unim.it/~vigna/webFonts4Linux/)"
echo
echo "At the end of the installation process, you can use a font"
echo "selector, such as gfontsel or xfontsel, to check whether the"
echo "new fonts are available (e.g., check for \"arial\"). Usually, too see any"
echo "change you will need to restart X or your font server."
echo
echo "Note that you must have TrueType support enabled to use these fonts."
echo

CONFOK=1
if ! which wget &>/dev/null; then CONFOK=0; echo "You need wget to run this script!"; fi
if ! which cabextract &>/dev/null; then CONFOK=0; echo "You need cabextract to run this script!"; fi
if [ "$CONFOK" = "0" ]; then echo; exit 1; fi

DIRNAME=/tmp/webFonts4Linux.CABs
mkdir -p $DIRNAME
if [ ! -w $DIRNAME ]; then echo "Temporary directory is not writable ($DIRNAME). Aborting." ; exit 1; fi

if ! pushd $DIRNAME &>/dev/null; then echo "Cannot cd into temporary directory ($DIRNAME). Aborting."; exit 1; fi;

# First of all we establish where to install the fonts.

FONTDIRNAME=/usr/share/fonts/monotype/TrueType
NEWDIR=1

echo "Please choose the installation directory (it will be created if necessary)."
echo "Note that if you specify an existing directory, you will have to generate"
echo "manually the fonts.dir and fonts.scale files (more on this later)."
echo
echo "You must have enough privileges to write into this directory: in particular,"
echo "if you want to install the fonts in the system hierarchy you must be root."
echo 
echo -n "[$FONTDIRNAME]: "

read INPUT

if [ "$INPUT" != "" ]; then FONTDIRNAME=$INPUT; fi

if [ -d $FONTDIRNAME ]; then
	echo
	echo "Directory exists, you will have to update fonts.dir and fonts.scale."
	NEWDIR=0
else
	if [ -e $FONTDIRNAME ]; then
		echo "The path you specified exists, but it is not a directory. Aborting."
		exit 1
	fi
fi

if ! mkdir -p $FONTDIRNAME; then echo "Cannot create font directory. Aborting."; exit 1; fi

# Now we choose the nearest mirror.

SITE=www.microsoft.com
PS3="-->"

echo
echo "Please choose the mirror nearest to you."
select MIRROR in Redmond Tokyo London; do
	case "$MIRROR" in
		Redmond) SITE=www.microsoft.com;;
		Tokyo)   SITE=www.asia.microsoft.com;;
		London)  SITE=www.eu.microsoft.com;;
	esac
	break;
done

for i in andale webdin trebuc georgi verdan arialb comic impact arial times courie; do
	echo
	echo "Getting font $i..."
	echo

	rm ${i}32.exe &>/dev/null
	wget http://$SITE/typography/downloads/${i}32.exe || exit 1

	echo 

	cabextract ${i}32.exe >/dev/null || exit 1

	# We install all .TTF file (regardless of the case) and downcase them.

	for f in *.[tT][tT][fF]; do
		NEWNAME=$(echo $f | tr '[A-Z]' '[a-z]')
		echo "Installing $NEWNAME in $FONTDIRNAME..."
		mv $f $FONTDIRNAME/$NEWNAME
	done
done	

popd &>/dev/null
rm -rf $DIRNAME

# We give a suggestion as to how to update fonts.dir and fonts.scale.

if [ "$NEWDIR" = "0" ]; then
	echo
	echo "You should have installed the freetype utilites; if so, just type"
	echo
	echo "   cd $FONTDIRNAME; ttmkfdir >fonts.dir; cp fonts.dir fonts.scale"
	echo
	echo "to update your fonts.dir and fonts.scale files, and restart"
	echo "your X font server (or X, if you are not using a font server)."
	echo
	exit 0
fi

pushd $FONTDIRNAME &>/dev/null

# If we created a new directory we also create fonts.scale and fonts.dir.

ln -s fonts.dir fonts.scale

cat >$FONTDIRNAME/fonts.dir </dev/null

# Now we should try to update the font path.

echo
echo "The last operation to be performed is to add $FONTDIRNAME"
echo "to the list of directories containing fonts. This can be"
echo "done in several ways, depending on your distribution and"
echo "configuration. You must have root privileges to do this!"
echo
echo -n "Do you want to continue? [Y/n]: "

read YESNO

if [ "$YESNO" = "n" ]; then exit 0; fi

# Red Hat

OLDPATH="$PATH"
export PATH="/usr/sbin:/sbin:/usr/bin:/bin:$PATH"

if which chkfontpath &>/dev/null; then
	echo
	echo -n "You have the chkfontpath command, so we shall use it... "
	chkfontpath -a $FONTDIRNAME
	echo "done."
	echo
	exit 0
fi

export PATH="$OLDPATH"

# xfs

if [ -e /etc/X11/*fs/config ]; then
	FSCONFIG=$(\ls -1 /etc/X11/*fs/config | tr "\n" " ")
	echo
	echo "It seems like you have a font server installed. You should edit the file(s)"
	echo
	echo $FSCONFIG
	echo
	echo "and add $FONTDIRNAME to the list of font directories."
	echo
	exit 0
fi

# boh

echo
echo "You do not seem to be running a font server. In this case, try the command"
echo
echo "   xset fp+ $FONTDIRNAME"
echo
echo "which will instruct X to look into $FONTDIRNAME"
echo "for fonts. The command, however, must be repeated each time the server"
echo "is started, so you should put it in some startup file."
echo
echo "Alternatively, you can add $FONTDIRNAME"
echo "to the FontPath entry of your X configuration file (usually /etc/X11/XF86Config"
echo "or /etc/X11/XF86Config-4)."
echo 

exit 0


Have fun!

Herman