pdf.js: Non-embedded fonts rendered strangely
Categories
(Firefox :: PDF Viewer, defect)
Tracking
()
People
(Reporter: pmenzel+bugzilla.mozilla.org, Unassigned)
References
(Regression)
Details
(Keywords: regression)
Attachments
(4 files)
Steps to reproduce:
According to the users this is a regression in at least 115.0.2. This only happens with our self-built Firefox. On Debian sid/unstable, testing firefox 115.0.2-1, and Nightly 117.0a1 (20230725211415), the problem is not seen (even with browser.display.use_document_fonts = 1
).
View PDFs created by Web sites like dhl.de with filled in fields.
$ pdffonts confidential.pdf
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
Helvetica-Bold Type 1 WinAnsi no no no 2 0
Helvetica Type 1 WinAnsi no no no 3 0
Helvetica-BoldOblique Type 1 WinAnsi no no no 4 0
I can share the file privately.
Actual results:
The filled in text (by the Web site) looks distorted (see attached image). All the problematic PDF files seem to use Helvetica as font and do not have it embedded.
Evince shows the font correctly for the user, by using NimbusSans.
Setting browser.display.use_document_fonts = 0
in about:config works around the issue.
Expected results:
For non-embedded fonts, a better substitute font should be tried, or the user informed.
Reporter | ||
Comment 1•2 years ago
|
||
Reporter | ||
Updated•2 years ago
|
Reporter | ||
Comment 2•2 years ago
|
||
$ pdfinfo confidential.pdf
Producer: OpenPDF 1.3.30
CreationDate: Wed Jul 26 XX:XX:XX 2023 CEST
ModDate: Wed Jul 26 XX:XX:XX 2023 CEST
Custom Metadata: no
Metadata Stream: no
Tagged: no
UserProperties: no
Suspects: no
Form: none
JavaScript: no
Pages: 1
Encrypted: no
Page size: 595.28 x 841.89 pts (A4)
Page rot: 0
File size: 38480 bytes
Optimized: no
PDF version: 1.5
![]() |
||
Updated•2 years ago
|
Reporter | ||
Comment 3•2 years ago
|
||
This is reproducible in Nightly 117.0a1, 20230726154100.
Reporter | ||
Comment 4•2 years ago
|
||
Opening the file in pdf.js built from the main/master branch, the problem is also there.
Reporter | ||
Comment 5•2 years ago
|
||
Works with pdf.js v3.2.146.
Comment 6•2 years ago
|
||
For non-embedded fonts, a better substitute font should be tried, or the user informed.
It's exactly what we tried to do:
- https://github.com/mozilla/pdf.js/blob/8f83a1359eb759507c66205ed40ab35bf83ccf13/src/core/font_substitutions.js#L84-L119
- https://github.com/mozilla/pdf.js/blob/8f83a1359eb759507c66205ed40ab35bf83ccf13/src/display/font_loader.js#L83-L112
The first available font in the list is used and if nothing is found then liberation.ttf
is used.
So maybe a font in the list shouldn't be there, if you manage to know which one is used then we could see if it should be in the list or not.
You could try something like fc-list | rg -i "font name"
to figure out which one is used.
Reporter | ||
Comment 7•2 years ago
|
||
Reporter | ||
Comment 8•2 years ago
|
||
The commit below is the culprit:
commit 53134c0c0bb2d19244dd8c31aa4e8e6d01a657e4
Author: Calixte Denizet <calixte.denizet@gmail.com>
Date: Thu Apr 27 18:01:07 2023 +0200
[api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039)
- Replace FoxitSans with LiberationSans: LiberationSans is already there (for XFA) and we can use
it as a good replacement of FoxitSans.
- For now we just try to substitue standard fonts, the strategy is the following:
* we try to find a font locally from a hardcoded list;
* if it fails then we use Liberation as fallback (only for Helvetica for the moment);
* else we just fallback on the system serif/sansserif/monospace font.
external/standard_fonts/FoxitSans.pfb | Bin 15025 -> 0 bytes
external/standard_fonts/FoxitSansBold.pfb | Bin 16344 -> 0 bytes
external/standard_fonts/FoxitSansBoldItalic.pfb | Bin 16418 -> 0 bytes
external/standard_fonts/FoxitSansItalic.pfb | Bin 16339 -> 0 bytes
src/core/core_utils.js | 46 ++-
src/core/evaluator.js | 20 +
src/core/font_substitutions.js | 478 ++++++++++++++++++++++++
src/core/fonts.js | 2 +
src/core/standard_fonts.js | 8 +-
src/display/canvas.js | 3 +-
src/display/font_loader.js | 45 ++-
web/app_options.js | 10 +-
12 files changed, 584 insertions(+), 28 deletions(-)
delete mode 100644 external/standard_fonts/FoxitSans.pfb
delete mode 100644 external/standard_fonts/FoxitSansBold.pfb
delete mode 100644 external/standard_fonts/FoxitSansBoldItalic.pfb
delete mode 100644 external/standard_fonts/FoxitSansItalic.pfb
create mode 100644 src/core/font_substitutions.js
You could try something like fc-list | rg -i "font name" to figure out which one is used.
On MarIuX, distribution showing the failure:
$ fc-list | grep -i helvetica
/usr/share/fonts/X11/100dpi/helvBO08.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvBO10.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvB18-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvR08-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvR10-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvR14-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvO24.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvR12-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvBO18.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvB14-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvB08-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvB10-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvBO18-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvB12-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvO24-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvBO12-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvR24.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvB24.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvB18-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvBO14-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvBO08-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvBO10-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvR14.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvB14.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvB08-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvB10-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvB14-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvO18.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvR18-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvB18.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvB12-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvO08.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvO10.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvB08.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvB10.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvR24.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvBO24.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvO18-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvBO14.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvB24-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvO08.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvO10.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvR14.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvO18.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvR12.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvO08-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvO10-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvBO24.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvO14-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvO14-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvO12-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvO08-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvO10-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvBO14.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvO12.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvB12.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvR24-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvO12-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvO18-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvBO12-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvR24-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvBO12.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvBO14-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvBO08-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvBO10-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvBO24-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvB24.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvO12.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvB24-ISO8859-1.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvR12.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvR08.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvR10.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvB08.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvB10.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/75dpi/helvR18-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvR18.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvB18.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvBO12.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvB14.pcf.gz: Helvetica:style=Bold
/usr/share/fonts/X11/100dpi/helvO14.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvR14-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvR08-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvR10-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvBO18-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvO24.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvBO08.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvBO10.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/75dpi/helvR12-ISO8859-1.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvR18.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/75dpi/helvO14.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/75dpi/helvBO18.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvBO24-ISO8859-1.pcf.gz: Helvetica:style=Bold Oblique
/usr/share/fonts/X11/100dpi/helvR08.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvR10.pcf.gz: Helvetica:style=Regular
/usr/share/fonts/X11/100dpi/helvO24-ISO8859-1.pcf.gz: Helvetica:style=Oblique
/usr/share/fonts/X11/100dpi/helvB12.pcf.gz: Helvetica:style=Bold
$ fakeroot bee list fonts-x-org
fonts-x-org-1.0-0.x86_64
Build recipe: bee file for package.
On Debian sid/unstable:
$ fc-list | grep -i helvetica
$
Reporter | ||
Comment 9•2 years ago
|
||
I am also curious, why browser.display.use_document_fonts = 0
makes a difference.
Updated•2 years ago
|
Comment 10•2 years ago
|
||
It's very likely a duplicate of bug 1839860, so let's move the discussion there.
Reporter | ||
Comment 11•2 years ago
|
||
Just for the record. The installed fonts also differ in the tested distributions.
On the (working) Debian sid/unstable, Evince replaces the font with NimbusSans.
$ fc-list "Nimbus Sans"
/usr/share/fonts/opentype/urw-base35/NimbusSans-Regular.otf: Nimbus Sans:style=Regular
/usr/share/fonts/type1/urw-base35/NimbusSans-Regular.t1: Nimbus Sans:style=Regular
/usr/share/fonts/opentype/urw-base35/NimbusSans-Bold.otf: Nimbus Sans:style=Bold
/usr/share/fonts/X11/Type1/NimbusSans-BoldItalic.pfb: Nimbus Sans:style=Bold Italic
/usr/share/fonts/opentype/urw-base35/NimbusSans-BoldItalic.otf: Nimbus Sans:style=Bold Italic
/usr/share/fonts/opentype/urw-base35/NimbusSans-Italic.otf: Nimbus Sans:style=Italic
/usr/share/fonts/type1/urw-base35/NimbusSans-BoldItalic.t1: Nimbus Sans:style=Bold Italic
/usr/share/fonts/type1/urw-base35/NimbusSans-Bold.t1: Nimbus Sans:style=Bold
/usr/share/fonts/X11/Type1/NimbusSans-Bold.pfb: Nimbus Sans:style=Bold
/usr/share/fonts/X11/Type1/NimbusSans-Italic.pfb: Nimbus Sans:style=Italic
/usr/share/fonts/X11/Type1/NimbusSans-Regular.pfb: Nimbus Sans:style=Regular
/usr/share/fonts/type1/urw-base35/NimbusSans-Italic.t1: Nimbus Sans:style=Italic
On the (non-working) MarIuX OpenType fonts are not installed, and Evince uses Nimbus Sans L.
$ fc-list "Nimbus Sans L"
/usr/share/ghostscript/fonts/n019023l.pfb: Nimbus Sans L:style=Regular Italic
/usr/share/ghostscript/fonts/n019063l.pfb: Nimbus Sans L:style=Regular Condensed Italic
/usr/share/ghostscript/fonts/n019044l.pfb: Nimbus Sans L:style=Bold Condensed
/usr/share/ghostscript/fonts/n019003l.pfb: Nimbus Sans L:style=Regular
/usr/share/ghostscript/fonts/n019043l.pfb: Nimbus Sans L:style=Regular Condensed
/usr/share/ghostscript/fonts/n019004l.pfb: Nimbus Sans L:style=Bold
/usr/share/ghostscript/fonts/n019064l.pfb: Nimbus Sans L:style=Bold Condensed Italic
/usr/share/ghostscript/fonts/n019024l.pfb: Nimbus Sans L:style=Bold Italic
Description
•