How to install fonts in Linux

This tutorial describes how to install TrueType fonts on Debian GNU/Linux 4.0 (etch). In other Linux distributions like Redhat/Fedora or SuSE it works in a similar way.
Before you begin you should verify that the programs "ttmkfdir" und "mkfontdir" are installed. An X-windows system is also necessary.
If not get them with "apt-get install ttmkfdir"
You will need fontconfig as well ("apt-get install fontconfig").

In Linux fonts are often stored in /usr/share/fonts or /usr/X11R6/lib/X11/fonts.
If /usr/share/fonts is your main font directory, the TrueType fonts for X would go into /usr/share/fonts/truetype.

It is possible, though not recommended, to store fonts anywhere in the system.

When you want to use Microsofts TrueType fonts on your Linux box, you can install the package "msttcorefonts". The non-free repository has to be enabled in /etc/apt/sources.list. Just enter "apt-get install msttcorefonts" to install and configure the fonts automatically.

Manuell installation of fonts will be descibed below:

Unpack your TrueType fonts and copy them to /usr/local/fonts/ttf.
Then "cd" to /usr/local/fonts/ttf and create the fonts.scale and fonts.dir files with "ttmkfdir -o fonts.scale" and "mkfontdir".

Now you have to tell the program "fontconfig", that is used by many modern Linux applications, where to look for the newly installed fonts. Create a new file "/etc/fonts/local.conf" and append the following lines to it:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/local/fonts/ttf</dir>

</fontconfig>

Call "fc-list" to check if the new fonts were recognized by the system.
If this ist the case all applications that are capable of handling TrueType fonts can use the new fonts from now on.

How to use TrueType fonts under Linux:

Under Linux TrueType fonts can be used in all applications which support them. OpenOffice ist only one of them.
A nice possibility is, to useTrueType fonts from within scripts that run on a webserver, in order to dynamically create logos on the fly.

Code example in PHP:


<?php

header ("Content-type: image/jpeg");
$im = @ImageCreate (400,200) or die ("no GD-Image-Stream available");
$bg_color = ImageColorAllocate ($im, 200, 200, 200);
$txt_color = ImageColorAllocate ($im, 255,255,0);
imagettftext($im,
    40,
    15,
    25,
    175,
    $txt_color,"/usr/share/fonts/msfonts/HeNB.TTF",
    $_SERVER["HTTP_HOST"]);

imagejpeg ($im);
imagedestroy($im);

?>





created with myCMS | featuring Amazon Interface and Online-Marketing

All named names, trademarks and Logos are property of their owners.
All trademarks, copyrights and other signs are acknowledged.

fix