Installing fonts in Linux and Mozilla

Mozilla fonts suck big time. Especially if you visit a page with Trebuchet MS font like I’ve recently started using on mahmood.tv. True to my promise of using Linux exclusively over the next couple of weeks, I thought I’d better do something about the font display on my linux laptop.

In order to do that, I needed to copy the fonts I use for Windows XP Pro to Linux, that started the journey, however I must say that there is a wealth of information in this regard on the net, all you have to do is search for it.

Here are the steps I did to get my fonts over to Linux and how I activated them:

  1. if you don’t have a /usr/share/fonts/TrueType directory, create one
  2. make sure that all the font files you’re copying have lower-case extensions, so if you have files like font.TTF, rename that to font.ttf
  3. copy the fonts to /usr/share/fonts/TrueType
  4. change into that directory: cd /usr/share/fonts/TrueType
  5. issue the following commands to build the necessary fonts.scale and fonts.dir:

    ttmkfdir -o fonts.scale
    mkfontdir

  6. this should have now created the fonts.scale and fonts.dir files
  7. now go to you /etc/X11 directory so that you can add the new font directory to the search path of your X server by adding it to the fonts section of XF86Config
  8. edit XF86Config
    go to the �Files� section and add the FontPath there, mine looks like the following after editing:

    RgbPath “/usr/X11R6/lib/X11/rgb”
    FontPath “unix/:7100”
    FontPath “/usr/share/fonts/TrueType”

  9. Now for the Mozilla part! Go to the directory you installed Mozilla in, mine is located at /usr/local/mozilla. Change into /usr/local/mozilla/defaults/prefs
  10. backup the �unix.js� preference file so that you can get back to it if anything screws up:
  11. cp unix.js unix.js.bak
  12. edit the unix.js file and look for the �TrueType� section and change it to look like the following snippet:

    pref(“font.FreeType2.enable”, true);
    pref(“font.freetype2.shared-library”, “libfreetype.so.6”);
    pref(“font.FreeType2.autohinted”, false);
    pref(“font.FreeType2.unhinted”, false);
    pref(“font.antialias.min”, 8);
    pref(“font.embedded_bitmaps.max”, 1000000);
    pref(“font.scale.tt_bitmap.dark_text.min”, 0);
    pref(“font.scale.tt_bitmap.dark_text.gain”, “0.7”);
    pref(“font.directory.truetype.1”, “/usr/share/fonts/TrueType”);
    pref(“font.directory.truetype.2”, “/usr/X11R6/lib/X11/fonts/TTF”);
    pref(“font.FreeType2.printing”, true);

    Now you’ll enjoy a MUCH clearer veiw of websites you visit!

    I’m still not very happy as the fonts are not kerned properly and look a bit spaced out on my laptop. I’ll have a look at that next and let you know if I get better display.

    For OpenOffice.org, you can simply run the �spadmin� program and add your fonts by pointing to the TrueType directory and �add all�, close the panel and start up OpenOffice and you’ll be happy to see that you now have all the fonts to play with in your documents!

    Version history:
    created: 16 June 2003
    Mahmood Al-Yousif

Comments

  1. mahmood

    Turn OFF TrueType2 for best results

    Since installing Mozilla 1.4rc2, here are the changes I did to the unix.js file. It is [b]MUCH[/b] better by disabling TrueType2, great big difference!

    pref(“font.FreeType2.enable”, false);
    pref(“font.freetype2.shared-library”, “libfreetype.so.6”);
    pref(“font.FreeType2.autohinted”, false);
    pref(“font.FreeType2.unhinted”, true);
    pref(“font.antialias.min”, 9);
    pref(“font.embedded_bitmaps.max”, 1000000);
    pref(“font.scale.tt_bitmap.dark_text.min”, 0);
    pref(“font.scale.tt_bitmap.dark_text.gain”, “0.8”);
    pref(“font.directory.truetype.1”, “/usr/share/fonts/TrueType”);
    pref(“font.directory.truetype.2”, “/usr/X11R6/lib/X11/fonts/TTF”);
    pref(“font.FreeType2.printing”, true);

    [Modified by: Mahmood Al-Yousif (mahmood) on June 18, 2003 07:17 AM]

  2. anonymous

    Awesome!!

    Mahmood, you’re a star! This is exactly what I needed! Thanks for collecting the information in one place for me!

    Leitchy
    biggles@lythia.com

  3. anonymous

    FreeType failed to open, error=0?

    When I launched Mozilla 1.4 after making the changes you suggested i got this error FreeType failed to open, error=0 for fonts.scale and fonts.dir?

    Can you please help me with the error? Thank you.

    Samir

  4. anonymous

    Installing fonts in Linux and Mozilla

    “spadmin” running this program and pointing to the /usr/share/fonts/TrueType/fonts will create a ‘Segmentation fault’ error what could tthis be?

  5. anonymous

    Installing fonts in Linux and Mozilla

    Assalamualaikum Mahmood, i really apreciate your effort.. i really like the tutorial..
    thanks ..

    Abdul Hamid

  6. anonymous

    Installing fonts in Linux and Mozilla

    Thanks very much – very helpful indeed!

    The only thing that threw me for a second was that I needed to do a “whereis” on “ttmkfdir” and “mkfontdir” to find them, since for some reason they aren’t in my path.

    Anyway, running Mozilla Firebird under Gentoo, and your tips worked great! Thanks! 🙂

  7. anonymous

    conver to lowercase

    (in the directory you just copied the *.ttf files) use this perl mini-script to convert the filenames to lowercase:

    find . | perl -ne ‘chomp; next unless -e; $new=lc($_); rename $_,$new’

  8. anonymous

    Installing fonts in Linux and Mozilla

    Thanks, Mahmood – I just installed Mozilla 1.6 and your info helped a lot. What a pain that Mozilla doesn’t ask about or autodetect the TTF path during installation 🙁
    – Kevin Finn (too lazy to make an account)

  9. anonymous

    Installing fonts in Linux and Mozilla

    i’m emah….from m’sia..thanks 4 the tutorial

  10. anonymous

    Installing fonts in Linux and Mozilla

    Just Great. Just That.

    Exactly what I was looking for, right to the point.

  11. anonymous

    Installing fonts in Linux and Mozilla

    i do not have root to my machine
    now how can i install my font

  12. anonymous

    Installing fonts in Linux and Mozilla

    Thanks!

    One note — it looks like your “font.antialias.min” value got turned into a smiley face (red, with sunglasses) by the blogging software.

    Joe
    [url]http://www.joegrossberg.com[/url]

  13. anonymous

    Installing fonts in Linux and Mozilla

    I’m new to Linux, I chnaged all what ever you said. I can not restart the system. Shall I have to restart any services to get the fonts in mozilla?. I’m opening a Tamil language website “http://vikatan.com”. It is not working. – Sasi

  14. anonymous

    Installing fonts in Linux and Mozilla

    Does anybody know or have tried the above mentioned steps for Firefox browser. I tried it for firefox, but it didnot work. Can somebody tell the equivalent of unix.js for firefox..

    Thanks,
    Ejaz

Comments are closed.