Fonts

From ArchWiki
(Redirected from Fonts (Italiano))

From Wikipedia:Computer font: "A computer font is implemented as a digital data file containing a set of graphically related glyphs. A computer font is designed and created using a font editor. A computer font specifically designed for the computer screen, and not for printing, is a screen font."

Note that certain font licenses may impose some legal limitations.

Font formats

Most computer fonts used today are in either bitmap or outline data formats.

Bitmap fonts
Consist of a matrix of dots or pixels representing the image of each glyph in each face and size.
Outline or vector fonts
Use Bézier curves, drawing instructions and mathematical formulae to describe each glyph, which make the character outlines scalable to any size.

Bitmap formats

These formats can also be gzipped. See #Bitmap for the available bitmap fonts.

Outline formats

  • PostScript fonts by Adobe – has various formats, e.g: Printer Font ASCII (PFA) and Printer Font Binary (PFB)
  • TrueType by Apple and Microsoft (file extension: ttf)
  • OpenType by Microsoft, built on TrueType (file extensions: otf, ttf)

For most purposes, the technical differences between TrueType and OpenType can be ignored.

Other formats

The typesetting application TeX and its companion font software, Metafont, traditionally renders characters using its own methods. Some file extensions used for fonts from these two programs are *pk, *gf, mf and vf. Modern versions can also use TrueType and OpenType fonts.

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

The SVG format also has its own font description method.

Installation

There are various methods for installing fonts.

Pacman

Fonts and font collections in the enabled repositories can be installed using pacman.

Available fonts may be found by querying packages (e.g. for font or ttf).

Creating a package

You should give pacman the ability to manage your fonts, which is done by creating an Arch package. These can also be shared with the community in the AUR. The packages to install fonts are particularly similar; see Font packaging guidelines.

The family name of a font file can be acquired with the use of fc-query for example: fc-query -f '%{family[0]}\n' /path/to/file. The formatting is described in FcPatternFormat(3).

Manual installation

The recommended way of adding fonts that are not in the repositories of your system is described in #Creating a package. This gives pacman the ability to remove or update them at a later time.

Alternatively, fonts can be installed manually:

  • For a single user, install fonts to ~/.local/share/fonts/.
    • In many cases this suffices, unless you run graphical applications as other users.
    • In the past ~/.fonts/ was used, but is now deprecated.
  • For system-wide (all users) installation, place your fonts under /usr/local/share/fonts/.
    • You may need to create the directory first: mkdir -p /usr/local/share/fonts.
    • /usr/share/fonts/ is under the purview of the package manager, and should not be modified manually.

The creation of a subdirectory structure is up to the user, and varies among Linux distributions. For clarity, it is good to keep each font in its own directory. Fontconfig will search its default paths recursively, ensuring nested files get picked up.

An example structure might be:

/usr/local/share/fonts/
├── otf
│   └── SourceCodeVariable
│       ├── SourceCodeVariable-Italic.otf
│       └── SourceCodeVariable-Roman.otf
└── ttf
    ├── AnonymousPro
    │   ├── Anonymous-Pro-B.ttf
    │   ├── Anonymous-Pro-I.ttf
    │   └── Anonymous-Pro.ttf
    └── CascadiaCode
        ├── CascadiaCode-Bold.ttf
        ├── CascadiaCode-Light.ttf
        └── CascadiaCode-Regular.ttf

The font files need to have sufficient read permissions for all users, i.e. at least chmod 444 for files, and 555 for directories.

For the Xserver to load fonts directly (as opposed to the use of a font server), the directory for your newly added font must be added with a FontPath entry. This entry is located in the Files section of your Xorg configuration file (e.g. /etc/X11/xorg.conf or /etc/xorg.conf). See #Older applications for more detail.

Finally, update the fontconfig cache (usually unnecessary as software using the fontconfig library does this):

$ fc-cache

Older applications

With older applications that do not support fontconfig (e.g. GTK 1.x 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

Or if fonts were installed in a different sub-folders under the e.g. /usr/share/fonts:

$ for dir in * ; do if [  -d  "$dir"  ]; then cd "$dir";xset +fp "$PWD" ;mkfontscale; mkfontdir;cd .. ;fi; 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
Note: Many packages will automatically configure Xorg to use the font upon installation. If that is the case with your font, this step is not necessary.

This can also be set globally in /etc/X11/xorg.conf or /etc/X11/xorg.conf.d.

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 X.Org 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/misc"
    FontPath    "/usr/share/fonts/truetype"
    FontPath    "/usr/share/fonts/TTF"
    FontPath    "/usr/share/fonts/util"
EndSection

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 (after successful installation of the package) and runs as root to enable them system-wide.

# fc-cache
/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"

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.

Tip: Archfonts is a Python script that can be used to generate an overview of all the TTF fonts found in the official repositories and in the AUR.

Bitmap

Note: pango 1.44 dropped support for FreeType in favor of HarfBuzz thus losing support for traditional BDF/PCF bitmap fonts, so some applications (e.g. gnome-terminal) will not work with such fonts anymore, showing rectangles instead of glyphs. See FS#63297, Pango issue #386 and HarfBuzz issue #1897.

Works with Pango 1.44 and later:

Latin script

Families

Packages providing a base font set:

Packages not providing a base font set:

Legacy Microsoft font packages:

  • Microsoft fonts (ttf-ms-fontsAUR) – Andalé Mono, Courier New, Arial, Arial Black, Comic Sans, Impact, Lucida Sans, Microsoft Sans Serif, Trebuchet, Verdana, Georgia, Times New Roman
  • Vista fonts (ttf-vista-fontsAUR) – Consolas, Calibri, Candara, Corbel, Cambria, Constantia

Monospaced

Fonts supporting "programming ligatures" (e.g., the display of the "->" sequence as a double-width "⟶" glyph) are identified below with a ⟶ sign. For more monospaced fonts, also see #Bitmap and #Families.

Relevant websites:

Sans-serif

Serif

Handwriting

  • ttf-nothingyoucoulddoAUR – Handwriting of a photographer
  • ttf-indieflowerAUR – Handwriting sans-serif font with bubbly and rounded edges
  • ttf-pacificoAUR – Brush script handwriting font which was inspired by the 1950s American surf culture and expanded to Cyrillic
  • otf-londrinaAUR – Handwriting font inspired from the streets of Sao Paulo, Brazil
  • otf-teslaAUR – Script font based on a reconstruction of Nikola Tesla's handwriting
  • ttf-architects-daughterAUR – Font incorporating the graphic, squared look of architectural writing and the natural feel of daily handwriting

Unsorted

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: This section should be absorbed into the Monospace/Serif/Sans-Serif structure (Discuss in Talk:Fonts)

Non-latin scripts

Ancient Scripts

  • ttf-ancient-fontsAUR – Font containing Unicode symbols for Aegean, Egyptian, Cuneiform, Anatolian, Maya, and Analecta scripts

Arabic

See Localization/Arabic#Fonts.

Bengali

Read Localization/Bengali#Fonts for details.

Braille

  • ttf-ubrailleAUR – Font containing Unicode symbols for braille

Chinese, Japanese, Korean, Vietnamese

Pan-CJK

Adobe Source Han fonts and Noto CJK fonts have identical glyphs and metrics, but with different branding since the project was commissioned by both Adobe and Google.

Both collections comprehensively support Simplified Chinese, Traditional Chinese, Japanese, and Korean, with a consistent design and look.

Chinese

See Localization/Chinese#Fonts.

Japanese

See Localization/Japanese#Fonts.

Korean

See Localization/Korean#Fonts.

Vietnamese
  • ttf-hannom – Vietnamese TrueType font for chữ Nôm characters

Cyrillic

See also #Latin script.

  • ttf-paratypeAUR – Font family by ParaType: sans, serif, mono, extended cyrillic and latin, OFL license
  • otf-russkopisAUR – A free OpenType cursive font for Cyrillic script

Greek

Almost all Unicode fonts contain the Greek character set (polytonic included). Some additional font packages, which might not 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
  • ttf-mgopenAUR – Professional TrueType fonts from Magenta
  • ttf-sbl-greekAUR – SBL Greek, created by the Society of Biblical Literature (SBL)
  • ttf-sbl-biblitAUR – SBL BibLit, includes characters from both SBL Greek and SBL Hebrew

Hebrew

  • opensiddur-hebrew-fontsAUR – Large collection of Open-source licensed Hebrew fonts. There are also few Latin, Greek, Cyrillic, Arabic, and Amharic.
  • culmusAUR – Nice collection of free Hebrew fonts.
  • alefbetAUR – 2 Hebrew fonts (at the moment): the commonly used "David Libre", and the handwriting font "Gveret Levin".
  • ttf-ms-fontsAUR – contains Arial and other fonts.
  • ttf-sbl-hebrewAUR – SBL Hebrew, created by the Society of Biblical Literature (SBL)
  • ttf-sbl-biblitAUR – SBL BibLit, includes characters from both SBL Hebrew and SBL Greek

Indic

See Localization/Indic#Fonts.

Khmer

Mongolic and Tungusic

  • ttf-abkaiAUR – Fonts for Sibe, Manchu and Daur scripts (incomplete, currently in development)

Persian

Tai–Kadai

Tibeto-Burman

Emoji and symbols

A section of the Unicode standard is designated for pictographic characters called "emoji".

Emoji fonts come in different formats: CBDT/CBLC (Google), SBIX (Apple), COLR/CPAL (Microsoft), SVG (Mozilla/Adobe).

Emojis should work out of the box once you have at least one emoji font installed of a supported format. However, some of the emoji fonts encode their glyphs as large fixed-size bitmaps and thus, for the purpose of displaying at the intended size, rely on bitmap font downscaling, which is enabled by default.

Emoji font fallback according to the standard requires extra code to handle emoji.

For the discovery and input of Emoji see List of applications/Utilities#Text input.

Software CBDT/CBLC SBIX COLR/CPAL SVG Emoji font fallback
Freetype Yes Yes Yes No
Pango Freetype Yes
WebKitGTK Freetype Yes
Qt Freetype No [2] [3] [4]
Chromium Freetype Yes
Firefox Freetype Yes No, see Firefox#Font troubleshooting for workaround.
Note: Qt can only use first 255 fonts at a time [5]. Make sure you have an emoji font in your list of preferred fallback fonts.

CBDT/CBLC:

SVG:

  • otf-openmojiAUR – German University of Design in Schwäbisch Gmünd open-source Emoji 15.0.
  • ttf-twemoji-colorAUR – Twitter's open-source Emoji 14.0.

Outline only:

  • ttf-symbolaAUR – provides many Unicode symbols, including emoji.

Kaomoji are sometimes referred to as "Japanese emoticons" and are composed of characters from various character sets, including CJK and Indic fonts. For example, the following set of packages covers most of existing kaomoji: gnu-free-fonts, ttf-arphic-uming, and ttf-indic-otf.

Math

Additionally, texlive-basic and texlive-fontsextra contain many math fonts such as Latin Modern Math and STIX fonts. See TeX Live#Making fonts available to Fontconfig for configuration.

Other operating system fonts

Fallback font order

Fontconfig automatically chooses a font that matches the current requirement. That is to say, if one is looking at a window containing English and Chinese for example, it will switch to another font for the Chinese text if the default one does not support it.

Fontconfig lets every user configure the order they want via $XDG_CONFIG_HOME/fontconfig/fonts.conf. If you want a particular Chinese font to be selected after your favorite Serif font, your file would look like this:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
   <family>serif</family>
   <prefer>
     <family>Your favorite Latin Serif font name</family>
     <family>Your Chinese font name</family>
   </prefer>
 </alias>
</fontconfig>
Tip:
  • If you use a Chinese locale, set LC_LANG to und to make this work. Otherwise both English and Chinese text will be rendered in the Chinese font.
  • After changing the configuration run fc-match -a monospace | head to verify your fallback font is set correctly.

You can add a section for sans-serif and monospace as well. For more information, have a look at the fontconfig manual.

See also Font configuration#Set default or fallback fonts.

Font alias

There are several font aliases which represent other fonts in order that applications may use similar fonts. The most common aliases are: serif for a font of the serif type (e.g. DejaVu Serif); sans-serif for a font of the sans-serif type (e.g. DejaVu Sans); and monospace for a monospaced font (e.g. DejaVu Sans Mono). However, the fonts which these aliases represent may vary and the relationship is often not shown in font management tools, such as those found in KDE and other desktop environments.

To reverse an alias and find which font it is representing, run:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

In this case, DejaVuSansMono.ttf is the font represented by the monospace alias.

Tips and tricks

List all installed fonts

You can use the following command to list all installed Fontconfig fonts that are available on your system.

$ fc-list

List installed fonts for a particular language

Applications and browsers select and display fonts depending upon fontconfig preferences and available font glyph for Unicode text. To list installed fonts for a particular language, issue a command fc-list :lang="two letter language code". For instance, to list installed Arabic fonts or fonts supporting Arabic glyph:

$ fc-list -f '%{file}\n' :lang=ar
/usr/share/fonts/TTF/FreeMono.ttf
/usr/share/fonts/TTF/DejaVuSansCondensed.ttf
/usr/share/fonts/truetype/custom/DroidKufi-Bold.ttf
/usr/share/fonts/TTF/DejaVuSansMono.ttf
/usr/share/fonts/TTF/FreeSerif.ttf

List installed fonts for a particular Unicode character

This article or section needs expansion.

Reason: When is fc-list a better alternative? (Discuss in Talk:Fonts#List font containing a specific glyph?)

To search for monospace fonts supporting a particular Unicode codepoint:

$ fc-match -s monospace:charset=1F4A9

Set terminal font on-the-fly

This article or section needs expansion.

Reason: Where is the documentation for the escape codes? (Discuss in Talk:Fonts)

For terminal emulators that use X resources, e.g. xterm or rxvt-unicode, fonts can be set by using escape sequences. Specifically, echo -e "\033]710;$font\007" to change the normal font (*font in ~/.Xresources), and replace 710 with 711, 712, and 713 to change the *boldFont, *italicFont, and *boldItalicFont, respectively.

$font uses the same syntax as in ~/.Xresources and can be anything the terminal emulator will support. (Example: xft:dejavu sans mono:size=9)

Application-specific font cache

Matplotlib (python-matplotlib) uses its own font cache, so after updating fonts, be sure to remove ~/.matplotlib/fontList.cache, ~/.cache/matplotlib/fontList.cache, ~/.sage/matplotlib-1.2.1/fontList.cache, etc. so it will regenerate its cache and find the new fonts [6].

Bidirectional text support

See Bidirectional text for troubleshooting problems related to RTL languages.

Braille font not displaying correctly inside terminals

If braille characters in terminals exhibit rendering issues, try installing a braille font and uninstalling gnu-free-fonts.

Application-specific font configuration tips

Emacs

Emacs calculates sizes differently than standard Linux desktop applications, and Emacs packages do not all use the same config format, so if points or raw pixel size doesn't work, try using the other value.

Visual Studio Code

Change the setting Editor: Experimental Whitespace Rendering from "svg" to "font" if your monospace fonts have problems scaling certain characters correctly. This is known to help with "Terminus (TTF)" and "IBM 3270" fonts.

See also