Fallback fonts in snap package are not the same as apt package
Categories
(Firefox Build System :: Third Party Packaging, defect)
Tracking
(Not tracked)
People
(Reporter: rahul.siddharthan, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0
Steps to reproduce:
My setup is Firefox 99.0.1 snap on Ubuntu 22.04 Jammy. I filed an Ubuntu bug but they said the firefox snap is from upstream and sent me here.
I opened http://www.wormbook.org/chapters/www_intromethodscellbiology/intromethodscellbiology.pdf and the fonts are wrong and spacing is ugly.
Over on reddit people suggested disabling use document fonts (browser.display.use_document_fonts=0) and that fixed it; but for html pages it uses the wrong fonts then.
Also on reddit, someone said reproducible in a Ubuntu VM; someone else said, not reproducible on Linux Mint, which is based on Ubuntu but doesn't use snaps.
Actual results:
Ugly fonts. Results in first image here
https://www.reddit.com/r/firefox/comments/uhz6d1/continued_messedup_font_rendering_in_firefox_pdf/
Expected results:
Beautiful fonts. Second image here
https://www.reddit.com/r/firefox/comments/uhz6d1/continued_messedup_font_rendering_in_firefox_pdf/
| Reporter | ||
Comment 1•3 years ago
|
||
Update: the bug remains in firefox 100.
Updated•3 years ago
|
Comment 2•3 years ago
|
||
Do you have gsfonts installed on your system? I had the same problem, but I fixed it by installing gsfonts.
| Reporter | ||
Comment 3•3 years ago
|
||
I do have gsfonts installed, version 1:8.11+urwcyr1.0.7~pre44-4.5 . As noted, the font rendering is fine if I disable "browser.display.use_document_fonts". So it is not a missing font problem.
| Reporter | ||
Comment 4•3 years ago
|
||
Update: this problem does not occur with firefox-trunk (version 101.0a1), which is installed via apt. I strongly suspect it is a problem with the snap packaging of firefox.
Comment 5•3 years ago
|
||
I've managed to reproduce this issue using Firefox 100.0.1 Snap on Ubuntu 22.04.
Marking this as dupe because it has been already reported in bug 1752414.
Updated•3 years ago
|
| Reporter | ||
Comment 6•3 years ago
|
||
The issue seems to be that the ubuntu snap doesn't find fonts on the system that are not embedded in the pdf. The ubuntu deb from the mozillateam ppa finds the fonts fine. So it is a snap packaging problem.
Comment 7•3 years ago
|
||
The fonts used on the first page are not embedded in the pdf and so we use a fallback font.
For any reason this font is not the same from a package to an other but It's very likely not bug related to the snap packaging.
Comment 8•3 years ago
|
||
Let's use this bug to track the mismatch of the fallback font in the Ubuntu snap.
Comment 9•3 years ago
|
||
I repro on snap stable & nightly, is there some MOZ_LOG I could use to see what is happening on the font loading path?
Sandbox logging did not immediately reveal anything wrong.
Comment 10•3 years ago
|
||
Side by side repro of the issue. On the left, Nightly Snap, on the right, Nightly from us.
Opened the linked PDF, selected the main title « Methids in cell biology » and moved to "Fonts" in the devtools. It seems weird, because they report the exact same fonts, and characteristics.
Comment 11•3 years ago
|
||
about:support on the snap package reports mesa 21.2.6 while it reports 22.0.1 on non snap package
Comment 12•3 years ago
|
||
Most of the fonts aren't embedded in the pdf.
The text is drawn on a canvas, hence the font properties are not visible in devtools (what you see is the text layer used to allow text selection).
With a local dev, the fonts set in the canvas are:
"Times", serif"Helvetica", sans-serif
So either a font called Times or Helvetica is found in a case and not in the other, or the font behind serif or sans-serif is not the same.
| Reporter | ||
Comment 13•3 years ago
|
||
(In reply to Alexandre LISSY :gerard-majax from comment #10)
Created attachment 9284140 [details]
Screenshot_ubuntu22.04_2022-07-05_16:08:03.pngSide by side repro of the issue. On the left, Nightly Snap, on the right, Nightly from us.
Opened the linked PDF, selected the main title « Methids in cell biology » and moved to "Fonts" in the devtools. It seems weird, because they report the exact same fonts, and characteristics.
I am puzzled that the one on the right reports the font as DejaVu Sans. It is Helvetica and rendered correctly. The one on the left is, indeed, DejaVu Sans and should not be.
Comment 14•3 years ago
|
||
(In reply to rahul.siddharthan from comment #13)
(In reply to Alexandre LISSY :gerard-majax from comment #10)
Created attachment 9284140 [details]
Screenshot_ubuntu22.04_2022-07-05_16:08:03.pngSide by side repro of the issue. On the left, Nightly Snap, on the right, Nightly from us.
Opened the linked PDF, selected the main title « Methids in cell biology » and moved to "Fonts" in the devtools. It seems weird, because they report the exact same fonts, and characteristics.I am puzzled that the one on the right reports the font as DejaVu Sans. It is Helvetica and rendered correctly. The one on the left is, indeed, DejaVu Sans and should not be.
Yeah, I was told I read the dev tools wrong
Comment 15•3 years ago
|
||
fc-match :family=Times return different things under (snap run --shell firefox) / outside of Snap:
Under snap:
$ fc-match :family=Times
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
Outside of snap:
$ fc-match :family=Times
NimbusRoman-Regular.otf: "Nimbus Roman" "Regular"
Comment 16•3 years ago
•
|
||
Outside:
user@ubuntu-2204-snap:~$ fc-match :family=Times
NimbusRoman-Regular.otf: "Nimbus Roman" "Regular"
user@ubuntu-2204-snap:~$ fc-match :family=Helvetica
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
user@ubuntu-2204-snap:~$ fc-match :family="Times New Roman"
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
user@ubuntu-2204-snap:~$ fc-match :family=serif
DejaVuSerif.ttf: "DejaVu Serif" "Book"
user@ubuntu-2204-snap:~$ fc-match :family=sans-serif
DejaVuSans.ttf: "DejaVu Sans" "Book"
user@ubuntu-2204-snap:~$ fc-match :family="Times, serif"
NimbusRoman-Regular.otf: "Nimbus Roman" "Regular"
user@ubuntu-2204-snap:~$ fc-match :family="Helvetica, sans-serif"
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
Inside:
user@ubuntu-2204-snap:/home/user$ fc-match :family=Times
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
user@ubuntu-2204-snap:/home/user$ fc-match :family=Helvetica
LiberationSans-Regular.ttf: "Liberation Sans" "Regular"
user@ubuntu-2204-snap:/home/user$ fc-match :family="Times New Roman"
LiberationSerif-Regular.ttf: "Liberation Serif" "Regular"
user@ubuntu-2204-snap:/home/user$ fc-match :family=serif
DejaVuSerif.ttf: "DejaVu Serif" "Book"
user@ubuntu-2204-snap:/home/user$ fc-match :family=sans-serif
DejaVuSans.ttf: "DejaVu Sans" "Book"
user@ubuntu-2204-snap:/home/user$ fc-match :family="Helvetica, sans-serif"
DejaVuSans.ttf: "DejaVu Sans" "Book"
user@ubuntu-2204-snap:/home/user$ fc-match :family="Times, serif"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
Comment 17•3 years ago
|
||
$ cat $XDG_CONFIG_HOME/fontconfig/fonts.conf
<fontconfig>
<dir>/snap/firefox/x1/gnome-platform/usr/share/fonts</dir>
<dir>/usr/local/share//fonts</dir>
<dir>/usr/share//fonts</dir>
<include ignore_missing="yes">/etc/fonts/conf.d</include>
<include ignore_missing="yes">conf.d</include>
<cachedir prefix="xdg">fontconfig</cachedir>
<cachedir>/var/snap/firefox/common/fontconfig</cachedir>
</fontconfig>
I would assume this should find all fonts ?
Comment 18•3 years ago
|
||
We will look into XDG_DATA_DIRS at https://github.com/ubuntu/snapcraft-desktop-helpers/blob/ec861254c2a1d2447b2c589446e6cdf04c75c260/common/desktop-exports#L274
XDG_DATA_DIRS=/home/user/snap/firefox/x1/.local/share:/home/user/snap/firefox/x1:/snap/firefox/x1/data-dir:/snap/firefox/x1/usr/share:/snap/firefox/x1/gnome-platform/usr/share:/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
And if we find fonts, we add them at https://github.com/ubuntu/snapcraft-desktop-helpers/blob/ec861254c2a1d2447b2c589446e6cdf04c75c260/common/desktop-exports#L288-L292
This is how we end up with <dir>/snap/firefox/x1/gnome-platform/usr/share/fonts</dir> in comment #17.
Unfortunately, this is where we have some DejaVu fonts, and fontconfig seems to prefer them ?
Comment 19•3 years ago
|
||
(In reply to Alexandre LISSY :gerard-majax from comment #18)
We will look into
XDG_DATA_DIRSat https://github.com/ubuntu/snapcraft-desktop-helpers/blob/ec861254c2a1d2447b2c589446e6cdf04c75c260/common/desktop-exports#L274XDG_DATA_DIRS=/home/user/snap/firefox/x1/.local/share:/home/user/snap/firefox/x1:/snap/firefox/x1/data-dir:/snap/firefox/x1/usr/share:/snap/firefox/x1/gnome-platform/usr/share:/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktopAnd if we find fonts, we add them at https://github.com/ubuntu/snapcraft-desktop-helpers/blob/ec861254c2a1d2447b2c589446e6cdf04c75c260/common/desktop-exports#L288-L292
This is how we end up with
<dir>/snap/firefox/x1/gnome-platform/usr/share/fonts</dir>in comment #17.Unfortunately, this is where we have some
DejaVufonts, and fontconfig seems to prefer them ?
It's not just that. Removed the extra font directory, I get:
$ grep -n DejaVu inside-snap.txt outside-snap.txt
inside-snap.txt:4:/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
inside-snap.txt:10:/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
inside-snap.txt:32:/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
inside-snap.txt:127:/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
inside-snap.txt:190:/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
inside-snap.txt:353:/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf: DejaVu Serif:style=Book
outside-snap.txt:4:/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
outside-snap.txt:10:/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
outside-snap.txt:32:/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
outside-snap.txt:127:/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
outside-snap.txt:190:/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
outside-snap.txt:353:/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf: DejaVu Serif:style=Book
So the fc-list output is identical:
$ sha1sum outside-snap.txt inside-snap.txt
6725ddfa566a886949c5e6b2264887aa2cc38772 outside-snap.txt
6725ddfa566a886949c5e6b2264887aa2cc38772 inside-snap.txt
Yet the behavior is different:
(outside)
user@ubuntu-2204-snap:~$ fc-match :family="Times, sans-serif"
NimbusRoman-Regular.otf: "Nimbus Roman" "Regular"
(inside)
user@ubuntu-2204-snap:/home/user$ fc-match :family="Times, sans-serif"
DejaVuSans.ttf: "DejaVu Sans" "Book"
Comment 20•3 years ago
|
||
As suggested by Sebastian on IRC,
$ mkdir ~/snap/firefox/current/.config/fontconfig/conf.d; cp /etc/fonts/conf.d/61-urw-nimbus-roman.conf ~/snap/firefox/current/.config/fontconfig/conf.d
This fixes the example of fc-match above, confirming we are missing some fontconfig on snap-side.
I could confirm locally that the following allows me to get identical PDF rendering:
mkdir ~/snap/firefox/current/.config/fontconfig/conf.d; cp /etc/fonts/conf.d/* ~/snap/firefox/current/.config/fontconfig/conf.d
Comment 21•3 years ago
|
||
Upstreamed to https://github.com/ubuntu/gnome-sdk/issues/49
Comment 22•3 years ago
|
||
| Reporter | ||
Comment 23•3 years ago
|
||
(In reply to Alexandre LISSY :gerard-majax from comment #20)
As suggested by Sebastian on IRC,
$ mkdir ~/snap/firefox/current/.config/fontconfig/conf.d; cp /etc/fonts/conf.d/61-urw-nimbus-roman.conf ~/snap/firefox/current/.config/fontconfig/conf.d
Confirmed, this fixes it for me.
Comment 24•3 years ago
|
||
The severity field is not set for this bug.
:gerard-majax, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 25•3 years ago
|
||
Another workaround is changing pdfjs.disableFontFace = true, although I did encounter it failing to render the title of this document.
Comment 26•3 years ago
|
||
Upstream will fix with https://github.com/ubuntu/gnome-sdk/pull/72
Comment 27•3 years ago
|
||
The package has been pushed to candidate channel, locally updating my VM with snap refresh --candidate gnome-3-38-2004 and the issue is properly fixed. Thanks all for your patience.
Description
•