Use Windows and Mac Fonts





Use Windows and Mac Fonts

Spruce up your desktop with your favorite 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.

When copying fonts from one operating system to another, bear in mind the legal implications of what you are doing. Fonts that are included with proprietary operating systems are sometimes under specific licensing terms that can restrict their use. Before you copy anything, be sure to read the licensing terms for the fonts.


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 systemsDOS/FAT/NT, File systemsVFAT Support or, if you have an NTFS filesystem, File systemsNTFS file system support (read only).

Before you can access the Windows disk, mount the partition. You can do this manually with the following:

[email protected]:~$ mkdir /mnt/windows
[email protected]:~$ mount -t vfat /dev/hda1 /mnt/windows

Your Windows partition might be located someplace other than /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:

[email protected]:~$ 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  0
/dev/hda1     /mnt/windows     ntfs   ro    0  0

This tells the system that /dev/hda1 is 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:

[email protected]:~$ ttmkfdir

If 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.

Remember to use proper capitalization for your Windows files when accessing them from Linux. For example, the main Windows directory is sometimes spelled with all caps: WINDOWS. So, you might need to change your font paths appropriately.


An alternative method if you are using the XFS font server is to use the chkfontpath command to add the path dynamically:

[email protected]:~$ chkfontpath --add /mnt/windows/Windows/Fonts

If you add the directory using this command, you must restart the font server and restart XFree86. You can do this with the following:

[email protected]:~$ /etc/init.d/xfs restart

Now your fonts should be available.

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:$PATH
MANPATH = /usr/local/man:$MANPATH
export PATH MANPATH

Now log off Mac OS X and then log back on, and check that these variables are set by typing the following:

[email protected]:~$ echo $PATH
[email protected]:~$ echo $MANPATH

To convert the fonts, create a directory in which to perform the conversion:

[email protected]:~$ mkdir ~/fontconv

You 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:

[email protected]:~$ cp /System/Library/Fonts/* ~/fontconv

Now if you go to the fontconv directory, you can perform the conversion with:

[email protected]:~$ 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:

[email protected]:~$ mkdir ~/macfonts
[email protected]:~$ cp *.ttf ../macfonts
[email protected]:~$ tar zcvf ../macfonts/*.ttf macfonts

Now copy these fonts to the Linux machine and extract them into 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.


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows