Return to Video

Linux Font Rendering Stack

  • Not Synced
    Okay, good morning everyone.
  • Not Synced
    I'm going to talk about the
    Linux Font Rendering stack,
  • Not Synced
    and that is what I learned the last
    four and a half years.
  • Not Synced
    I worked at the
    city administration of Munich.
  • Not Synced
    For introduction to font rendering,
  • Not Synced
    I can say writing is
    the most used interface,
  • Not Synced
    or probably the most used interface
    between humans and the machines.
  • Not Synced
    So all of you probably use it everyday
    on your computer.
  • Not Synced
    Screen text is replacing text on paper
    more and more
  • Not Synced
    and this is still an ongoing process.
  • Not Synced
    The way from a string in a computer to
    display text is surprisingly complex,
  • Not Synced
    And writing in itself is quite profound.
  • Not Synced
    For example, it's influenced by history
    so probably all, or at least most,
  • Not Synced
    writing systems are derived from some
    pictograph writing systems.
  • Not Synced
    This is also true for Roman letters.
  • Not Synced
    And also the Roman letters themselves,
    they changed a lot since 2000 years ago.
  • Not Synced
    In the Roman Empire they used some
    different letters than we use now.
  • Not Synced
    So the goal of this talk is to raise
    awareness of font rendering in computing,
  • Not Synced
    with the focus on the Linux desktop.
  • Not Synced
    Now to the history,
    and then I talk about typography.
  • Not Synced
    Text display in early computing.
  • Not Synced
    In early computing it was just
    a way to display results.
  • Not Synced
    Before that there were
    only flashing lights
  • Not Synced
    where you can read the results
    and...
  • Not Synced
    [audience member] ??... BT100
    ?? raise your hand
  • Not Synced
    [Max] And the output device receives
    a page or a character stream,
  • Not Synced
    and then the presentation is the job
    of the output device.
  • Not Synced
    So for example, a typewriter
    or a printer or a terminal.
  • Not Synced
    And this is a BT100
    you can see on the right side.
  • Not Synced
    So this is a real terminal.
  • Not Synced
    But going on in history
    there's the home computer era.
  • Not Synced
    In the home computer era you have
    fixed character sets
  • Not Synced
    and most of the time due to system
    limiatations, memory limitations,
  • Not Synced
    you have graphics mode and text mode.
  • Not Synced
    In the graphics mode you can basically
    set the pixels more or less as you want,
  • Not Synced
    and in the text mode you can use fonts.
  • Not Synced
    The screen configuration at that time
    is more or less defined
  • Not Synced
    by the state of technology.
  • Not Synced
    So every screen at that time has more or
    less the same resolution,
  • Not Synced
    and that's something that the engineers
    of that time relied on,
  • Not Synced
    and also software engineers relied on.
  • Not Synced
    The text rendering was just
    using bitmap fonts.
  • Not Synced
    That means you have a fixed size character
    and you just define it pixelwise
  • Not Synced
    so it's some kind of hand-crafted
    characters.
  • Not Synced
    You have a given raster and then
    you really display
  • Not Synced
    these hard-defined characters.
  • Not Synced
    So then I need to introduce a few
    typography terms.
  • Not Synced
    First, there's glyph or a character.
  • Not Synced
    That's...well you can say a symbol.
  • Not Synced
    So I think most people can understand what
    that means.
  • Not Synced
    Then a font, this is a set of glyphs.
  • Not Synced
    And then we have a collection of fonts,
    that is called typeface or font family.
  • Not Synced
    Those are closely related fonts with
    the same visual appearance,
  • Not Synced
    And they differ only in slopes or widths
    or weights for example.
  • Not Synced
    Usually with typesetting, with moving
    letters in the printing press,
  • Not Synced
    you really had, for weight for example,
    different pieces/letters/hardware.
  • Not Synced
    And then the point size,
    or typographic unit.
  • Not Synced
    This is a measure of the size, and
    derives directly from the printing press
  • Not Synced
    with moving letters.
  • Not Synced
    There are different definitions, and what
    we probably all use as point size is the
  • Not Synced
    DTP point – desktop publishing point,
  • Not Synced
    where one point is defined as 1/72 inch,
    which is 0.3527 period millimeters.
  • Not Synced
    It is interesting to note that this has
    nothing to do with pixels.
  • Not Synced
    [Audience Member] (unintelligible question)
  • Not Synced
    [Max] Please use the microphone
    if you a question.
  • Not Synced
    [Audience Member] ...3257, what's the bar
    over the 7 mean?
  • Not Synced
    [Max] It means that the 7 goes
    on and on and on forever.
  • Not Synced
    So this is typography of the
    Latin alphabet...terminology.
  • Not Synced
    There's something called kerning.
  • Not Synced
    You can see an example of kerning
    on the right side.
  • Not Synced
    So in the printing press you have letters
    and they usually have a gap.
  • Not Synced
    To improve the readability, and to
    make all the text appear more uniform
  • Not Synced
    the typesetter reduces the gap.
  • Not Synced
    With moving letters they have special
    letter pairs...
  • Not Synced
    if you go on with this
    there are ligatures,
  • Not Synced
    which are replacement glyphs for close
    standing characters.
  • Not Synced
    An example of this is a double f, fi or fl.
  • Not Synced
    So you can see also in the slides here
    that double f is such a ligature.
  • Not Synced
    It's one connected glyph.
  • Not Synced
    And then there's a speciality
    if you reverse all of the ?? [static].
  • Not Synced
    The term non-proportional font.
  • Not Synced
    So you have a font where very character,
    every glyph, has the same width.
  • Not Synced
    This is also called monospace font.
  • Not Synced
    Sometimes you distinguish half-width
    and full width letters.
  • Not Synced
    This is also something you would see
    on a typewriter for example.
  • Not Synced
    Early bitmap fonts are usually
    monospaced fonts.
  • Not Synced
    Okay, let's go to
    the text rendering stack.
  • Not Synced
    Text rendering today.
  • Not Synced
    In all computing nowadays,
    typography is introduced.
  • Not Synced
    So won't find many devices on the market
    which don't use accurate typography.
  • Not Synced
    Glyphs are now represented as
    size-independent outlines.
  • Not Synced
    We can see on the right side there's
    a font editor: Font Forge.
  • Not Synced
    This is the way that such fonts
    are created.
  • Not Synced
    So you can see here in the picture
    the outline of the "S".
  • Not Synced
    It's a size-independent outline and
    you can just use that for
  • Not Synced
    every kind of display.
  • Not Synced
    And then you do something that is called
    rasterization, or sampling, or rendering
  • Not Synced
    for displaying it at the actual display.
  • Not Synced
    In the past this allowed for new
    applications for computers.
  • Not Synced
    First it allowed word processing and
    computer-based typesetting.
  • Not Synced
    Before that typesetting was
    a very hard job.
  • Not Synced
    It allowed internationalization.
  • Not Synced
    It allows universal graphical interface
    which goes
  • Not Synced
    hand-in-hand with internationalization.
  • Not Synced
    Come to think of it, not so long ago it
    was not so common that you could
  • Not Synced
    buy devices where you can easily switch
    the language to
  • Not Synced
    any language you would like.
  • Not Synced
    This is just a recent development.
  • Not Synced
    So now I will give you an overview of
    the formats we see on Linux systems.
  • Not Synced
    First I talk about the bitmap formats.
  • Not Synced
    Today we have bitmap formats in the
    PC Screen Font format,
  • Not Synced
    PSF or PSFU.
  • Not Synced
    These are the fonts that are used for the
    Linux VT, also known as the console.
  • Not Synced
    Usually you can store in such a font
    256 or 512 glyphs.
  • Not Synced
    Some of them contain
    a Unicode translation table.
  • Not Synced
    And on the other hand there are
    X Window System Bitmap Fonts.
  • Not Synced
    There are three formats:
  • Not Synced
    There's a Sever normal Format (SNF).
  • Not Synced
    Glyph Bitmap Distribution Format (BDF).
  • Not Synced
    And Portable Compiled Format (PCF).
  • Not Synced
    Nowadays PCF is the only letter that
    you can find on a Linux system if so,
  • Not Synced
    and the first two are deprecated.
  • Not Synced
    And also the X Window Bitmap Fonts
    themselves are not very common these days.
  • Not Synced
    To the outline font formats.
  • Not Synced
    There are Postscript Formats.
  • Not Synced
    Postscript Formats have different versions
    as I would call them. It's called types.
  • Not Synced
    Type 1 is the one that is still relevant,
    to a certain degree.
  • Not Synced
    Those are the ones you can probably
  • Not Synced
    find on a standard Debian installation
    for example.
  • Not Synced
    It uses cubic bezier curves.
  • Not Synced
    The file format is divided into
    different files.
  • Not Synced
    So for every font you have
    Printer Font ASCII
  • Not Synced
    or a Printer Font Binary file,
    and you have
  • Not Synced
    a Print Font Metric or
    Adobe Font Metric file.
  • Not Synced
    Then you have the Truetype file format.
  • Not Synced
    This is more common. I guess everyone
    heard of that already.
  • Not Synced
    It uses quadratic bezier curves.
  • Not Synced
    It can contain optional code for
    TrueType Hinting Virtual Machine.
  • Not Synced
    What that means I will explain latter.
  • Not Synced
    There's a third format,
    the OpenType format,
  • Not Synced
    which has two possible glyph formats:
    one is truetype,
  • Not Synced
    and the other is Compact Font Format,
    which is based on Postscript Type 2.
  • Not Synced
    So you can say what is new in this format,
    or what's the difference?
  • Not Synced
    Well it supports so-called Smartfonts.
  • Not Synced
    That means you can have language-specific
    ligatures or character substitutions.
  • Not Synced
    For example, kerning classes, which means
    you have a class of characters like
  • Not Synced
    the A and different variations.
  • Not Synced
    So these are A with different diacritic
    symbols,
  • Not Synced
    and you can just use one kerning class for
    all of those characters and don't have to
  • Not Synced
    invent the wheel for every A with
    diacritic symbols anew.
  • Not Synced
    Now to the font rendering techniques that
    I use today.
  • Not Synced
    This only applies to the outline fonts
    because well rendering bitmap fonts is
  • Not Synced
    obviously quite easy. You just paint the
    pixels that are in the bitmap.
  • Not Synced
    So rasterization is all about using
    outline fonts.
  • Not Synced
    The one library library that is used all
    over the free and open source world
  • Not Synced
    is FreeType.
  • Not Synced
    It is used on Linux system, BSD desktops,
    Android, and ReactOS, and also some others.
  • Not Synced
    For example it is contained in Ghostscript
    and therefore in most of the printers.
  • Not Synced
    It's also on iOS [exhale].
  • Not Synced
    So the naive rasterization algorithm would
    be just lay a pixel raster over the outline,
  • Not Synced
    over the character you want to display,
    and if the center of the pixel is inside
  • Not Synced
    the outline then you
    set the color to black.
  • Not Synced
    The problem is the so called
    aliasing effect.
  • Not Synced
    This is what you can see
    in the picture below.
  • Not Synced
    So those are the same words,
    rendered at different resolutions.
  • Not Synced
    The left one has 10x the resolution
    of the right one.
  • Not Synced
    You can see that, for example,
    the 'w' is quite deformed.
  • Not Synced
    Or the curl of the 'g';
    there's even a part missing.
  • Not Synced
    So you have details of the font
    which are lost,
  • Not Synced
    and you have artefacts.
  • Not Synced
    Somehow, especially in the early computing
    days you wanted to reduce those,
  • Not Synced
    and therefore you used a technique
    called hinting.
  • Not Synced
    This is to avoid such artefacts and
    improve the readability
  • Not Synced
    at lower resolutions.
  • Not Synced
    Therefore the outline adjusted to fit the
    pixel raster at the rasterization.
  • Not Synced
    Some of the fonts can contain
    instructions, the so-called hints
  • Not Synced
    where the the name comes from.
  • Not Synced
    You can see in the example here,
    in the picture above,
  • Not Synced
    that it's quite a good result.
  • Not Synced
    This is much more readable
    than the word above.
  • Not Synced
    However, with the use of hinting, there
    are also characteristics of the font lost
  • Not Synced
    which is obvious because
    if you change the outline
  • Not Synced
    then obviously characteristics get lost.
  • Not Synced
    And especially important for
    word processing,
  • Not Synced
    what you see is what you get
    word processing,
  • Not Synced
    that the tracking of the font is changed.
  • Not Synced
    So tracking means the width
    of single characters.
  • Not Synced
    The picture below, this is a picture I
    took from LibreOffice.
  • Not Synced
    If you have a close look, you can see
    that the gap between those 'i' characters
  • Not Synced
    is not always the same.
  • Not Synced
    But if do word processing, you actually
    want to have a result which looks the same
  • Not Synced
    as on the printout.
  • Not Synced
    So I would recommend no
    to hint fonts in
  • Not Synced
    a what you see is what you get
    word processor.
  • Not Synced
    If you have a look beyond the backyard,
    on macOS, there exists no hinting,
  • Not Synced
    and in the Windows world, hint can't
    be turned off,
  • Not Synced
    so this is hardwired in the
    font rendering of the Windows system.
  • Not Synced
    Well anther approach to improve
    readability is anti-aliasing
  • Not Synced
    which applies multisampling.
  • Not Synced
    So for every pixel you take samples at
    different spots
  • Not Synced
    and then you compute from
    that a gray value,
  • Not Synced
    which is a measure of how much of the
    area of the pixel is covered by the glyph.
  • Not Synced
    On the picture you can see again
    the simple raster word,
  • Not Synced
    and then in the middle you see the word
    with anti-alising,
  • Not Synced
    and below you can see a combination of
    hinting and antialiasing.
  • Not Synced
    Suddenly the text becomes very readable
    also on low resolutions.
  • Not Synced
    This is what is usually used in
    computing in the 90s.
  • Not Synced
    So there is another approach to improve
    and therefore I have to
  • Not Synced
    talk a bit about LCD displays.
  • Not Synced
    So in the picture on the left, above you
    can see tube monitor pixels and
  • Not Synced
    on the bottom you can see
    LCD monitor pixels.
  • Not Synced
    All of the pixels consist of so-called
    subpixels with different colors.
  • Not Synced
    The mixture of the three different colors
  • Not Synced
    gives them a wide range
    of different colors.
  • Not Synced
    With the tube monitors this is not used,
    but with LCD display
  • Not Synced
    depending on the
    configuration of the subpixels
  • Not Synced
    it can be used to improve improve the
    resolution in one direction.
  • Not Synced
    Therefore you have to know how the
    configuration of the display is.
  • Not Synced
    So usually, one pixel, which you can see
    in the picture below right?
  • Not Synced
    These are the usual computer monitors.
  • Not Synced
    One pixel consists of a red, green and a
    blue subpixel in this order.
  • Not Synced
    But you have to keep in mind, especially
    with tablets, or smartphones,
  • Not Synced
    you can rotate the screen, so you have to
    keep that in mind.
  • Not Synced
    Also there are other subpixel
    configurations.
  • Not Synced
    For example, depending on the technology
    there can be additional red or green
  • Not Synced
    or even white subpixels.
  • Not Synced
    So there are also multiple possibilities
    of the configuration.
  • Not Synced
    We can use this configuration as I said
    to improve the resolution
  • Not Synced
    and in the usual case
    this is horizontally.
  • Not Synced
    You can see on the picture
    on the left side,
  • Not Synced
    first there's the naive,
    simple rendered character,
  • Not Synced
    then the character
    just using anti-aliasing,
  • Not Synced
    and then there's the
    subpixel rendered character.
  • Not Synced
    This one is the most readable
    or most sharp character.
  • Not Synced
    Not sharp!... but it's most correctly
    rendered according to the outline font.
  • Not Synced
    Depending on the technique of the display,
  • Not Synced
    you can see a color haze
    around the characters.
  • Not Synced
    So this happens when the software
    and the display technology
  • Not Synced
    don't match each other.
  • Not Synced
    So this is what you can see
    on the picture on the right.
  • Not Synced
    Okay, let's talk about the font rendering
    software parts in the Linux desktop.
  • Not Synced
    There's the so-called server-side
    text rendering.
  • Not Synced
    So in the X server there's the
    Core Font subsystem.
  • Not Synced
    With that, X11 clients can request the
    server to display a text
  • Not Synced
    by sending a string via libXfont
  • Not Synced
    and using the so-called
    X Logical Font Description (XLFD).
  • Not Synced
    Here's an example for Adobe Career font,
  • Not Synced
    then the X server has to then
    render the text using the font.
  • Not Synced
    If you imagine a terminal server setup
    with thin clients,
  • Not Synced
    then the thin client runs the X server
    and the terminal server runs the X client
  • Not Synced
    and every thin client then has to
    handle the font rendering.
  • Not Synced
    So I don't know if
    this is the only reason,
  • Not Synced
    but nowadays server-side font
    rendering is not so common.
  • Not Synced
    Probably not used anymore.
  • Not Synced
    Now I have to talk first
    about font management.
  • Not Synced
    In Linux systems there is
    a software called fontconfig,
  • Not Synced
    which manages installed fonts
    on the system
  • Not Synced
    and it configures for example how to
    substitute fonts.
  • Not Synced
    For example if in a document there's a
    font to render a text
  • Not Synced
    and the font is not
    available on the system
  • Not Synced
    then in the font config system there can
    be rules to replace the font
  • Not Synced
    with a similar font.
  • Not Synced
    This is heavily used in Linux systems.
  • Not Synced
    There are also rules for what font to
    use if the current selected font
  • Not Synced
    doesn't contain a character
    you want to display.
  • Not Synced
    You can see on the picture on the right
    that this is also used...
  • Not Synced
    although I have to admit,
  • Not Synced
    I had to take this picture on a Debian 5.0
    system in LibreOffice
  • Not Synced
    because nowadays
    it works a bit different,
  • Not Synced
    but this is a good example where
    you can see that those characters
  • Not Synced
    come from different fonts actually.
  • Not Synced
    There's also a command line tool
    which is quite nice.
  • Not Synced
    fc-match command line tool.
  • Not Synced
    So for example if you want to see what is
    the replacement font for, let's say, Arial
  • Not Synced
    then you get the output:
    okay, it's Nimbus Sans.
  • Not Synced
    And you can also set rendering options,
  • Not Synced
    which means you can set anti-aliasing
    or you can turn off hinting.
  • Not Synced
    Usually these configurations are stored in
    /etc/fonts
  • Not Synced
    and there is also a per-user configuration
    in .config/fontconfig
  • Not Synced
    and it's in XML file format snippets.
  • Not Synced
    In the picture you can see an example.
  • Not Synced
    This is the replacement rule for
    Carlito and Calibri.
  • Not Synced
    Carlito is a replacement font for the
    nowadays often used
  • Not Synced
    Calibri font from Microsoft.
  • Not Synced
    So this configuration says the one way,
    Carlito is the same as Calibri,
  • Not Synced
    and the other way around.
  • Not Synced
    This is just an example,
  • Not Synced
    you can have a look at /etc/fonts
    and a lot of such snippets.
  • Not Synced
    It defines how fonts are
    displayed on the system.
  • Not Synced
    Another thing, and this is the reason
    why I had to take the screenshot
  • Not Synced
    on an older system, there's a piece of
    software called HarfBuzz.
  • Not Synced
    HarfBuzz is Persian for OpenType,
  • Not Synced
    so this software relies on the OpenType
    font format.
  • Not Synced
    You can see on the right side
    the HarfBuzz logo
  • Not Synced
    that actually says
    HarfBuzz in Persian.
  • Not Synced
    Before I talked about ligatures,
  • Not Synced
    In some languages ligatures are required
    to render fonts correctly
  • Not Synced
    and this is an example on the left of
    Devanagari, which is an Indic script.
  • Not Synced
    So if you have the first two characters
    combined then this is the rule
  • Not Synced
    of how to replace those characters
    with a third glyph.
  • Not Synced
    There were early implementations
    by Qt for Pangul
  • Not Synced
    and those were integrated in HarfBuzz.
  • Not Synced
    Well those parts are now known as
    Harfbuzz Old,
  • Not Synced
    and the current HarfBuzz is a rewrite.
  • Not Synced
    Nowaday's it's also used for
    the so-called simple script,
  • Not Synced
    meaning especially Latin script,
  • Not Synced
    and is integrated into Qt, GTK,
    LibreOffice, Firefox, Android, and XETEX.
  • Not Synced
    This is what I use for the slides here,
  • Not Synced
    so all the slides here are
    also rendered using HarfBuzz.
  • Not Synced
    And of course the whole
    font rendering stack.
  • Not Synced
    HarfBuzz also has fancy features like
    variable widths or weight
  • Not Synced
    with only one font or you can define
    in the font characters with
  • Not Synced
    variable widths and without stepping you
    can change it using HarfBuzz.
  • Not Synced
    Those techniques are used in
    client-side rendering.
  • Not Synced
    One library often was
    until recently often used, Xft.
Title:
Linux Font Rendering Stack
Description:

Displaying text is the most common interface to convey information from computer systems to humans. On a Linux system there is a variety of techniques for rendering text some of which are used more or less on modern systems. Many of those text rendering techniques originate from different time periods of computing history and rendering text in graphical environments is more complex than often thought off.

We find two approaches in Linux systems for displaying text: - using bitmap fonts designed for fixed resolution displays - rendering text based on scalable glyph shapes using a stack of software components for rasterisation, text shaping and text layout.

This talk will give an overview on the different techniques, software and standards for font rendering on Linux systems in the context of their historical origins.

Speaker: Max Harmathy
At: DebConf18

more » « less
Video Language:
English
Team:
Debconf
Project:
2018_debconf18
Duration:
43:31

English subtitles

Revisions Compare revisions