Difference between revisions of "Fonts"

From ArchWiki
Jump to: navigation, search
(Fonts with Xorg: fix dir)
(Indic: Add mention that this font contains a look of disapproval)
Line 218: Line 218:
 
*{{Pkg|ttf-freebanglafont}} - Font for Bangla
 
*{{Pkg|ttf-freebanglafont}} - Font for Bangla
 
*{{Pkg|ttf-indic-otf}} - Indic OpenType Fonts collection (containing ttf-freebanglafont)
 
*{{Pkg|ttf-indic-otf}} - Indic OpenType Fonts collection (containing ttf-freebanglafont)
 +
:(This one contains a ಠ_ಠ "look of disapproval" that might be more to your liking than the {{Pkg|bdf-unifont}} one mentioned elsewhere in this document)
  
 
====Khmer====
 
====Khmer====

Revision as of 18:01, 8 February 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Fonts#)
Summary help replacing me
Covers the selection and installation of fonts on Arch Linux
Legal
Certain font licenses may impose some legal limitations
Related
Font Configuration: Font setup and beautification
Java Runtime Environment Fonts: Fonts specific to Sun's Java machine
MS Fonts: Adding Microsoft fonts and mimicking Windows' font settings

Font formats

Most computer fonts used today are in either bitmap or outline data formats. Bitmap fonts store fixed images for each glyph in each typeface and point size. Outline or vector fonts store characters as instructions for drawing each glyph's lines and curves. Outline fonts scale smoothly in size over a wide range.

Common font filename extensions include:

  • bdf and bdf.gz – bitmap fonts, bitmap distribution format and gzip compressed bdf
  • pcf and pcf.gz – bitmaps, portable compiled font and gzip compressed pcf
  • psf, psfu, psf.gz and psfu.gz – bitmaps, PC screen font, PC screen font Unicode and the gzipped versions (not compatible with Xorg)
  • pfa and pfb – outline fonts, PostScript font ASCII and PostScript font binary. PostScript fonts carry built-in printer instructions.
  • ttf – outline, TrueType font. Originally designed as a replacement for the PostScript fonts.
  • otf – outline, OpenType font. TrueType with PostScript typographic instructions.

For most purposes, the technical differences between TrueType and OpenType can be ignored, some fonts with a ttf extension are actually OpenType fonts.

Other formats

The typesetting application, TeX, and its companion font software, Metafont, render characters using their own methods. Some of the file extensions used for fonts by these two programs are *pk, *gf, mf and vf.

FontForge, a font editing application, can store fonts in its native text-based format, sfd, spline font database.

Installation

Various methods of installing fonts.

Pacman

Fonts and font collections in the enabled repositories can be installed using pacman. Available fonts may be found by using:

$ pacman -Ss font

Or to search for ttf fonts only:

$ pacman -Ss ttf

Some fonts like terminus are installed in /usr/share/fonts/local, which is not added to the font path by default. By adding the following lines to ~/.xinitrc

xset +fp /usr/share/fonts/local
xset fp rehash

the fonts can be used in X11.

Creating a package

If you want to give pacman the ability to manage your fonts, you can create an Arch package. These can also be shared with the community in the AUR. Here is an example of how to create a basic package. To learn more about building packages, read PKGBUILD.

pkgname=ttf-fontname
pkgver=1.0
pkgrel=1
depends=('fontconfig' 'xorg-font-utils')
pkgdesc="custom fonts"
arch=('any')
source=(http://someurl.org/$pkgname.tar.bz2)
install=$pkgname.install

build()
{
  mkdir -p $pkgdir/usr/share/fonts/TTF
  cp $srcdir/$pkgname/*.ttf $pkgdir/usr/share/fonts/TTF
}

This PKGBUILD assumes the fonts are TrueType. An install file (ttf-fontname.install) will also need to be created to update the font cache:

post_install() {
  echo -n "Updating font cache... "
  fc-cache -fs >/dev/null
  mkfontscale /usr/share/fonts/TTF /usr/share/fonts/Type1
  mkfontdir /usr/share/fonts/TTF /usr/share/fonts/Type1
  echo "done"
}

post_upgrade() {
  post_install
}

Manual installation

The recommended way of adding fonts to your system that are not in the repositories is described in #Creating a package. This gives pacman the ability to be able to remove or update them at a later time. Fonts can alternately be installed manually as well.

To install fonts system-wide (available for all users), move the folder to the /usr/share/fonts/ directory. To install fonts for only a single user, use ~/.fonts/ instead.

Also you may need to update /etc/X11/xorg.conf or /etc/xorg.conf with the new directory. Search for FontPath to find the correct location within the file to add your new path. See #Fonts with Xorg for more detail.

Then update the fontconfig font cache:

$ fc-cache -vf

Older applications

With older applications that do not support fontconfig (e.g. GTK1 applications, and xfontsel) the index will need to be created in the font directory:

$ mkfontscale
$ mkfontdir

Or to include more than one folder with one command:

$ for dir in /font/dir1/ /font/dir2/; do xset +fp $dir; done && xset fp rehash

At times the X server may fail to load the fonts directory and you will need to rescan all the fonts.dir files:

# xset +fp /usr/share/fonts/misc # Inform the X server of new directories
# xset fp rehash                # Forces a new rescan

To check that the font(s) is included:

$ xlsfonts | grep fontname

Pango Warnings

When Pango is in use on your system it will read from fontconfig to sort out where to source fonts.

(process:5741): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='common'
(process:5741): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type='PangoRenderFc', script='latin'

If you are seeing errors similar to this and/or seeing blocks instead of characters in your application then you need to add fonts and update the font cache. This example uses the ttf-liberation fonts to illustrate the solution and runs as root to enable them system-wide.

# pacman -S ttf-liberation
  -- output abbreviated, assumes installation succeeded -- 

# fc-cache -vfs
/usr/share/fonts: caching, new cache contents: 0 fonts, 3 dirs
/usr/share/fonts/TTF: caching, new cache contents: 16 fonts, 0 dirs
/usr/share/fonts/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/util: caching, new cache contents: 0 fonts, 0 dirs
/var/cache/fontconfig: cleaning cache directory   
fc-cache: succeeded

You can test for a default font being set like so:

# fc-match
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"

Fonts with Xorg

In order for Xorg to find and use your newly installed fonts, you must add the font paths to /etc/X11/xorg.conf (another Xorg configuration file may work too).

Here is an example of the section that must be added to /etc/X11/xorg.conf. Add or remove paths based on your particular font requirements.

# Let Xorg know about the custom font directories
Section "Files"
    FontPath    "/usr/share/fonts/100dpi"
    FontPath    "/usr/share/fonts/75dpi"
    FontPath    "/usr/share/fonts/cantarell"
    FontPath    "/usr/share/fonts/cyrillic"
    FontPath    "/usr/share/fonts/encodings"
    FontPath    "/usr/share/fonts/local"
    FontPath    "/usr/share/fonts/misc"
    FontPath    "/usr/share/fonts/OTF"
    FontPath    "/usr/share/fonts/TTF"
    FontPath    "/usr/share/fonts/util"
EndSection

Font packages

This is a selective list that includes many font packages from the AUR along with those in the official repositories. Fonts are tagged "Unicode" if they have wide Unicode support, see the project or Wikipedia pages for detail.

Braille

International users

Arabic

Chinese, Japanese, Korean, Vietnamese

(Mainly) Chinese
  • wqy-microheiAUR - A Sans-Serif style high quality CJK outline font. (AUR)
  • wqy-zenhei - Hei Ti Style (sans-serif) Chinese Outline font embedded with bitmapped Song Ti (also supporting Japanese (partial) and Korean characters).
  • ttf-arphic-ukai - Kaiti (brush stroke) Unicode font (enabling anti-aliasing is suggested)
  • ttf-arphic-uming - Mingti (printed) Unicode font
  • opendesktop-fonts - New Sung font, previously is ttf-fireflysung package
  • wqy-bitmapfont - Bitmapped Song Ti (serif) Chinese font
  • ttf-hannom - Chinese and Vietnamese TrueType font
Japanese
  • ttf-sazanami - Japanese free TrueType font to alternate with the ttf-kochi font family.
  • ttf-kochi-substituteAUR - High quality Japanese TrueType fonts. It has bitmap hinting information, so it's beautiful and not jagged to display on the CRT.
  • otf-ipafontAUR - Japanese Gothic (san-serif) and Mincho (serif) font set; one of the highest quality open source fonts. Default of openSUSE-ja. (AUR)
  • ttf-vlgothicAUR - Japanese Gothic fonts. Default of Debian/Fedora/Vine Linux (AUR)
  • ttf-ipa-monaAUR, ttf-monapoAUR - Japanese fonts to show 2channel Shift JIS art properly. (AUR)
Korean
  • ttf-baekmuk - Collection of Korean TrueType fonts
  • ttf-aleeAUR - Set of free Hangul TrueType fonts (AUR)
  • ttf-unfonts-coreAUR - Un fonts (default Baekmuk fonts may be unsatisfactory) (AUR)

Cyrillic

Also see #Monospace, #Sans and #Serif

Greek

Almost all Unicode fonts contain the Greek character set (polytonic included). Some additional font packages, which might not be contain the complete Unicode set but utilize high quality Greek (and Latin, of course) typefaces are:

  • otf-gfsAUR - Selection of OpenType fonts from the Greek Font Society (AUR)
  • ttf-mgopenAUR - Professional TrueType fonts from Magenta (AUR)

Hebrew

  • culmusAUR - Nice collection of free Hebrew fonts

Indic

(This one contains a ಠ_ಠ "look of disapproval" that might be more to your liking than the bdf-unifont one mentioned elsewhere in this document)

Khmer

Sinhala

Tamil

Thai

  • ttf-thai - Font covering glyphs for Thai

Math

Microsoft fonts

See MS Fonts.

Monospaced

Here are some suggestions. Every user has their own preference, experiment to find one that suits you. If you won't like to try one by one, there's an opinion from Dan Benjamin on his blog: Top 10 Programming Fonts.

Here's a big list of fonts by Trevor Lowing: http://www.lowing.org/fonts/

TrueType

Bitmap

Sans-serif

Script

Serif

Unsorted

Console fonts

The console, meaning a terminal running with no X Window System, uses the ASCII character set as the default. This font and the keymap used are easily changed.

A console font is limited to either 256 or 512 characters. The fonts are found in /usr/share/kbd/consolefonts/.

Keymaps, the connection between the key pressed and the character used by the computer, are found in the subdirectories of /usr/share/kbd/keymaps/.

Previewing and testing

Unfortunately, no organized library of images is available to preview console fonts. The user can, however, use setfont to temporarily change the font and be able to consider its use as the default. The available glyphs or letters in the font can also be viewed as a table with the command showconsolefont.

If the newly changed font is not suitable, a return to the default font is done by issuing the command setfont without any arguments. If the console display is totally unreadable, this command will still work—the user just types in setfont while "working blind."

Note that setfont only works on the console currently being used. Any other consoles, active or inactive, remain unaffected.

Examples

Change the font. This example is distinctive:

$ setfont /usr/share/kbd/consolefonts/gr737b-9x16-medieval.psfu.gz

Or change the font to one with 512 glyphs and set the keymap to ISO 8859-5 using the -m option:

$ setfont /usr/share/kbd/consolefonts/LatArCyrHeb-16.psfu.gz -m 8859-5

Then issue commands that send text to the display, perhaps view a manpage and try vi or nano, and view the table of glyphs with the command, showconsolefont.

Return to the default font with:

$ setfont

Changing the default font

To change the default font, the CONSOLEFONT= and CONSOLEMAP= settings in /etc/rc.conf must be altered. Again, the fonts can be found in /usr/share/kbd/consolefonts/ directory and keymaps can be found in the subdirectories of /usr/share/kbd/keymaps/.

Examples

For displaying characters such as Č, ž, đ, š or Ł, ę, ą, ś using the font lat2-16.psfu.gz:

CONSOLEFONT="lat2-16"

It means that second part of ISO/IEC 8859 characters are used with size 16. You can change font size using other values like lat2-08...16. For the regions determined by 8859 specification, look at the Wikipedia. You can use a Terminus font which is recommended if you work a lot in console without X server. ter-216b for example is latin-2 part, size 16, bold. ter-216n is the same but normal weight. Terminus fonts have sizes up to 32.

Now, set the proper keymap, for lat2-16 it will be:

CONSOLEMAP="8859-2"

To use the specified font in early userspace, that is, early in the bootup process, add the consolefont hook to /etc/mkinitcpio.conf:

HOOKS="base udev autodetect pata scsi sata filesystems consolefont keymap"

Then rebuild the image:

# mkinitcpio -p linux
Note: The above steps must be repeated for each kernel if more than one kernel package is installed.

See Mkinitcpio#HOOKS for more information.