Bug 64509 - CONFIGURATION: Enhance Font Substitution Table
Summary: CONFIGURATION: Enhance Font Substitution Table
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Installation (show other bugs)
Version:
(earliest affected)
4.0.3.3 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
: 109525 (view as bug list)
Depends on:
Blocks: Font-Substitution
  Show dependency treegraph
 
Reported: 2013-05-12 21:10 UTC by João Paulo
Modified: 2019-06-12 06:42 UTC (History)
11 users (show)

See Also:
Crash report or crash signature:


Attachments
vcl.xcu partial patch (336.01 KB, patch)
2015-09-04 08:08 UTC, João Paulo
Details
Personal LO replacement table (68.99 KB, image/jpeg)
2018-12-26 12:40 UTC, Timur
Details

Note You need to log in before you can comment on or make changes to this bug.
Description João Paulo 2013-05-12 21:10:37 UTC
Problem description: 

There are many fonts in existence, yet one's system doesn't have it all installed.

There are fonts which originated from real world types (digitized fonts), but each type designer or foundry made it differently from each other.

They are the so called fonts variations, as Adobe Caslon (Carol Twombly based on William Caslon's specimens pages), and ITC Founder's Caslon (digitized by Justin Howes, based on  resources of the St. Bride Printing Library).

And there are fonts whose types originated on the virtual world (virtual typefaces), even if the initial drawings were made on paper. These fonts could have been abandoned by their designers or foundries, but adopted by others; they could have been licensed in such a way the name of the font should be changed; or they could have intended variations for each script so to avoid software issues.

The primary examples for the first case are the TeX GYRE Collection of Fonts (Bonum, Chorus, Cursor, Heros, Pagella, Schola, Termes are all based, respectively, on URW Gothic L, URW Bookman L, URW Chancery L Medium Italic, URW Nimbus Mono L - itself based on IBM's Courier, URW Nimbus Sans - itself based on Helvetica, URW Palladio L, URW Century Schoolbook L, Nimbus Roman No9 L - itself based on Times); for the second case we have the BitStream Vera and DejaVu families of fonts; and for the latter we have the DejaVu and DejaVu LGC (which contains only Latin, Greek, and Cyrillic characters, instead of Chinese, Japanese, Korean and Arabic characters).

To ease the life of many users not typographic savvy, LibreOffice should have a preinstalled font substitution table, at the same time it should indicate when the fonts needed to render a file isn't installed on the system (such as a warning when opening it).

Steps to reproduce:

1. Create a document on a machine which has, for example, the Calligraffiti font installed (a calligraphic font available for free at http://www.fontsquirrel.com/fonts/calligraffiti), and format it to use the font.
2. Send it to another user who doesn't have the font (or just uninstall the font from the system).
3. Open the file on a system without the font.

Current behavior:

LibreOffice doesn't show any messages the font specified on the file doesn't exist on the system; worse, it shows the name of the font on the toolbar and presents it as the sans serif font DejaVu Sans.

Expected behavior:

LibreOffice should warn the user that because the Calligraffiti font isn't available on the system it will use <font name> on its place.

And for the well known families of fonts which have been substituted, such as the TeX GYRE Fonts (http://www.gust.org.pl/projects-1/e-foundry/tex-gyre), LibreOffice could have it prepopulated on the font substitution table.
Operating System: All
Version: unspecified
Comment 1 Julien Nabet 2013-05-18 06:46:46 UTC Comment hidden (obsolete)
Comment 2 João Paulo 2013-05-19 16:36:37 UTC
(In reply to comment #1)
> What's your LO version? on which env are you?

I am running LibreOffice 4.0.3.3 on Windows XP and Vista, but I found this behavior on every LO release since the fork from OpenOffice.org, and also on every OOo release I used then.
Comment 3 João Paulo 2013-05-19 16:43:32 UTC
Maybe I should create another bug for the lack of warning when the font isn't installed on the user's system? Because I realized I reported two bugs:
- the lack of a prepopulated font substitution table (installation issue);
- the lack of a warning the font isn't installed nor substituted (UI issue).
Comment 4 João Paulo 2013-05-19 16:57:20 UTC
I created a small table for well known fonts (and the Lobster font):

Lobster				Lobster Two

Bitstream Vera Sans		DejaVu Sans
Bitstream Vera Sans Mono	DejaVu Sans Mono
Bitstream Vera Serif		DejaVu Serif

CenturySchL			TeXGyreSchola
NimbusMonL			TeXGyreCursor
NimbusMono			TeXGyreCursor
NimbusRomanNo9			TeXGyreTermes
NimbusRomNo9L			TeXGyreTermes
NimbusSanL			TeXGyreHeros
NimbusSanLCon			TeXGyreHerosCn
URWBookmanL			TeX Gyre Bonum
URWChanceryLMed			TeXGyreChorus
URWGothicL			TeXGyreAdventor
URWGothicLDem			TeXGyreAdventor
URWPalladioL			TeXGyrePagella

And a small table for fonts that always should be substituted, regardless of having the font on the system (the "G" versions have Graphite enabled, so its rendering is better):

Linux Biolinum			Linux Biolinum G
Linux Libertine			Linux Libertine G
Comment 5 Julien Nabet 2013-05-20 17:04:36 UTC
On pc Debian x86-64 with master sources updated today, I reproduced the problem.

Caolán: one for you?
Comment 6 Caolán McNamara 2013-06-05 16:17:20 UTC
re "not reporting the font is not installed and is being substituted"

in 4.1 the font name is italicized in the font selectors if it's not installed, so that's fixed now.

re "having a substitution table", so...

for most Unix platforms e.g Linux we run the font through fontconfig which has a pile of rules and tables to give the best replacement font. So on those platforms this is "taken care of", and on MacOSX there's a similar built-in MacOSX thing I believe.

The remaining issue is Windows, there we use our built-in tables in registry/data/org/openoffice/VCL.xcu (http://opengrok.libreoffice.org/xref/core/officecfg/registry/data/org/openoffice/VCL.xcu) see near the end, the section starting with <node oor:name="FontSubstitutions"> so we should already have the bitstreamverasans replacements for example.

It shouldn't be too hard to add to add extra entries or improve the existing ones. Not something for me though, seeing as it doesn't affect the platform I develop on.

I suggest you have a go at adding what entries are missing there from your own list and submit the result to us. See https://wiki.documentfoundation.org/Development/Patch_Handling_Guidelines for some help.
Comment 7 QA Administrators 2015-03-16 23:40:22 UTC Comment hidden (obsolete)
Comment 8 João Paulo 2015-06-08 05:51:53 UTC Comment hidden (no-value)
Comment 9 João Paulo 2015-09-04 04:54:08 UTC
Just recently found (via Google) the page https://wiki.documentfoundation.org/LibreOffice_Localization_Guide/Advanced_Source_Code_Modifications with some instructions on how to edit vcl.xcu. I will try it this weekend.
Comment 10 João Paulo 2015-09-04 08:08:58 UTC
Created attachment 118408 [details]
vcl.xcu partial patch

Partial patch containing extra font substitutions for the following fonts:

- Lobster -> Lobster Two
- Utopia <-> Heuristica

(these were added to other places as well)
- CenturySchL <-> TeXGyreSchola
- NimbusMonL <-> TeXGyreCursor
- NimbusMono <-> TeXGyreCursor

Bitstream Vera and DejaVu font families weren't altered, as they were already there.

More will be added with time. Please test this patch.
Comment 11 Timur 2016-09-21 07:39:02 UTC
Reading Comment 6 here and the similar https://bugs.documentfoundation.org/show_bug.cgi?id=91004#c7, I understand that Linux (and Mac) first runs fontconfig and Windows first runs Font Substitution Table. 
If it so, Help should be amended to clarify that priority: https://help.libreoffice.org/index.php?title=5.1/Common/Fonts&Language=en-US
Before I open a new bug, please confirm.
Comment 12 QA Administrators 2017-10-23 13:59:07 UTC Comment hidden (obsolete)
Comment 13 João Paulo 2017-11-06 16:14:31 UTC
On Comment #10 I made a partial patch enabling font substitutions of fonts I know are drop-in replacements. However, I don't know how to add the patch to LibreOffice: I'm no developer, just an advanced user with configuration and script skills.

Could someone please add the patch to the source code?

Also, answering to Comment #12, this is not a bug, but an enhancement request.
Comment 14 Yousuf Philips (jay) (retired) 2017-11-06 22:54:23 UTC
(In reply to João Paulo from comment #13)
> On Comment #10 I made a partial patch enabling font substitutions of fonts I
> know are drop-in replacements. However, I don't know how to add the patch to
> LibreOffice: I'm no developer, just an advanced user with configuration and
> script skills.

If you would like to send in your patch, you can follow instructions here to learn how to do so.

https://wiki.documentfoundation.org/Development/gerrit

> Could someone please add the patch to the source code?

Unfortunately the file has been modified since your patch, so i cant identify just the changes you have made, but if you can grab the latest version of the file below[1] and make the changes, i could push it in on your behalf if you add yourself to the contributor's list[2].

[1] https://cgit.freedesktop.org/libreoffice/core/plain/officecfg/registry/data/org/openoffice/VCL.xcu
[2] https://wiki.documentfoundation.org/Development/Developers

> Also, answering to Comment #12, this is not a bug, but an enhancement
> request.

I've change the bug type to enhancement.
Comment 15 Ulrich Windl 2018-03-06 07:16:35 UTC
The problem with a font substitution table is that, while fonts are similar, they are not the same. Even if the glyphs look identical, there my be significant differences in kerning information.
So what the use typically sees if a font is missing and was substituted, is an ugly or broken layout (caused by different kerning, character spacing, or line spacing). (You can see this effect in PDFs also where the kerning information is basically hard-coded (glyphs positioned absolutely), but the fonts can be missing.)
My personal preference over a manually edited (and probably huge) font substitution table is using typeface information (like PANOSE (https://en.wikipedia.org/wiki/PANOSE)) to find ou which fonts are similar to each other. I don't know whether Windows or other OSes support it, but I remember that Smalltalk-80 had it in the 80ies ;-) Of course the usefulness of typeface metadata depend on its accuracy. If people just copy it blindly from another font, it will be hardly useful...
Comment 16 Timur 2018-12-25 18:13:01 UTC
*** Bug 109525 has been marked as a duplicate of this bug. ***
Comment 17 Timur 2018-12-26 12:40:00 UTC
Created attachment 147835 [details]
Personal LO replacement table

I attach personal LO replacement table. Not claiming it's proper. But we should have this updated.