The X Window System (X11) is the de facto standard for graphical user interfaces in Unix. X is network-based, enabling applications started on one host to be displayed on another host connected over any kind of network (LAN or Internet). This chapter provides basic information on the X configuration, and background information about the use of fonts in openSUSE® Leap.
Usually, the X Window System needs no configuration. The hardware is
dynamically detected during X start-up. The use of
xorg.conf
is therefore deprecated. If you still need to
specify custom options to change the way X behaves, you can still do so by
modifying configuration files under
/etc/X11/xorg.conf.d/
.
Fonts in Linux can be categorized into two parts:
Contains a mathematical description as drawing instructions about the shape of a glyph. As such, each glyph can be scaled to arbitrary sizes without loss of quality. Before such a font (or glyph) can be used, the mathematical descriptions need to be transformed into a raster (grid). This process is called font rasterization. Font hinting (embedded inside the font) improves and optimizes the rendering result for a particular size. Rasterization and hinting is done with the FreeType library.
Common formats under Linux are PostScript Type 1 and Type 2, TrueType, and OpenType.
Consists of an array of pixels designed for a specific font size. Bitmap fonts are extremely fast and simple to render. However, compared to vector fonts, bitmap fonts cannot be scaled without losing quality. As such, these fonts are usually distributed in different sizes. These days, bitmap fonts are still used in the Linux console and sometimes in terminals.
Under Linux, Portable Compiled Format (PCF) or Glyph Bitmap Distribution Format (BDF) are the most common formats.
The appearance of these fonts can be influenced by two main aspects:
choosing a suitable font family,
rendering the font with an algorithm that achieves results comfortable for the receiver's eyes.
The last point is only relevant to vector fonts. Although the above two points are highly subjective, some defaults need to be created.
Linux font rendering systems consist of several libraries with different relations. The basic font rendering library is FreeType, which converts font glyphs of supported formats into optimized bitmap glyphs. The rendering process is controlled by an algorithm and its parameters (which may be subject to patent issues).
Every program or library which uses FreeType should consult the Fontconfig library. This library gathers font configuration from users and from the system. When a user amends his Fontconfig setting, this change will result in Fontconfig-aware applications.
More sophisticated OpenType shaping needed for scripts such as Arabic, Han or Phags-Pa and other higher level text processing lies on the shoulders of Harfbuzz or Pango, to mention some examples.
To get an overview about which fonts are installed on your system, ask the
commands rpm
or fc-list
. Both will
give you a good answer, but may return a different list depending on system
and user configuration:
rpm
Invoke rpm
to see which software packages containing
fonts are installed on your system:
rpm -qa '*fonts*'
Every font package should satisfy this expression. However, the command
may return some false positives like fonts-config
(which is neither a font nor does it contain fonts).
fc-list
Invoke fc-list
to get an overview about what font
families can be accessed, whether they are installed on the system or in
your home:
fc-list ':' family
fc-list
The command fc-list
is a wrapper to the Fontconfig
library. It is possible to query a lot of interesting information from
Fontconfig—or, to be more precise, from its cache. See
man 1 fc-list
for more details.
If you want to know what an installed font family looks like, either use the
command ftview
(package
ft2demos
) or visit
http://fontinfo.opensuse.org/. For example, to display
the FreeMono font in 14 point, use ftview
like this:
ftview 14 /usr/share/fonts/truetype/FreeMono.ttf
If you need further information, go to http://fontinfo.opensuse.org/ to find out which styles (regular, bold, italic, etc.) and languages are supported.
To query which font is used when a pattern is given, use the
fc-match
command.
For example, if your pattern contains an already installed font,
fc-match
returns the file name, font family, and the
style:
tux >
fc-match 'Liberation Serif'
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
If the desired font does not exist on your system, Fontconfig's matching rules take place and try to find the most similar fonts available. This means, your request is substituted:
tux >
fc-match 'Foo Family'
DejaVuSans.ttf: "DejaVu Sans" "Book"
Fontconfig supports aliases: a name is substituted with another family name. A typical example are the generic names such as “sans-serif”, “serif”, and “monospace”. These alias names can be substituted by real family names or even a preference list of family names:
tux >
for font in serif sans mono; do fc-match "$font" ; done
DejaVuSerif.ttf: "DejaVu Serif" "Book"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
The result may vary on your system, depending on which fonts are currently installed.
Fontconfig always returns a real family (if at least one is installed) according to the given request, as similar as possible. “Similarity” depends on Fontconfig's internal metrics and on the user's or administrator's Fontconfig settings.
To install a new font there are these major methods:
Manually install the font files such as *.ttf
or
*.otf
to a known font directory. If it needs to be
system-wide, use the standard directory
/usr/share/fonts
. For installation in your home
directory, use ~/.config/fonts
.
If you want to deviate from the standard directories, Fontconfig allows
you to choose another one. Let Fontconfig know by using the
<dir>
element, see
Section 7.1.5.2, “Diving into Fontconfig XML” for details.
Install fonts using zypper
. Lots of fonts are already
available as a package, be it on your SUSE distribution or in the
M17N:fonts
repository. Add the repository to your list using the following command.
For example, to add a repository for SLE 12:
sudo zypper ar http://download.opensuse.org/repositories/M17N:/fonts/SLE_12/M17N:fonts.repo
To search for your FONT_FAMILY_NAME use this command:
sudo zypper se 'FONT_FAMILY_NAME*fonts'
Depending on the rendering medium, and font size, the result may be unsatisfactory. For example, an average monitor these days has a resolution of 100dpi which makes pixels too big and glyphs look clunky.
There are several algorithms available to deal with low resolutions, such as anti-aliasing (grayscale smoothing), hinting (fitting to the grid), or subpixel rendering (tripling resolution in one direction). These algorithms can also differ from one font format to another.
Subpixel rendering is not used in SUSE distributions. Although FreeType2 has support for this algorithm, it is covered by several patents expiring at the end of the year 2019. Therefore, setting subpixel rendering options in Fontconfig has no effect unless the system has a FreeType2 library with subpixel rendering compiled in.
Via Fontconfig, it is possible to select a rendering algorithms for every font individually or for a set of fonts.
sysconfig
#
openSUSE Leap comes with a sysconfig
layer above
Fontconfig. This is a good starting point for experimenting with font
configuration. To change the default settings, edit the configuration file
/etc/sysconfig/fonts-config
. (or use the YaST
sysconfig module). After you have edited the file, run
fonts-config
:
sudo /usr/sbin/fonts-config
Restart the application to make the effect visible. Keep in mind the following issues:
A few applications do need not to be restarted. For example, Firefox re-reads Fontconfig configuration from time to time. Newly created or reloaded tabs get new font configurations later.
The fonts-config
script is called automatically after
every package installation or removal (if not, it is a bug of the font
software package).
Every sysconfig variable can be temporarily overridden by the
fonts-config
command line option. See
fonts-config --help
for details.
There are several sysconfig variables which can be altered. See
man 1 fonts-config
or the help page of the YaST
sysconfig module. The following variables are examples:
Consider FORCE_HINTSTYLE
,
FORCE_AUTOHINT
, FORCE_BW
,
FORCE_BW_MONOSPACE
,
USE_EMBEDDED_BITMAPS
and
EMBEDDED_BITMAP_LANGAGES
Use PREFER_SANS_FAMILIES
,
PREFER_SERIF_FAMILIES
,
PREFER_MONO_FAMILIES
and
SEARCH_METRIC_COMPATIBLE
The following list provides some configuration examples, sorted from the “most readable” fonts (more contrast) to “most beautiful” (more smoothed).
Prefer bitmap fonts via the PREFER_*_FAMILIES
variables. Follow the example in the help section for these variables.
Be aware that these fonts are rendered black and white, not smoothed and
that bitmap fonts are available in several sizes only. Consider using
SEARCH_METRIC_COMPATIBLE="no"
to disable metric compatibility-driven family name substitutions.
Scalable fonts rendered without antialiasing can result in a similar outcome to bitmap fonts, while maintaining font scalability. Use well hinted fonts like the Liberation families. Unfortunately, there is a lack of well hinted fonts though. Set the following variable to force this method:
FORCE_BW="yes"
Render monospaced fonts without antialiasing only, otherwise use default settings:
FORCE_BW_MONOSPACE="yes"
All fonts are rendered with antialiasing. Well hinted fonts will be
rendered with the byte code interpreter (BCI) and
the rest with autohinter (hintstyle=hintslight
).
Leave all relevant sysconfig variables to the default setting.
Use fonts in CFF format. They can be considered also more readable than
the default TrueType fonts given the current improvements in FreeType2.
Try them out by following the example of
PREFER_*_FAMILIES
. Possibly make them more dark and
bold with:
SEARCH_METRIC_COMPATIBLE="no"
as they are rendered by hintstyle=hintslight
by
default. Also consider using:
SEARCH_METRIC_COMPATIBLE="no"
Even for a well hinted font, use FreeType2's autohinter. That can lead to thicker, sometimes fuzzier letter shapes with lower contrast. Set the following variable to activate this:
FORCE_AUTOHINTER="yes"
Use FORCE_HINTSTYLE
to control the level of hinting.
Fontconfig's configuration format is the eXtensible Markup
Language (XML). These few examples are not a complete reference,
but a brief overview. Details and other inspiration can be found in
man 5 fonts-conf
or in
/etc/fonts/conf.d/
.
The central Fontconfig configuration file is
/etc/fonts/fonts.conf
, which—along other
work—includes the whole /etc/fonts/conf.d/
directory. To customize Fontconfig, there are two places where you can
insert your changes:
System-wide changes.
Edit the file /etc/fonts/local.conf
(by default, it
contains an empty fontconfig
element).
User-specific changes.
Edit the file ~/.config/fontconfig/fonts.conf
.
Place Fontconfig configuration files in the
~/.config/fontconfig/conf.d/
directory.
User-specific changes overwrite any system-wide settings.
The file ~/.fonts.conf
is marked as deprecated and
should not be used anymore. Use
~/.config/fontconfig/fonts.conf
instead.
Every configuration file needs to have a fontconfig
element. As such, the minimal file looks like this:
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <!-- Insert your changes here --> </fontconfig>
If the default directories are not enough, insert the
dir
element with the respective directory:
<dir>/usr/share/fonts2</dir>
Fontconfig searches recursively for fonts.
Font-rendering algorithms can be chosen with following Fontconfig snippet (see Example 7.1, “Specifying Rendering Algorithms”):
<match target="font"> <test name="family"> <string>FAMILY_NAME</string> </test> <edit name="antialias" mode="assign"> <bool>true</bool> </edit> <edit name="hinting" mode="assign"> <bool>true</bool> </edit> <edit name="autohint" mode="assign"> <bool>false</bool> </edit> <edit name="hintstyle" mode="assign"> <const>hintfull</const> </edit> </match>
Various properties of fonts can be tested. For example, the
<test>
element can test for the font family (as
shown in the example), size interval, spacing, font format, and others.
When abandoning <test>
completely, all
<edit>
elements will be applied to every font
(global change).
<alias> <family>Alegreya SC</family> <default> <family>serif</family> </default> </alias>
<alias> <family>serif</family> <prefer> <family>Droid Serif</family> </prefer> </alias>
<alias> <family>serif</family> <accept> <family>STIXGeneral</family> </accept> </alias>
The rules from Example 7.2, “Aliases and Family Name Substitutions” create a prioritized family list (PFL). Depending on the element, different actions are performed:
<default>
from
Rule 1
This rule adds a serif
family name at the
end of the PFL.
<prefer>
from
Rule 2
This rule adds “Droid Serif” just
before the first occurrence of serif
in
the PFL, whenever Alegreya SC
is present in PFL.
<accept>
from Rule 3
This rule adds a “STIXGeneral” family name just
after the first occurrence of the serif
family name in the PFL.
Putting this together, when snippets occur in the order Rule 1 - Rule 2 - Rule 3 and the user requests “Alegreya SC”, then the PFL is created as depicted in Table 7.1, “Generating PFL from Fontconfig rules”.
In Fontconfig's metrics, the family name has the highest priority over other patterns, like style, size, etc. Fontconfig checks which family is currently installed on the system. If “Alegreya SC” is installed, then Fontconfig returns it. If not, it asks for “Droid Serif”, etc.
Be careful. When the order of Fontconfig snippets is changed, Fontconfig can return different results, as depicted in Table 7.2, “Results from Generating PFL from Fontconfig Rules with Changed Order”.
Think of the <default>
alias as a classification
or inclusion of this group (if not installed). As the example shows,
<default>
should always precede the
<prefer>
and <accept>
aliases of that group.
<default>
classification is not limited to the
generic aliases serif, sans-serif and monospace. See
/usr/share/fontconfig/conf.avail/30-metric-aliases.conf
for a complex example.
The following Fontconfig snippet in
Example 7.3, “Aliases and Family Name Substitutions” creates a
serif
group. Every family in this group could substitute
others when a former font is not installed.
<alias> <family>Alegreya SC</family> <default> <family>serif</family> </default> </alias> <alias> <family>Droid Serif</family> <default> <family>serif</family> </default> </alias> <alias> <family>STIXGeneral</family> <default> <family>serif</family> </default> </alias> <alias> <family>serif</family> <accept> <family>Droid Serif</family> <family>STIXGeneral</family> <family>Alegreya SC</family> </accept> </alias>
Priority is given by the order in the <accept>
alias. Similarly, stronger <prefer>
aliases can be
used.
Example 7.2, “Aliases and Family Name Substitutions” is expanded by Example 7.4, “Aliases and Family Names Substitutions”.
<alias> <family>serif</family> <accept> <family>Liberation Serif</family> </accept> </alias>
<alias> <family>serif</family> <prefer> <family>DejaVu Serif</family> </prefer> </alias>
The expanded configuration from Example 7.4, “Aliases and Family Names Substitutions” would lead to the following PFL evolution:
Order |
Current PFL |
---|---|
Request |
|
| |
| |
| |
| |
|
In case multiple <accept>
declarations for the
same generic name exist, the declaration that is parsed last
“wins”. If possible, do not use
<accept>
after
user (/etc/fonts/conf.d/*-user.conf
) when creating
a system-wide configuration.
In case multiple <prefer
declarations for the same
generic name exist, the declaration that is parsed last
“wins”. If possible, do not use
<prefer>
before user in the system-wide
configuration.
Every <prefer>
declaration overwrites
<accept>
declarations for the same generic
name. If the administrator wants to give the user free rein to use even
<accept>
and not only
<prefer>
,the administrator should not use
<prefer>
in the system-wide configuration. On
the other hand, users mostly use <prefer>
,, so
that should not be detrimental and we see the use of
<prefer>
also in system wide configurations.
Install the packages xorg-docs
to
get more in-depth information about X11. man 5 xorg.conf
tells you more about the format of the manual configuration (if needed).
More information on the X11 development can be found on the project's home
page at http://www.x.org.
Drivers are found in xf86-video-*
packages, for
example xf86-video-nv
. Many of the drivers
delivered with these packages are described in detail in the related manual
page. For example, if you use the nv
driver, find more
information about this driver in man 4 nv
.
Information about third-party drivers should be available in
/usr/share/doc/packages/<package_name>
. For
example, the documentation of
x11-video-nvidiaG03
is available
in /usr/share/doc/packages/x11-video-nvidiaG03
after
the package was installed.