Sunday, November 27, 2005

Adding Windows fonts in Linux

Unlike past times, Linux do come with good fonts. And the font rendering can be made better by choosing to antialiase the fonts. But at times you come across a website which has been designed with the windows user in mind. Such websites are best viewed with one of the windows fonts. If you have windows OS installed on your machine, you can copy the essential fonts from the windows partition to linux and use them to get a better web experience. Here is how you do it.
Method I :
Copy the ttf (True Type Fonts) fonts Ariel, Tahoma, Verdana, Courier New and Times New Roman from the windows partition to the fonts:// location in nautilus.

Method 2 :
Some people who are using Ubuntu have said that they can't do it as normal user. And since Ubuntu does not have a root account, they find difficulty in using su to copy eaither. Such people can do the following:
Create a '.fonts' folder in your home directory and copy the necessary fonts into it. Now you have access to the fonts on a per user basis.

Method 3:
This method can be used to install the fonts system wide if the above two methods do not give satisfactory results.
First find out in which location linux has installed the truetype fonts. It is usually at the location '/usr/share/fonts/truetype/' . But you may also do a search for the same as follows:
# find /usr -iname \*.ttf |head -n 5
Once you know the path of the fonts directory, move to this directory and create a folder there (it can be any name).
# cd /usr/share/fonts/truetype
# mkdir windowsfonts
Note: You need to be logged in as root while doing this.
Next copy all the windows ttf fonts to the windowsfonts directory that was just created.
# cp /media/hda1/windows/Fonts/*.ttf .
Now change the ownership of the fonts as well as make sure they have a right of 644 .
# chown root.root *.ttf
# chmod 644 *.ttf
Now run the command mkfontdir while in the windowsfonts directory.
# mkfontdir
This will create an index of the fonts in the directory. It will also create two files fonts.dir and fonts.cache-1 .
Now moving to the parent directory, edit the file fonts.cache-1 using your favourate editor and append the following line to it.
#File: /usr/share/fonts/truetype/fonts.cache-1
...
"windowsfonts" 0 ".dir"
Lastly run the command fc-cache.
# fc-cache
This command will scan the font directories on the system and build font information cache files for applications using fontconfig for their font handling.

That's it. Now you can have access to windows fonts in all your X applications including firefox and OpenOffice.org.

No comments: