[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

TrueType fonts in X4



There seems to be much confusion on how to get TrueType fonts working
with the new X4 packages. So i'll try to write up some clear directions.
Many thanks to the authors of the XFree86 Font Deuglification Mini HOWTO
(http://www.linuxdoc.org/HOWTO/mini/FDU/), and Kristin Aanestad
(http://home.c2i.net/dark/linux.html#ttf).


1. Get the fonts

 I guess Windos is good for something after all. At the least, you might
 as well get the Microsoft web fonts, since so many (broken) webpages
 use them. You don't even have to run their installer, the downloadables
 can be opened with a semi-recent version of WinZip (unfortunately,
 Debian's unzip doesn't like the Win32 packages).

 The FDU and Kristin's site both list other resources for obtaining
 fonts.


2. Name the fonts properly

 ttmkfdir doesn't like it if the fonts aren't named all in lowercase.
 So, copy them to a case-sensitive filesystem and rename them all. If
 you have mmv installed, it's simple:
   mmv '*.[Tt][Tt][Ff]' '#l1.ttf'

 If you prefer rename:
   rename 'y/A-Z/a-z/ if /\.ttf$/i' *

 Note that, since FAT/FAT32 are case insensitive, this won't work on
 those filesystems!


3. Create the fonts.scale file

 fonts.scale is for listing scalable fonts that mkfontdir won't
 recognize or won't name properly, because scalable fonts tend not to
 contain the X font name. To create this file, you'll need ttmkfdir
 (http://freshmeat.net/projects/ttmkfdir). mkttfdir from the fttools
 package will work, but it currently won't recognize symbol fonts or any
 other font not encoded in iso8859-1, jisx0201.1976-0, or
 jisx0208.1983-0.

 3.1 Compiling ttmkfdir

  You'll need the freetype2 and freetype2-dev packages installed, as
  well as the standard C compilation tools. You'll also have to edit the
  provided Makefile to change these variables to the given values:
    FREETYPE_BASE=/usr/include/freetype
    FREETYPE_INCL=$(FREETYPE_BASE)
    FREETYPE_LIB=-L/usr/lib -lttf

 3.2 Running ttmkfdir

  cd to the directory with your TrueType fonts, and run this command (of
  course, use your actual path):
    /path/to/ttmkfdir -o fonts.scale


4. Sorting fonts.scale properly (more or less)

 ttmkfdir currently puts the fonts in a somewhat backwards order. So,
 we'll run a perl script over things to put it right.

    perl -we 'open X, "<fonts.scale" or die;
              %h=(); $n=<X>;
	      while(<X>){
	      /^(\S+\.ttf)/; unshift @{$h{$1}}, $_;
	      }
	      open X, ">fonts.scale" or die;
	      print X $n;
	      for $x (sort keys %h){ %print %X %@{$h{$x}}; }'

 This basically puts the fonts in alphabetical order by filename, and
 reverses the order of the encodings, since most people would rather
 have iso8859-1 first instead of last.


5. Make fonts.dir

 Since we have fonts.scale, this is easy:
   mkfontdir


6. Make fonts.alias

 Some applications (notably Netscape) will only give you one size option
 for the TrueType fonts, which somewhat defeats the purpose. Download
 mkfontalias.py from Kristin's site and run it. If you'd like to
 eliminate all except iso8859-1 encoding, you can then run this command
 over the new fonts.alias file:
   perl -i -nwe '/iso8859-1\D/ and print' fonts.alias


7. Add the path

 7.1 /etc/X11/XF86Config-4

  Add a FontPath line for the new directory, and either restart X or use
  xset to adjust the font path for the current session.

 7.2 /etc/X11/fs/config

  Add the path to the catalogue line, and run "/etc/init.d/xfs reload"
  to make the changes take effect.


8. Miscellaneous

 Note that the TrueType fonts will show up under the foundry listed by
 the font, or "misc" if ttmkfdir can't determine. This may represent a
 change, since some xfstt implementations had reported all TrueTypes as
 being in the 'ttf' foundry.


HTH


-- 
  finger for GPG public key.

Attachment: pgpL3nA0D42lZ.pgp
Description: PGP signature


Reply to: