How do unknown fonts get substituted?

Solution 1:

I think it is decided not by Ubuntu but by the program (LibreOffice, OpenOffice etc.). I could not see anything related to LibreOffice per se but OpenOffice has a nice wiki with some details on how this "Font Fallback" works. It might be applicable to LibreOffice also, in general.

I am reproducing some sections from the wiki below for clarify. It is hard to explain better than what is in the wiki, so better to read it from there:

What is Font Fallback in OpenOffice.org 2?

Font-Fallback kicks in whenever a font is requested that is not installed on the system. (Not installed means: not available to OOo). OOo then tries to use a different font from the ones that OOo knows about that matches the requested one as close as possible.

How does Font Fallback work?

For font-fallback to produce satisfying results, OOo somehow has to know about similarities of fonts. OOo must know that it can for example substitute Helvetica in place of Arial, but not Comic Sans. This task is not as easy as it sounds, since many fonts exist and OOo cannot know about all of them.

OOo uses several ways to find a suitable replacement:

  • Font alias information provided by the system (e.g., from a fonts.dir file)
  • Hard-coded list of fallback-fonts, from VCL.xcu (tried first)
  • Alternative font name spellings
  • Font-attributes (e.g., does it have CJK-characters, is it a Symbol-font) or style (serif/non-serif, proportional/non-proportional)

if all that fails as well:

  • use a default font

Not directly related but this TLDP document is a good read.