TrueType fonts in X4

2000-11-12 Thread Brad
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 [EMAIL PROTECTED]; }'

 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.


pgpKDy9UEYNzT.pgp
Description: PGP signature


Re: TrueType fonts in X4

2000-11-12 Thread John S. J. Anderson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Brad [EMAIL PROTECTED] writes:

 There seems to be much confusion on how to get TrueType fonts working
 with the new X4 packages. 

Thanks for the clear instructions. I sorta had TrueType stuff working,
but I think I've got stuff totally sorted now.

One wibble, however:

 4. Sorting fonts.scale properly (more or less)
[snip]
 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 [EMAIL PROTECTED]; }'

You've got a couple typos on that last line; I rewrote it like so:

perl -e 'open X , fonts.scale or die; $n = X;
while(X) { /^(\S+\.ttf)/; unshift @{$h{$1}} , $_; }
open O , fonts.scale or die; 
print O $n; print O @{$h{$_}} foreach ( sort keys %h )'

but then this isn't golf. 8^)=  The important thing is to remove the 3
'%' from the final line.

Oh, and one more thing -- instead of saying:

  Download mkfontalias.py from Kristin's site

why not give the URL? URL:http://home.c2i.net/dark/mkfontalias.py

Thanks again for the good work, Brad.

john.

- -- 
- 
   [ John S Jacobs Anderson ]--URL:mailto:[EMAIL PROTECTED]
[ Genehack: Not your daddy's weblog ]--URL:http://genehack.org
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Mailcrypt 3.5.5 and Gnu Privacy Guard

iD8DBQE6D1cIWRJRdOm3KFARAspEAKCX0Wm0//oEDXx03zuPLCI3k2TcSACfaRSw
U7R+ro3hf3r145wVKP+kZi8=
=eH5t
-END PGP SIGNATURE-



Re: TrueType fonts in X4

2000-11-12 Thread Brad
On Sun, Nov 12, 2000 at 09:50:48PM -0500, John S. J. Anderson wrote:
for $x (sort keys %h){ %print %X [EMAIL PROTECTED]; }'
 
 You've got a couple typos on that last line; I rewrote it like so:

i don't know where they came from, apparently something went wrong with
the copy-paste. Thanks for the correction.

Anyway, as you've already discovered, that line should be:
   for $x (sort keys %h){ print X @{$h{$x}}; }'

   Download mkfontalias.py from Kristin's site
 
 why not give the URL? URL:http://home.c2i.net/dark/mkfontalias.py

It seems less polite to skip the page explaining how to use it and
everything, and just take advantage of the script.


-- 
  finger for GPG public key.


pgp2LgANbdRe0.pgp
Description: PGP signature