Hack 25. Use Windows and Mac Fonts


from other operating systems.A major problem that has been
leveled
at the Linux desktop is a lack of good-quality fonts. This is because
font creation is a time-consuming and expensive process that requires
a lot of skill. Those who know how to do it are generally not
inclined to give their work away for free (a nice contrast to the
thousands of open source programmers who do give their code away).
You can purchase fonts to use with your Linux system, but it is
cheaper to use fonts you already have on another OS.
|
4.5.1. Use Windows Fonts
Linux has full support for the
TrueType fonts used by Windows. One method of using the fonts is to
simply copy them from Windows and install them either in the X font
directories or in .fonts in your home directory.
Although this method works, if you have Windows installed on the same
computer that runs Linux, it's unnecessary to copy
all those fonts when you can use a more elegant solution and access
them from one place.First, you need to ensure that you can mount your Windows partition.
To do this you need to have support for the VFAT (or NTFS if you use
Windows 2000/XP) filesystem in your kernel. My distribution kernels
include this support, but if you compile your own kernels, you need
to add support yourself. In your kernel configuration tool, enable
support by selecting File systems
systems
File systems
do this manually with the following:
foo@bar:~$ mkdir /mnt/windowsYour Windows partition might be located someplace other than
foo@bar:~$ mount -t vfat /dev/hda1 /mnt/windows
/dev/hda1 and you can use a different mount
point than /mnt/windows. If you are unsure which
partition numbers are available, you can type this command to see a
list:
foo@bar:~$ ls -al /dev/hda*To make mounting easier, add this mount point to the list of
available mount points in /etc/fstab. This file
tells the system which disks are available and how they are accessed.
You should add one of these two lines depending on whether you have a
VFAT- or NTFS-formatted Windows partition:
/dev/hda1 /mnt/windows vfat rw 0 0This tells the system that /dev/hda1 is
/dev/hda1 /mnt/windows ntfs ro 0 0
available in /mnt/windows with read and write
access and to mount it at every boot. NTFS is mounted read-only
(ro), because writing to an NTFS partition is not
supported and will cause data corruption.To use the fonts, you need to access the Windows font directory and
run some utilities that will make the fonts usable in X Windows.
Although X supports TrueType fonts, it needs some special files to be
generated that provide information about the fonts. Windows often
keeps fonts in C:\Windows\Fonts, so you should
go to /mnt/windows/windows/fonts to run the
commands.The first command is called ttmkfdir. This
command creates a special font
information file called fonts.scale that
displays a list of the fonts and their capabilities in a format the X
server can understand; this acts like a reference card that says what
each font can do. To create this file, simply run the command inside
the font directory:
foo@bar:~$ ttmkfdirIf your Windows partition is NTFS, you won't be able
to run this command because your access is read-only. To get around
this, copy the fonts to a directory on your Linux system and run the
command. Then copy the file it creates,
fonts.scale, to media you can access from
Windows, such as a floppy disk or USB memory key. From there you can
put it in your C:\Windows\fonts directory. You
will have to repeat this work each time you add new fonts to your
Windows partition that you want to use in Linux, so you have to
question if it is really worth it.You now need to tell XFree86 that this font directory exists and it
should use it. You can do this in one of two ways. The first method
is to add a FontPath line to your X11
configuration file, which is commonly
/etc/X11/XF86Config-4:
FontPath "/mnt/windows/Windows/Fonts"When you have added this, you will need to restart your X server.
|
the chkfontpath command to add the path
dynamically:
foo@bar:~$ chkfontpath --add /mnt/windows/Windows/FontsIf you add the directory using this command, you must restart the
font server and restart XFree86. You can do this with the following:
foo@bar:~$ /etc/init.d/xfs restartNow your fonts should be available.
4.5.2. Use Mac OS X Fonts
Although Mac OS X has
support for TrueType
fonts, Apple decided to store many of the native system font details
in special files known as data fork resource
files. These files end in the extension
.dfont and contain a lot more information than
is typically found in a TrueType font file. This information is
specific to the Mac OS X operating system, so just copying the files
over to Linux is not enough as X would not understand what to do with
this extra information. Therefore, you need to convert these files to
something X can use with the aid of a nifty little tool called Fondu.Fondu (http://fondu.sourceforge.net/) has been
developed to extract font information from the
.dfont files and make usable TrueType font
files. Fondu includes not only a converter, but also several other
tools to deal with font differences between Unix-type operating
systems, such as Linux/BSD and Mac OS X. On the home page is a Mac OS
X StuffIt archive that you need to download to your Mac.When you have downloaded the archive, double-click the icon to
extract the software and a .pkg icon will appear on the desktop. When
you click this icon, the installation routine will run. Although the
installer will require the normal process of clicking Next and
selecting where to install the files, you should also set your
PATH and MANPATH environment
variables to /usr/local/bin and
/usr/local/man, respectively, so that the
installed files are accessible anywhere in Mac OS X. You can do this
in the .profile file inside your directory (this
file is read each time you log in and sets up any environment
settings such as those defined by these variables):
PATH = /usr/local/bin:$PATHNow log off Mac OS X and then log back on, and check that these
MANPATH = /usr/local/man:$MANPATH
export PATH MANPATH
variables are set by typing the following:
foo@bar:~$ echo $PATHTo convert the fonts, create a directory in which to perform the
foo@bar:~$ echo $MANPATH
conversion:
foo@bar:~$ mkdir ~/fontconvYou cannot convert the main font files in the system font directory
as write access is disabled, so use fontconv as
a temporary directory. Use this command to copy the fonts from the
/System/Library/Fonts directory into your new
directory:
foo@bar:~$ cp /System/Library/Fonts/* ~/fontconvNow if you go to the fontconv directory, you can
perform the conversion with:
foo@bar:~$ fondu *When this process is finished you will see a number of
.ttf fonts in the directory. Create another
directory called macfonts into which to copy the
TrueType fonts, and then make a tarball of them:
foo@bar:~$ mkdir ~/macfontsNow copy these fonts to the Linux machine and extract them into
foo@bar:~$ cp *.ttf ../macfonts
foo@bar:~$ tar zcvf ../macfonts/*.ttf macfonts
either the system font directory or .fonts in
your home directory. As outlined in the previous section, be sure to
run the ttmkfdir tool to create the font
information file, and add the font path to XFree86.