X11 fonts a tutorial

 

In X11, you can use multiple font systems, practically there is the X11 core font system , core as in being part of the core protocol, and there is a newer font system, called the xft font system. xft is not really new, as in today, but it is simply more recent, then the core font system.

A font system, has multiple tasks, such as defining the kind of fonts that can be used, and converting a character, using a selected font, or fonts to a bitmap image.

X11 core font system

What is X11 core font system?

In X11 core font system, the server is responsible for having the fonts, so the fonts are stored, or installed on the server. A client asks the server to load a font. The server is responsible for converting characters, into bitmaps, using the fonts that it has installed .

So, why the use of the term server and client, you might ask? Because when X11 was designed, it had in mind that communication will be done over a network. So the API calls, or the function calls, which are done by your program, called the client, are going to be done over a medium, the network.

So when designing, the idea was to minimize network bandwidth or transfer, as such some control was relinquished, to the entity responsible for handling the API calls, the server, hence the server was responsible for having the fonts, and creating bitmaps from characters.

X11 core font formats

This being said, a natural question to ask, is, what are the font formats, supported by the server?

To start with, adobe came up with the BDF format. BDF, stands for bitmap distribution format. This was simply an ASCII file, which defined the font, by using keys and values, as in:

FONT -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso10646-1
# The key is FONT
# The value is -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso10646-1

or

BITMAP
12
11
# BITMAP is the key ,
# 12 , 11 .. are the 
# values.

The BDF format, needed to be compiled, for different architectures, and it was not compressed.

So the next idea was, why not provide a compressed version of this format. So this led, to the birth of SNF, which stands for Sever normal format.

The SNF format, was used in in X11R4, but its main problem was, is that it was not portable, so if compiled for an architecture, it cannot be used for another. So in other words, it was platform dependent.

Hence the next idea, why not have a platform independent, compressed version of BDF ? This led to the birth of PCF , which stands for the portable compiled format, and which can be used on any platform, or architecture, even if compiled on a different one.

So these were the fonts, which were based on BDF, what happened next you might ask ?

Well all the previous fonts, were bitmap fonts, so they are just a series of 1 and 0. Being a series of 1, and 0, scaling did not work well, but it can nevertheless be performed, using a given algorithm, like why not proportion, or nearest neighbor, or anything else.

This being said, the next step in font development was, why not, instead of specifying the bits for each character, just outline, how the character should be drawn, using for example lines, curves, points, and some formulas.

Scaling, in this case, is performed, by using the specified basic drawing primitives, and other algorithms, and when drawing is necessary, the bits are generated .

These types of fonts, are called outline or vector fonts. an example of outline fonts, are Type 1 , true type, and open fonts.

Outline or vector fonts, are not without limitations, they do require more processing power, they might not scale down in a good manner . Bitmap fonts are not without advantages, they do not require processing power, so they are faster, and they might scale well down.

This being said X11 core font system, does support the following formats of vector also known as outline fonts:

  • Type1 , which is adobe postscript, and which can have the following extensions : .pfa, .afm , .pfb.
  • True Type, which is a vector font developed by apple, and has a ttf extension .
  • Open Type, which is a vector font, developed by both Microsoft and adobe, and which has an otf extension.

X11 core fonts naming

X11 core font naming, is also called X Logical Font Description, which acronym is XLFD .An example of an X11 core font name is:

-adobe-helvetica-medium-r-normal--25-180-100-100-p-130-iso10646-1

– ouff, what is all that ?
adobe is?
foundry.
– okay, and what is foundry?
– This is like a historical name, which refers to the entity, who has created this font.
– ah! interesting! And helvetica?
– isn’t this called …uh .. font family.
– humm … humm .
– Font family , so like for one font family, you might have, multiple later definitions.
– ah ok, and what is ?
medium?
– well, this is the font weight, it can be one of thin, extralight, light, normal, medium, semibold or demibold, bold, extrabold, black.
– so is it like ordered, in an increasing degree of blackness? or heaviness?
– interesting! so where are we at now?
r .
– Ah, this one is easy, this is the ?
slant .
– okay, okay ! and slant is it like … an inclination, or something similar?
– sure! why not?
– and slant can be ?
r for roman, which is upright, i for italics, o for oblique, ri for reverse italic, ro for reverse oblique, and ot for other.
– hmm interesting, so like italics as in?
– someone drawing a slanted version, of what is upright.
– oblique?
– as in slanting, created by using an angle.
– okay, i see, and reverse?
– reverse clockwise.
– okay, it works, so now ?
normal
– is this, is this the ?
set width
– what, what?
normal, condensed, narrow, double-wide.
– ah ok ,so this is the font proportionate width, according to the foundry.
– ok, next?
25
– ah, weird story, it is called the PIXEL_SIZE.
– really, how weird is it?
– well, it is defined, as with relation to the POINT_SIZE, and the vertical resolution RESOLUTION_Y.
, and if set to 0 , this means that the font is scalable.
– hmmm, hmmm, and what is this?
180 ? This is the POINT_SIZE
– Ohh .. you divide by ten to get?
– the actual size.
– so ?
180 / 10 = 18 points.
– Ahh .. And this is the height, for which the font was ?
– designed.
– okay, cool, and to convert a point, to an inch ?
– well, 1 point, is equal to 1 inch, divided by 72 .
– okay, and what about 100?
– this is RESOLUTION_X
– okay, okay, so the horizontal resolution in?
– pixel or dot per inch.
– for which the font was ?
– designed.
– And the second 100?
– this is RESOLUTION_Y.
– ah, ok, ok! So the vertical resolution in?
– pixel or dot per inch.
– for which the font was?
– designed.
– hmm, hmm , so let us get back, to this weird story of yours.
– okay. 18 points, the POINT_SIZE, is how many inches ?
18 / 72 inches .
– so how many pixels ?
18 / 72 inches * 100 pixel / 1 inch = 25 pixels.
– oh trivial, so this is the ?
PIXEL_SIZE .
– okay, what about this p thing ?
– Oh, it is p, as in spacing !
– so spacing as in ?
p for proportional, m for mono-space, and c for character cell.
– proportional as in ?
– each character, can have its own width.
– mono-space, and character cell, all characters have ?
– fixed width?
– and for character cell, the width, is the width of ?
– the cell, that the character occupies.
– ohh, and this 130 thing?
– This is the AVERAGE_WIDTH , average width of ?
– a character.
– and 0 means ?
– the font is scalable.
– and this iso10646-1 ?
– well this is two things.
– and they are ?
CHARSET_REGISTRY , CHARSET_ENCODING.
– ah this one is simple.
– okay ?
CHARSET_REGISTRY is the authority responsible for ?
– registering the font related character set.
– like ?
– ISO.., or something …
– and CHARSET_ENCODING is ?
– the registry character set, encoding scheme.

This being said, if a font is designed for a given screen density, and used on a different screen density, it will scale, as such its actual or screen related PIXEL_SIZE, and POINT_SIZE, will be different.

This being said, if the font was used on a higher screen density, its PIXEL_SIZE and POINT_SIZE will be smaller, and if the font was used on a smaller density, its PIXEL_SIZE and POINT_SIZE will be higher.

So for example, if the font had a POINT_SIZE , of a 20, on a RESOLUTION_Y of 100, on a RESOLUTION_Y of 120, it will have a POINT_SIZE of 100/120 * 20 = 16 .

Listing, viewing, and selecting the fonts

To list all the fonts, which are installed on the server, xlsfonts can be used.

$ xlsfonts  | more
# List the fonts which are
# installed on the server.
-adobe-courier-bold-o-normal--10-100-75-75-m-60-iso10646-1
-adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-1
-adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-10
...

To view the character set, which is associated with a font, xfd can be used.

$ xfd -fn -adobe-courier-bold-o-normal--10-100-75-75-m-60-iso10646-1
# display the character set
# of the specified font.

To browse the available fonts, and to display a limited preview, of their character set, xfontsel can be used.

$ xfontsel
# Launch xfontsel

$ xfontsel -sample 'abcd' &
# Launch xfontsel and specify
# the sample to show instead 
# of the default alphanumeric
# one , which is A-Z a-z 0-9

To specify the font, that you wish an X application to use, you can possibly use the -fn option, followed by the font name, as in:

$ xcalc -fn -adobe-courier-bold-o-normal--34-240-100-100-m-200-iso8859-1
# the -fn option, followed 
# by a font name, can be 
# used to tell an X 
# application what font 
# it should use. 

Finally an X11 application, can have what is called a resource file, which can be used to define certain options or preferences, for this application, which can be overridden, or customizable by the user, such as an application background color, or the font it is going to use …

An application might define the resource file, that it is going to use, in /etc/X11/app-defaults , and a user might override applications resource files settings, by using an .Xresources file, in his home directory.

$ cat /etc/X11/app-defaults/XCalc | grep font
# grep anything related to font, 
# as defined, in Xcalc default
# resource file. 
XCalc*ti.button3.font:		-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*ti.button16.font:		-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*ti.button20.font:		-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*hp.button1.font:		-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*hp.button10.font:		-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*hp.button12.font:		-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*hp.button26.font:			6x12

The utility appres , can also be used to query an application resource file, for the fonts that it is going to load, but not necessarily be using, as follows:

$ appres XCalc | grep font
# List the font used by XCalc
# XCalc, is the application 
# class name.

XCalc*hp.button12.font:	-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*hp.button1.font:	-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*hp.button26.font:	6x12
XCalc*hp.button10.font:	-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*ti.button16.font:	-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*ti.button3.font:	-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*
XCalc*ti.button20.font:	-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*

An application class name, can be found by using xprop WM_CLASS, and clicking on the application, you want its class name to be displayed.

You can also check the source code of an application, to know what kind of fonts, it is using.

X11 core fonts name alias

So what is an alias you might ask . As you have seen in the previous section, the logical font description, can be really lengthy, so why not provide a shorter name, for this lengthy logical font description, and basically, this what an alias is.

An alias can be defined, in one or more, fonts.alias files, which are placed in one or more directories, in the font path, in other words, at most one fonts.alias file, per font directory path.

This being said, an alias file, is formed of key value pairs, where the key is the alias name, and the value is font name, that you wish to alias.

As an example, the fonts.alias file, in the /usr/share/fonts/X11/100dpi , has the following content:

lucidasans-bolditalic-8 -b&h-lucida-bold-i-normal-sans-11-80-100-100-p-69-iso8859-1
lucidasans-bolditalic-10 -b&h-lucida-bold-i-normal-sans-14-100-100-100-p-90-iso8859-1
lucidasans-bolditalic-12 -b&h-lucida-bold-i-normal-sans-17-120-100-100-p-108-iso8859-1
lucidasans-bolditalic-14 -b&h-lucida-bold-i-normal-sans-20-140-100-100-p-127-iso8859-1

Once a font alias, is added to a fonts.alias file, or once a fonts.alias file is created, the server must be informed, of such a change, and this can be done, by using xset fp rehash.

X11 core fonts name wildcards

A wildcard is either, an asterisk , *, which can match 1 or more characters, or an interrogation mark, ? which can match exactly one character.

So why using wildcards , you might ask?! Well as we have seen, when specifying a font to be used, you can either use, a full font name, an alias, or you can use also wildcards.

$ xlsfonts '*adobe*' | more
# list all fonts, which have a name
# that contains adobe 
-adobe-courier-bold-o-normal--0-0-100-100-m-0-iso10646-1
-adobe-courier-bold-o-normal--0-0-100-100-m-0-iso8859-1
-adobe-courier-bold-o-normal--0-0-75-75-m-0-iso10646-1
-adobe-courier-bold-o-normal--0-0-75-75-m-0-iso8859-1
...

$ xlsfonts '?misc-fixed-medium-r-normal--15-*-*-*-c-90-iso885?-?'
# List all fonts, that start with
# any character, have
# misc-fixed-medium-r-normal--15
# followed by a dash, followed by
# any characters, followed by a 
# dash, followed by any characters,
# followed by a dash, and followed
# by any characters, followed by
# -c-90-iso885, followed by any 
# character, followed by a dash
# followed by a character.
-misc-fixed-medium-r-normal--15-120-100-100-c-90-iso8859-1
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-2
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-3
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-4
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-5
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-7
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-8
-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-9

Using a wild card, can be useful, like if you don’t have hard requirements, for certain components of a font, maybe you just want the foundry to be adobe, and as for the rest, you do not care.

At this stage, you might ask, how matching is done. Well simply put, if the specified font name, has multiple matches, the first one in the font path, is the one used, later on if scaling is possible, to make the match happen, then scaling is done, irrelevant if the font is a bitmap, or a vector font.

$ xcalc -fn '*adobe*'
# some characters, are not displayed
# correctly in the calculator, after
# using this font wildcard.

X11 core fonts location

We already described, how to list all the fonts, but how about the font path, which is the directories, where the fonts reside, xset can be used for this purpose, as in :

$ xset q
...
Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins

So at this stage, you might wonder, what does :unscaled mean, at the end of a listing in a font path?

Well basically, when the X11 server is searching for a font, and there are multiple possible matches, X11, will first try and find the most exact match,the first one, after that, if the most exact match is not found, it will search for a font which will scale,the first match, irrelevant if it s a vector, or a bitmap font.

So using the :unscaled suffix, you are just informing the server, that these suffixed directories, contain fonts, which should not be scaled, so if an exact match is not found, these fonts won’t be matched for scaling.

On a side note, 100 or 75 in the font path, are the pixel per inch or the dpi, for which the font was designed.

Another possible output, of xset q, is the following :

$ xset q
Font Path:
  catalogue:/etc/X11/fontpath.d,built-ins

$ ls -l /etc/X11/fontpath.d
# list the content of the returned 
# font path.
total 4
.. 'xorg-x11-fonts-100dpi:unscaled:pri=30' -> /usr/share/X11/fonts/100dpi
.. 'xorg-x11-fonts-75dpi:unscaled:pri=20' -> /usr/share/X11/fonts/75dpi
..  xorg-x11-fonts-Type1 -> /usr/share/X11/fonts/Type1
.. 'xorg-x11-fonts-misc:unscaled:pri=10' -> /usr/share/X11/fonts/misc

This format is called a catalogue directory, and the one before is called absolute directory.

A catalogue directory, is a directory which contains symbolic links, to real font directories, as in the previous example.

The symbolic link name, has the following format:

<identifier>:[attribute]:pri=<priority>

For example :

xorg-x11-fonts-100dpi:unscaled:pri=30

xorg-x11-fonts-100dpi is called the identifier, unscaled is called the attribute, and was explained earlier, 30 is the font priority, and is used in ordering fonts.

To specify that a directory, is a catalogue directory, you just need to precede it, with catalogue: .

A third way of specifying a font, is by using, what is known, a font server identifier. A font server identifier, has the following format:

<trans>/<hostname>:<port−number>

As in

unix/localhost:7100

So trans, is the transport, it can be for example unix, for unix sockets, or it can also be TCP/IP. hostname is the hostname, as in localhost, and port, is the port number, to which the font server is listening to, usually it is 7100.

X11 font server

So, in the previous section, there was something about a font server identifier , basically an X11 font server, also known as xfs, served in a period of time, where it was decided, that font handling, should be done, by an external server, with which the X11 server can communicate.

Nowadays, the X11 server, is responsible for handling core fonts, so a font server is not really used.

Installing X11 core bitmap fonts

So as we have talked about, there are two type of X11 core fonts, the bitmap, and the scalable.

For bitmap fonts, it is preferable to have the pcf format. So, this being said, after having downloaded the font, and if it is in bdf format, you can use the tool bdftopcf, to convert from bdf format, to the pcf format.

$ bdftopcf font.bdf > font.pcf
# convert the font from bdf to
# pcf

$ gzip font.pcf
# compress the font using 
# the gzip command, this 
# will create a font.pcf.gz
# file.
# A bitmap font file must 
# be compressed.

Now that you have the bitmap font, that you wish to install, you can either place it, in an existing directory, or create a new directory, and place the font in it.

Once this is done, inside the selected directory, you must issue, the mkfontdir command, in order to update or create the font indexes.

This command, will just create or update a file, named fonts.dir, which format is similar to the fonts.alias file, so it consists of key and value pair, where in this case, the key is the filename, and the value is the logical font name.

...
ncenR24.pcf.gz -adobe-new century schoolbook-medium-r-normal--34-240-100-100-p-181-iso10646-1
symb08.pcf.gz -adobe-symbol-medium-r-normal--11-80-100-100-p-61-adobe-fontspecific
symb10.pcf.gz -adobe-symbol-medium-r-normal--14-100-100-100-p-85-adobe-fontspecific
symb12.pcf.gz -adobe-symbol-medium-r-normal--17-120-100-100-p-95-adobe-fontspecific
...

If the directory is not already in path, you can use the xset command to add it to path, as in :

$ xset fp+ /home/myfonts/
# add the /home/myfonts/ 
# directory, to the end 
# of the font path.

$ xset +fp /home/myfonts/
# add the /home/myfonts/
# directory, to the 
# beginning of the
# font path.

$ xset fp- /home/myfonts/
# remove the /home/myfonts/ 
# directory, from the end 
# of the font path.

$ xset -fp /home/myfonts/
# remove the /home/myfonts/
# directory, from the 
# beginning of the font 
# path.

Once this is done, and in order for the font server to reread, the fonts.alias, and fonts.dir files, you just need to issue the command : xset fp rehash, and now you can just use, the installed font.

Installing X11 core scalable fonts

The process is similar to the one described in the previous section, you just need to download a scalable font, in one of the supported format, so the Type 1 , TrueType and OpenType.

Once this is done, you can either place the downloaded font, in a previous directory in the path , or just create a new directory. In both cases, you need to issue the following two commands:

$ mkfontscale /path/directory/
$ mkfontdir /path/directory/

The mkfontscale command, will create a fonts.scale file, this is a file similar to fonts.dir, so it is an index of scalable fonts, and it consists of key value pairs, where the key is the filename , and the value is the font logical name.

...
c0632bt_.pfb -bitstream-bitstream charter-bold-r-normal--0-0-0-0-p-0-iso8859-1
c0633bt_.pfb -bitstream-bitstream charter-bold-i-normal--0-0-0-0-p-0-adobe-standard
c0633bt_.pfb -bitstream-bitstream charter-bold-i-normal--0-0-0-0-p-0-ascii-0
...

Once this is done, and if the directory was newly created, you just need to add it to the font path, as shown in the previous section.

Once this is done, you must inform the server of the changes, that have been made, by issuing the command xset fp rehash .

XFT font system

What is the xft font system?

Mainly the difference, between X11 core font system, and Xft font system, is thatXft performs rendering on the client side, and not on the server side, so the client is the one who is responsible, for creating the bitmaps representable of a given text.

Additionally, one of the most talked about features, of Xft, is anti aliasing, which is basically, for example a character having some sharp edges, this is aliasing, and anti aliasing as countering that, by using for example tones of colors, to hide the sharp edges.

Sharpe edges, for example, as in drawing a circle circumference, you have the color of the circumference pixels, and the surrounding pixels, are for example white, so you will have the effect of sharp edges, along the circumference.

Aliasing might also happen, when going from higher resolution images, to lower ones, because of loss of pixels.

xft is actually a stack of libraries or packages. It has the fontconfig package which is responsible, for deciding what fonts are available, on the system , and for certain other font configurations, such as if, fonts aliasing is enabled or disabled.

Another library in the stack, is the FreeType library, responsible for rasterizing, so for generating the characters bitmap images, given the selected font . xft actually stands for, the X FreeType interface library.

An application can either choose to support, the X11 core font system , or it might choose to support the XFT font system, or both.

xft font formats

xft supports both bitmap, and scalable font formats, so it supports the formats of fonts supported by X11 core, and additional formats, such as woff and eot

xft fonts location

fontconfig is responsible for managing, the non X11, core font database, so it looks in certain directories, for fonts.

The list of directories, that fontconfig looks for fonts in, is defined in the /etc/fonts/fonts.conf file, under the section Font directory list.

$ cat /etc/fonts/fonts.conf
# output the contents of 
# /etc/fonts/fonts.conf
...
<!-- Font directory list -->
  <dir>/usr/share/fonts</dir>
  <dir>/usr/X11R6/lib/X11/fonts</dir> 
  <dir>/usr/local/share/fonts</dir>
  <dir prefix="xdg">fonts</dir>
  <!-- the following element will be removed in the future -->
  <dir>~/.fonts</dir>
...

So as seen, the font path, consists of the directories /usr/share/fonts , /usr/X11R6/lib/X11/fonts, /usr/local/share/fonts, and ~/.fonts which use seems to be deprecated.

There is also an entry <dir prefix="xdg">fonts</dir>, so in this case, prefix is the prefix before the specified directory, which in this case is fonts, and the prefix is actually the value of the environment variable XDG_DATA_HOME.

xft installing fonts

To install fonts that will be managed by fontconfig, you just have to copy the font , into one of the directories, that fontconfig checks for fonts.

The directories, that fontconfig will check for fonts, are specified in the configuration file, /etc/fonts/fonts.conf, under:

 !-- Font directory list -->
	<dir>/usr/share/fonts</dir>
...
...

This location was described in the previous section.

An example of the content of /usr/share/fonts is:

$ ls /usr/share/fonts
# List the content of the
# fonts directory, 
# /usr/share/fonts.
cmap  cMap  eot  opentype  svg  truetype  type1  woff  X11

As it can be seen, there is a directory for opentype fonts, and one for trutype, and one for type1

To install the font, first you need to download it, or get it from someplace, after that , you have to move it to the appropriate directory. Later on, fontconfig must be made aware, of the new file, as such the command fc-cache must be executed to update, user font cache information, and sudo fc-cache must be used, to update, system wide, font cache information.

The font cache generated will contain for each font, its filename, and its associated properties.

So where are these cache files stored, you might ask. Well the /etc/fonts/fonts.conf has the answer, under the Font cache directory list section.

<!-- Font cache directory list -->
   <cachedir>/var/cache/fontconfig</cachedir>
   <cachedir prefix="xdg">fontconfig</cachedir>
   <!-- the following element will be removed in the future -->
   <cachedir>~/.fontconfig</cachedir>

Applications might need to be restarted, so that they are aware, of the newly installed font.

xft fonts naming

xft has its own font naming scheme, but the concepts exposed, in the X11 core fonts naming section, still apply, so if you understand that section, this section should be understood the same.

So xft font naming scheme is the following :

family-size:name=value:name=value...

The definition of family, size, and possible names and values, are in the following table.

Sometimes, instead of having a name, and a value pair, you will just have the value. The possible values, for weight, slant, spacing, and rgba are the following.

xft Listing, viewing, and selecting the fonts

To list all the fonts, which are known, by fontconfig, you can use, the fc-list command.

$ fc-list | more
...
/usr/share/fonts/truetype/lato/Lato-SemiboldItalic.ttf: Lato,Lato Semibold:style=Semibold Italic,Italic
...
/usr/share/fonts/X11/Type1/c0611bt_.pfb: Courier 10 Pitch:style=Bold Italic
...
/usr/share/fonts/opentype/mathjax/MathJax_Main-Regular.otf: MathJax_Main:style=Regular
...

So as the previous output shows, by default if no arguments are specified to fc-list, it will display , the font file name, followed by the font family, and the font style.

If you use the -v option, then you will have a more verbose output.

$ fc-list -v | more
# fc-list verbose output.
...
Pattern has 20 elts (size 32)
	family: "URW Palladio L"(s)
	style: "Bold Italic"(s)
	stylelang: "en"(s) "en"(s)
	slant: 100(i)(s)
	weight: 200(f)(s)
	width: 100(f)(s)
	foundry: "urw"(s)
	file: "/usr/share/fonts/type1/gsfonts/p052024l.pfb"(s)
	index: 0(i)(s)
	outline: True(s)
	scalable: True(s)
	charset: 
	0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff ffffffff ffffffff
	0001: ffffffff ffffffff fffff3ff ffffffff 00040000 00000000 00000000 00000000
	0002: 0f000000 00000000 00000000 00000000 00000000 00000000 3f0002c0 00000000
	0003: 00000000 00000000 00000000 00000000 00100000 10000000 00000000 00000000
	0004: ffffffff ffffffff ffffffff 00000000 cf0ff000 0d0dcc00 faff0007 033ffffc
	0020: 77180000 06010047 00000010 00000000 00000000 00001000 00000000 00000000
	0021: 00400000 00000004 00000000 00000000 00000000 00000000 00000000 00000000
	0022: 46260044 00000000 00000000 00000031 00000000 00000000 00000000 00000000
	0025: 00000000 00000000 00000000 00000000 00000000 00000000 00000400 00000000
	00f6: 00000000 00000000 00000000 00000000 00000000 00000000 000001f8 00000000
	00fb: 00000006 00000000 00000000 00000000 00000000 00000000 00000000 00000000
(s)
	lang: aa|af|av|ay|be|bg|bi|br|bs|bua|ca|ce|ch|co|cs|cv|da|de|en|eo|es|et|eu|fi|fj|
fo|fr|fur|fy|gd|gl|gv|ho|hr|hu|ia|id|ie|ik|io|is|it|ki|kl|kum|kv|la|lb|lez|lt|lv|mg|mh|mk|
mo|mt|nb|nds|nl|nn|no|nr|nso|ny|oc|om|os|pl|pt|rm|ro|ru|sel|sk|sl|sma|smj|so|sq|sr|ss|st|s
v|sw|tk|tl|tn|tr|ts|uk|uz|vo|vot|wa|wen|xh|yap|zu|an|crh|csb|fil|hsb|ht|jv|kj|ku-tr|kwm|li
|mn-mn|ms|na|ng|pap-an|pap-aw|rn|rw|sc|sg|sn|su|za(s)
	fontversion: 0(i)(s)
	fontformat: "Type 1"(s)
	decorative: False(s)
	postscriptname: "URWPalladioL-BoldItal"(s)
	color: False(s)
	symbol: False(s)
	variable: False(s)
...

You can also specify a pattern to match, by using the format family-size:name=value:name=value..., where the family, size, name and value, are the one, describe in the Xft naming section.

$ fc-list ":lang=ar"
# List fonts which support
# the Arabic language.
...
/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
/usr/share/fonts/truetype/noto/NotoSansArabicUI-Regular.ttf: Noto Sans Arabic UI:style=Regular
...


$ fc-list ":lang=ar:weight=bold"
# List fonts which support 
# the arabic language, and 
# which weight is bold. 
...
/usr/share/fonts/truetype/noto/NotoNaskhArabic-Bold.ttf: Noto Naskh Arabic:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
...


$ fc-list Lato:weight=black
# list the fonts, which have
# a family of Lato, and a 
# weight of black.
...
/usr/share/fonts/truetype/lato/Lato-Black.ttf: Lato,Lato Black:style=Black,Regular
/usr/share/fonts/truetype/lato/Lato-BlackItalic.ttf: Lato,Lato Black:style=Black Italic,Italic
...

Finally for fc-list, you can specify the fields to be displayed in the output, by using the names, which were described, in the xft font naming section.

$ fc-list : file family style spacing
# : will match everything.
# For the output, what we
# want to be displayed, is
# the file name, the font
# family, the font style,
# and the spacing. 
...
/usr/share/fonts/truetype/noto/NotoSerifKannada-Bold.ttf: Noto Serif Kannada:style=Bold
/usr/share/fonts/opentype/mathjax/MathJax_SansSerif-Regular.otf: MathJax_SansSerif:style=Regular
...


$ fc-list :spacing=mono  family style spacing
# List fonts which have a
# spacing of mono, and 
# show only the fields
# family, style and 
# spacing. 
...
DejaVu Sans Mono:style=Bold Oblique:spacing=100
Liberation Mono:style=Bold Italic:spacing=100
Nimbus Mono L:style=Regular:spacing=100
Courier 10 Pitch:style=Bold Italic:spacing=100
DejaVu Sans Mono:style=Oblique:spacing=100
Courier 10 Pitch:style=Italic:spacing=100
Courier 10 Pitch:style=Regular:spacing=100
Liberation Mono:style=Bold:spacing=100
MathJax_Vector:style=Regular:spacing=100
Noto Mono:style=Regular:spacing=100
Courier 10 Pitch:style=Bold:spacing=100
MathJax_Vector\-Bold:style=Bold:spacing=100
Nimbus Mono L:style=Regular Oblique:spacing=100
DejaVu Sans Mono:style=Book:spacing=100
DejaVu Sans Mono:style=Bold:spacing=100
Liberation Mono:style=Italic:spacing=100
Nimbus Mono L:style=Bold:spacing=100
Liberation Mono:style=Regular:spacing=100
...


$ fc-list :spacing=mono  -f '"%{family}" - %{style} \n'
# To specify the output format,
# you can also use, the -f option
# followed by a format specifier, 
# where what is between brackets,
# are the name discussed in the 
# xft font naming section.
...
"Liberation Mono" - Italic 
"Noto Mono" - Regular 
"MathJax_Vector" - Regular 
...

For previewing the fonts that you have installed, you can install the application gnome-font-viewer:

$ apt-get install gnome-font-viewer 
# install the gnome-font-viewer 
# application. 

And once this is done, you just right click on the font, and open it with the gnome-font-viewer app.

To specify, for an application which uses the xft stack, which font it should use, you can possibly use the -fa font_name option.

$ xterm -fa Lato &
# Specify that a font
# from the Lato font 
# family should be used.

$ xterm -fa Lato:bold &
# specify that a font
# from the Lato font
# family should be 
# used, and it should
# be a bold one.

Finally to know the font files, that an application has open, when it is using XFT, or a non X11 core font system, you can use lsof .

lsof -c firefox-esr | grep fonts
# List of files opened
# by firefox-esr , and 
# grep those which contain
# the word fonts
firefox-e 4440 difyel  mem       REG                8,1    380132  268329 /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf
firefox-e 4440 difyel  mem       REG                8,1    757076  268325 /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf


$ ps aux | grep firefox-esr
# Get the process id of 
# firefox-esr
difyel    4440  3.1 22.9 2823144 232480 ?      Sl   16:23   0:19 /usr/lib/firefox-esr/firefox-esr


$ lsof -p 4440 | grep fonts
# list the files opened, 
# by the provided process id,
# and grep those that contain
# the word fonts.
firefox-e 4440 difyel  mem       REG                8,1    380132  268329 /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf
firefox-e 4440 difyel  mem       REG                8,1    757076  268325 /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf

When an application is using X11 core, it does not itself interact with the fonts, but it is the server duty.

Resources to download and edit fonts

Usually each linux distribution will provide some fonts packages, so for example in Debian, there is a package which is called ttf-mscorefonts-installer.

This package contains some true type fonts, designed by Microsoft, such as Arial or Georgia … and which can be installed by using apt-get install ttf-mscorefonts-installer . You must make sure, to have contrib selected, under /etc/apt/sources.list .

Additionally, a lot of fonts can be found, on google fonts , and they can be downloaded, and installed, and you can convert otf fonts, to bdf fonts, by using the otf2bdf tool.

For font editing, there are multiple tools, for example fontgorge , and birdfont .

fontforge
birdfont