Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Page MenuHomePhabricator

Replace Liberation 1 fonts with Liberation 2 for svg rendering
Closed, ResolvedPublic

Description

The Thumbor servers currently use fonts-liberation 1.07.4 for the Liberation font family. Liberation Serif is used as the default font for SVG rendering , but Liberation 1 doesn't always produce nice results at smaller sizes (T247567). I would suggest moving to fonts-liberation2 for thumbnail rendering. It is more actively maintained, and produces generally better results.

Test files are https://commons.wikimedia.org/wiki/File:Sea_level_history_and_projections.svg at 270px.

Liberation Sans 1

wmf270px-Sea_level_history_and_projections.svg.png (203×270 px, 14 KB)

Liberation Sans 2

lib2270px-Sea_level_history_and_projections.svg.png (203×270 px, 15 KB)

Event Timeline

herron triaged this task as Medium priority.Jul 27 2020, 8:20 PM

Change 728568 had a related patch set uploaded (by AntiCompositeNumber; author: AntiCompositeNumber):

[operations/puppet@production] mediawiki::packages::fonts: replace fonts-liberation with fonts-liberation2

https://gerrit.wikimedia.org/r/728568

@AntiCompositeNumber does this merit a User-notice ahead of time or is it subtle enough that people won't notice?

On stretch and buster, I see liberation2 installing:

/usr/share/fonts/truetype/liberation2/LiberationMono-Bold.ttf
/usr/share/fonts/truetype/liberation2/LiberationMono-BoldItalic.ttf
/usr/share/fonts/truetype/liberation2/LiberationMono-Italic.ttf
/usr/share/fonts/truetype/liberation2/LiberationMono-Regular.ttf
/usr/share/fonts/truetype/liberation2/LiberationSans-Bold.ttf
/usr/share/fonts/truetype/liberation2/LiberationSans-BoldItalic.ttf
/usr/share/fonts/truetype/liberation2/LiberationSans-Italic.ttf
/usr/share/fonts/truetype/liberation2/LiberationSans-Regular.ttf
/usr/share/fonts/truetype/liberation2/LiberationSerif-Bold.ttf
/usr/share/fonts/truetype/liberation2/LiberationSerif-BoldItalic.ttf
/usr/share/fonts/truetype/liberation2/LiberationSerif-Italic.ttf
/usr/share/fonts/truetype/liberation2/LiberationSerif-Regular.ttf

liberation1 installs:

/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf
/usr/share/fonts/truetype/liberation/LiberationMono-BoldItalic.ttf
/usr/share/fonts/truetype/liberation/LiberationMono-Italic.ttf
/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf
/usr/share/fonts/truetype/liberation/LiberationSans-Bold.ttf
/usr/share/fonts/truetype/liberation/LiberationSans-BoldItalic.ttf
/usr/share/fonts/truetype/liberation/LiberationSans-Italic.ttf
/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Bold.ttf
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-BoldItalic.ttf
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Italic.ttf
/usr/share/fonts/truetype/liberation/LiberationSansNarrow-Regular.ttf
/usr/share/fonts/truetype/liberation/LiberationSerif-Bold.ttf
/usr/share/fonts/truetype/liberation/LiberationSerif-BoldItalic.ttf
/usr/share/fonts/truetype/liberation/LiberationSerif-Italic.ttf
/usr/share/fonts/truetype/liberation/LiberationSerif-Regular.ttf

So we'd be losing all the LiberationSansNarrow variants - is that OK?

From https://github.com/liberationfonts/liberation-sans-narrow#current-release:

Note: 2.00.0 onward releases does not includes Liberation Sans Narrow font due to licensing problems. Please refer to older releases for Liberation Sans Narrow font.

(Liberation 1 is under a modified GPL license)

There is no 2.0 version of Liberation Sans Narrow. It was moved to a separate repository in 1.07.5, but Debian has not updated from 1.07.4 and does not package it separately. I don't know if that's intentional to avoid the split or if it's just due to lack of maintenance for the v1 package.

As I mentioned on Gerrit, I don't see anything in fontconfig's documentation that would cause it to consistently select Liberation 2 fonts over Liberation 1 fonts.

The canonical font pattern is finally matched against all available fonts. The distance from the pattern to the font is measured for each of several properties: foundry, charset, family, lang, spacing, pixelsize, style, slant, weight, antialias, rasterizer and outline. This list is in priority order -- results of comparing earlier elements of this list weigh more heavily than later elements.

All of those properties are the same between the two fonts (except liberation 2 supports more languages). The only changes I see in fc-match -s Liberation -v are in fontversion and charset. Looking at https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/src/fcmatch.c#L315-352, it appears that fontversion is actually compared when matching fonts, it's just undocumented 🙄.

I don't think it's worth the hassle of creating a separate package for Liberation Sans Narrow ourselves. There's no good way (outside curl | greping a few hundred GB of SVG files) to determine if the narrow fonts are in use, so I think the better option is to keep fonts-liberation installed and hope fontconfig matches the fonts consistently. If Debian ever splits the package we can switch then.


As far as User-notice goes, I'm not sure. I only found one previous example of SVG font changes being included (in 2014) but I also wouldn't be surprised if someone filed a task in a week saying "why are the fonts different in different sized thumbnails of my SVG". I'm happy to let the Tech News editors make that decision though.

  • The version of the Liberation fonts used in SVG files will be upgraded. Only new thumbnails will be affected. Liberation Sans Narrow will not change.

Notes:

  • New thumbnails means all thumbnails of new files, all thumbnails of new versions of files, thumbnails of old files that had not been previously generated at that width, and thumbnails of files purged with ?action=purge (usually).
  • Users can't switch back to the old fonts.
  • Thumbor SVG rendering is the only thing I know this affects. The only other service that used this font list was Graphoid. I don't know if MediaWiki uses them for anything.
  • The change is most visible at thumbnail sizes (usually 200-500px).

Do you know when this would be in production, or is it too early to tell?

Hi @AntiCompositeNumber. If I understand correctly, this should be included in the next issue of Tech News (going out Monday) within the "Future changes" section? Please confirm. And thank you for supplying the suggested text!

Hi @AntiCompositeNumber. If I understand correctly, this should be included in the next issue of Tech News (going out Monday) within the "Future changes" section? Please confirm. And thank you for supplying the suggested text!

Yes please. I set a reminder to merge the puppet change on Tuesday.

Change 728568 merged by Legoktm:

[operations/puppet@production] mediawiki::packages::fonts: replace fonts-liberation with fonts-liberation2

https://gerrit.wikimedia.org/r/728568

This update might trigged a difference in rendering between SVG-check vs Commons-Rendering, see T335415 (not only the font is different also the alignment is different on small thumbnails)