Fonts

From ArchWiki
Revision as of 08:34, 11 November 2008 by Firmicus (Talk | contribs) (Font Packages in Arch Linux)

Jump to: navigation, search

Template:Article summary start Template:Article summary text Template:Article summary heading Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry} Template:Article summary heading Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Merge-arrows-2.pngThis article or section is a candidate for merging with Xorg Font Configuration.Merge-arrows-2.png

Notes: Talk:Xorg Font Configuration (Discuss in Talk:Fonts#)

Introduction

A standard Arch Linux desktop installation provides an excellent font support, with the latest stable versions of the X.org X server, freetype2 (with bytecode interpreter enabled) and fontconfig. For more information on font configuration please see: Font Configuration

Different Kinds of Fonts

There exists different kinds of fonts for Linux.

  • bitmap fonts (.pcf .bdf .pcf.gz .bdf.gz)
  • PostScript fonts (.pfa .pfb)
    (pfa: ascii format; pfb: binary format)
  • TrueType/OpenType fonts (.ttf)
    (OpenType fonts with quadratic outlines have also .ttf suffix)
  • PostScript flavored OpenType fonts (.otf)
  • TeX bitmap fonts (.pk)
    (usually automatically generated from the METAFONT source .mf)
  • TeX virtual fonts (.vf)

Installing fonts

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

Adding fonts in a modern Linux system is much easier than before. Here I try to post a few tips aiming to make it more understandable to average users. Usually, you should add fonts under the following directory:

  • /usr/share/fonts
  • /usr/X11R6/lib/X11/fonts

This will make everybody on the system to be able to use them, however; it requires root privileges. Copying them into:

  • ~/.fonts

directory is a good idea too.

Some font collections have been prepackaged for use in Arch Linux; search them by:

pacman -Ss fonts

Among the packages available you will see

extra/artwiz-fonts 1.3-1
    This is set of (improved) artwiz fonts.
extra/ttf-ms-fonts 1.3-6
    Un-extracted TTF fonts from Microsoft

Then if you want to install these two packages, do:

pacman -S artwiz-fonts ttf-ms-fonts

This will install the fonts into /usr/X11R6/lib/X11/fonts dir. CJK (Chinese/Japanese/Korean) users are encouraged to install also ttf-arphic-uming, ttf-arphic-ukai and ttf-fireflysung to display Asian characters properly.

Another option is to use KDE Font Installer in the KDE Control Center. This seems to work flawlessly if you use KDE.

You can also manually copy fonts into above three directories, but don't forget to run as root:
fc-cache -vf

This should work in X Window with GNOME, KDE or XFCE4 desktop environments for most applications. However, some GTK1 or old applications don't support fontconfig. (Really? Someone should check this and then fix it) You have to run the following commands in your fonts directory (in the terminal of course):

  mkfontscale
  mkfontdir
  ln -s /usr/share/fonts/encodings/encodings.dir yourfontdirectory/encodings.dir

ex: if you-re using KDE

   ln -s /usr/share/fonts/encodings/encodings.dir ~/.fonts/

then usually you need to restart X.

If you want to share such fonts or avoid repeating the above manual steps, you can make an Arch package. Save the fonts you wish to install as tar.bz2 and use a variation of the following PKGBUILD and .install to install them via ABS:

# PKGBUILD
  pkgname=fonts-extra
  pkgver=1.0
  pkgrel=1
  depends=('xfree86')
  pkgdesc=\"Fonts extra\"
  source=(fonts-extra.tar.bz2)
  install=fonts-extra.install
  build()        {
    mkdir -p $startdir/pkg/usr/X11R6/lib/X11/fonts/local
    mv $startdir/src/*.ttf $startdir/pkg/usr/X11R6/lib/X11/fonts/local
  }
# fonts-extra.install:
  # arg 1:  the new package version
  post_install() {
    echo -n \"updating font cache... \"
    /usr/bin/fc-cache
    cd /usr/X11R6/lib/X11/fonts/local
    /usr/X11R6/bin/mkfontscale
    /usr/X11R6/bin/mkfontdir
    ln -s /usr/X11R6/lib/X11/fonts/encodings/encodings.dir /usr/X11R6/lib/X11/fonts/local/encodings.dir
    echo \"done.\"
  }

  # arg 1:  the new package version
  # arg 2:  the old package version
  post_upgrade() {
    post_install $1
  }

  # arg 1:  the old package version
  pre_remove() {
    /bin/true
  }

  op=$1
  shift

  $op $*

Font Packages in Arch Linux

NB: This is a selective list, but it does also include most font packages from AUR.

  • Hebrew
    • culmus - nice collection of free Hebrew fonts
  • Thai
    • ttf-thai - font covering glyphs for thai
  • Khmer
    • ttf-khmer - font covering glyphs for khmer language
  • Braille
    • ttf-ubraille - font containing symbols for braille (unicode)
  • “Programmer's fonts” (for coding and terminal display)

Best fonts for terminal

The best font for a terminal depends on what terminal emulator you are using and what features it supports. For example, it even depends on how your fonts.dir looks, as sometimes fonts get installed incorrectly. It also depends on how you have configured your X Server, if you use freetype2 or freetype1, if you use the autohinter with the bytecode interpreter compiled into freetypeN, if you have compiled in the BI but doesn't use the autohinter, if you have not compiled in the BI and use the autohinter, if you have not compiled in the BI but uses the autohinter, etc.

A top favorite of some Arch Linux users is Terminus (in community as "terminus-font").

Some other fonts to try out:

  • Lucida Typewriter
  • Andale Mono
  • Bitstream Vera Mono
  • Courier
  • Terminal
  • Test
  • Gamov
  • default8x16
  • monospace
  • Liberation Mono
  • Proggy Clean

Example how to use Terminus:

xterm -bg black -fg gray -fn -xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-1
xterm -bg black -fg gray -fn -xos4-terminus-bold-r-normal--14-140-72-72-c-80-iso8859-1

Fonts in virtual console

Default font in virtual console can display only ASCII characters. If you use other characters you can change the CONSOLEFONT and CONSOLEMAP settings in your /etc/rc.conf file. Different fonts can be found in /usr/share/kbd/consolefonts directory and key maps can be found in the subdirectories of /usr/share/kbd/keymaps.

Examples

For displaying characters like "č ć ž đ š" use lat2-16.psfu.gz font:

CONSOLEFONT="lat2-16.psfu.gz"

Also, don't forget to set the proper key map, in this case:

CONSOLEMAP="8859-2"

To use the specified font in early userspace (early in the bootup process), add the 'keymap' hook to /etc/mkinitcpio.conf and rebuild the image. See the Mkinitcpio article for more information.

Fonts with LCD filter enabled

"LCD" packages

Install patched packages

Remove the original packages:

pacman -Rd libxft cairo

Install the patched packages from AUR unsupported (ex. using yaourt):

yaourt -S fontconfig-lcd
yaourt -S cairo-lcd

Install the patched packages from [community]:

pacman -S libxft-lcd

Reboot your system.

Note: if you want, you can simply revert to the original packages entering

pacman -Rd libxft-lcd cairo-lcd fontconfig-lcd
pacman -S libxft cairo

Change filter configuration

The "fontconfig-lcd" package enables by default the "lcddefault" filter. You can edit the /etc/fonts/conf.avail/10-lcd-filter.conf file and replace it with another filter.

  • New filter, fontconfig-lcd default
 <const>lcddefault</const>
  • None
 <const>lcdnone</const>
  • Lighter filter, less aggressive
 <const>lcdlight</const>
  • Legacy filter, cairo default
 <const>lcdlegacy</const>

Alternative with "ClearType" packages

There are more effects for fonts from Windows system, this method of beautifying fonts has been tested with GNOME/Xfce/KDE.

Remove Packages:

pacman -Rd cairo libxft freetype2

Install Packages

Install the package cairo-cleartype, libxft-cleartype, freetype2-cleartype from AUR

Search "cairo-cleartype", "libxft-cleartype", "freetype2-cleartype" in AUR, download all these tarballs, extract them, and compile them with makepkg, install them with

pacman -U *-cleartype*.pkg.tar.gz

Restart X11 (ctrl+alt+backspace)

OR if you have yaourt installed:

yaourt -S cairo-cleartype freetype2-cleartype libxft-cleartype

Configuration

FreeType autohinter (optional)

You can set the FreeType autohinter. As root :

ln -s /etc/fonts/conf.avail/10-autohint.conf /etc/fonts/conf.d/10-autohint.conf

Disable Unattractive Bitmap Fonts (optional)

Edit ~/.fonts.conf with the following content:

   <selectfont>
       <rejectfont>
           <pattern>
               <patelt name="scalable">
                   <bool>false</bool>
               </patelt>
           </pattern>
       </rejectfont>
   </selectfont>

Restart X11 (ctrl+alt+backspace)

At this point if you think fonts look too bold, modify the fonts configuration file: edit (or create if it doesn't exist yet) the file ~/.fonts.conf with the following content:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font" >
<test compare="more" name="weight">
<const>medium</const>
</test>
<edit mode="assign" name="autohint">
<bool>false</bool>
</edit>
</match>
</fontconfig>

FAQ

Q. My fonts are too large or too small. The resolution seems wrong. My fonts are mis-shapen.

A(1). Read the Display Size/DPI section of Xorg for configuration sample settings and formula.

A(2). Get your proper resolution from a console, by typing:

xdpyinfo | grep resolution

Change the value to this in the Gnome font configurator. Restart X. Sometimes, the videocard gives bogus information to X. It may be better to settle on a value between 72-78 DPI for 1024x768 displays. 96 DPI is a good value for 1280x1024, but it depends on the exact resolution. I actually prefer 75 on my home machine, and the font sizes seem to be a bit more true to their proper sizes when this is set. In most cases, if the numbers don't match, you may use the following method.

You may also opt to force X to start with a forced resolution. This may produce good results in some display modes. For example, you may use:

startx -- -dpi 75

This will force X to start in 75x75 DPI mode. You may change your Gnome font settings (From the menu: Applications/Desktop Preferences/Font) to 75 DPI and you should get a good match.

If this worked well for you, you may edit your "startx" script to always force this option on startup. Edit the file "/usr/bin/startx" as root.

Change the following line:

defaultserverargs=""

to...

defaultserverargs="-dpi 75"

Q. How do I install fonts?

A. An easy way to install fonts is to drop them into your "$HOME/.fonts" directory and running "fc-cache". You can also perform a system-wide font installation by copying the fonts to "/usr/share/fonts" or another font directory (as long as it is listed in your "/etc/fonts/fonts.conf" file), and then performing the "fc-cache" command as root. You may also need to run "ttmkfdir" or "mkfontdir" as well.

Q. The fonts in GNU Emacs are displayed as squares.

A. You need to install the xorg-fonts-75dpi or xorg-fonts-100dpi package.

Q. The fonts in OpenOffice.org look very bad.

A. If we have a bug/font-issue in the openoffice-base package, using the original rpm-packages from the office website will allways work. "Bad fonts are a thing of the past with the newest version (2.3.1)." (http://www.stchman.com/tweaks.html).

Note that OpenOffice.org for Linux ships with an (inferior) copy of freetype2 that are built directly into the code. In the past you could force it to link to your system's, shared, freetype2 by setting the following before starting the suit.

export LD_PRELOAD=/usr/lib/xorg/modules/fonts/libfreetype.so

The (Jan 2008) above is reported to not work anymore but at qa.openoffice.org a patch to do this bypass is emering.

Q. The OpenOffice.org menu font looks really bad. It doesn't use antialiasing either.

A. This can be changed in the OpenOffice.org configurator. From the drop-down menu, select "Tools/Options/OpenOffice.org/Fonts". Check the box that says "Apply Replacement Table". Type "Andale Sans UI" in the font box (this may have to be input manually, if it doesn't appear in the drop-down menu) and choose your desired font for the "Replace With" option. Dropline users may prefer the system default, "Trebuchet MS". When selected, click the checkmark box. Then choose the "always" and "screen" options in the box below. Apply the changes, and your menu fonts should look great.

Q. OpenOffice.org doesn't detect my TrueType fonts!

A. Make sure that you add the appropriate entry in your /etc/X11/xorg.conf file that points your programs to the /usr/share/fonts/ directory.

For example, here's a sample of an xorg.conf file

Section "Files"
    RgbPath         "/usr/share/X11/rgb"
    ModulePath      "/usr/lib/xorg/modules"
    FontPath        "/usr/share/fonts/misc"
    FontPath        "/usr/share/fonts/75dpi"
    FontPath        "/usr/share/fonts/100dpi"
    FontPath        "/usr/share/fonts/TTF"
    FontPath        "/usr/share/fonts/Type1"
EndSection

Another solution is to run the openoffice administration tool

# /opt/openoffice/program/spadmin

from which you can add fonts.

Q. Mozilla and other programs can no longer access TrueType fonts on my system, and are reverting to ugly fonts instead.

A. Make sure the "freetype" module is loaded in your /etc/X11/xorg.conf file and your /usr/share/fonts/TTF/fonts.dir lists all of the TrueType fonts you have installed.

Try checking your "Files" section of your xorg.conf, and make sure that you have all (or most) of these directories listed.

Section "Files"
    RgbPath         "/usr/share/X11/rgb"
    ModulePath      "/usr/lib/xorg/modules"
    FontPath        "/usr/share/fonts/misc"
    FontPath        "/usr/share/fonts/75dpi"
    FontPath        "/usr/share/fonts/100dpi"
    FontPath        "/usr/share/fonts/TTF"
    FontPath        "/usr/share/fonts/Type1"
EndSection

Finally, go to the following font directories:

/usr/share/fonts/TTF
/usr/share/fonts

Try deleting the "fonts.dir" and "fonts.scale" files in these directories. You may want to make backups first though. Run these commands to replace them.

mkfontscale
mkfontdir

Make sure you restart X for the changes to come into effect.

Q. What are some suggested font settings for Mozilla/Firefox?

A. These are recommended for Firefox:

Proportional: Serif   Size (pixels): 16
Serif: Times New Roman
Sans-serif: Arial
Monospace: Courier New   Size (pixels): 13
Display resolution: System settings
  • Note: Times New Roman may appear to be a non-TTF font. If this is the case, read above about how to fix this.

I believe that the following are Dropline's Mozilla defaults (also recommended):

Proportional: Serif   Size (pixels): 14
Serif: Times New Roman
Sans-serif: Verdana
Cursive: Andale Mono
Fantasy: Andale Mono
Monospace: Courier New   Size (pixels): 11
Allow Documents to use other fonts: Enabled
Display resolution: System settings

Q. Why do my Apps show squares when there should be arrows and the like?

A. It may help to activate bitmap fonts. They are disabled by default.

cd /etc/fonts/conf.d
rm 10-bitmaps.conf
ln -s yes-bitmaps.conf 10-bitmaps.conf
cd -

If you think your fonts look ugly now then consider to remove the following packages.

pacman -Rs xorg-fonts-100dpi xorg-fonts-75dpi

Read here and here for some background info.

Q: I just upgraded via pacman -Syu and my fonts are all ugly

A: There are several possible conflicting issues here. See these threads:

1 - http://bbs.archlinux.org/viewtopic.php?t=866

2 - http://bbs.archlinux.org/viewtopic.php?t=4975