pdfs with sans serif fonts and Identity-H encoding are displayed badly (with inconsistent/wobbly glyph height and position)
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
People
(Reporter: juh+bugzilla, Unassigned)
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
Steps to reproduce:
I create a pdf with a sans serif font where fonts are included with
type: CID Type 0C
encoding: Identity-H
The file is displayed fine in many pdf viewers.
But not in the pdf viewer of firefox.
I tried this with two different font families from different sources, so I guess it is not a font problem.
If I use another tool to create a pdf with embedded fonts as Type 1 and with the encoding "Builtin", the pdf is displayed fine.
A screenshot and the displayed file are attached.
Actual results:
The letters seems to jump up and down up until a magnification of 300% where the effect goes away. The pdf prints fine
Expected results:
The letters of the fonts should be displayed just fine even when the fonts are embedded as CID Type 0C with encoding: Identity-H.
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Layout: Text and Fonts' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
I think this is a font issue, or more specifically an issue with the font as embedded by LuaMetaTeX in this PDF -- it may have lost or disrupted the hinting from the original font in some way. Viewing the PDF in Adobe Reader, I can see some similar irregularity -- not as extreme as in your screenshot, but it's definitely not good. See for example the final line "eu lacus", where the "u" glyphs seem to be smaller and slightly raised compared to the surrounding text.
It's probably especially bad on Linux because of interactions between the font resource's hinting (or lack of it) and particular FreeType rasterization settings. You might find that changing the hinting level and/or antialiasing mode can improve the result.
Only a guess, but it may be that (a) LuaMetaTeX is stripping the original hinting from the font (assuming it was hinted originally -- if you use that same font directly in HTML, how does it look?), and (b) the use of Identity-H encoding may prevent the FreeType autohinter working well with the resulting font as it depends on the encoding to understand how glyphs should be harmonized across the alphabet.
Comment 3•2 years ago
|
||
This is definitely a hinting issue. I'm using Gnome on Wayland, and if I set "None" hinting and "None" AA, all of the PDFs look the same (and terrible). But if I set "Slight" hinting and "Grayscale" AA (the defaut values), the LMTX PDF looks different than the other 4. The glyphs in the LMTX PDF are all slightly taller, which makes the PDF look slightly worse to me. If I set "Full" hinting and "Subpixel" AA in Gnome Tweaks, I get the same results as with slight/grayscale.
On my Windows computer, all 4 of the "other" PDFs look the same, but the LMTX PDF also looks different. Here, the glyphs are quite a bit darker, which makes the document look quite a bit worse. I don't think that the Windows version of Firefox includes FreeType, so this probably isn't a FreeType bug.
When I open lmtx.pdf
and luahbtex.pdf
in Font Forge, I'm seeing identical hints on all of the characters. Perhaps Firefox isn't able to decode Identity-H fonts? Or perhaps LMTX is corrupting the hints, but FontForge has a more lenient parser? Or something else altogether?
The LuaMetaTeX engine isn't open source quite yet, but all of the font code is done in Lua (I think?) which is should be in files named like font-???.lmt
at https://source.contextgarden.net/ or https://github.com/contextgarden/context-mirror/. This is also being discussed on the ConTeXt mailing list.
assuming it was hinted originally
Yes, the TeX Gyre fonts are all professionally/manually hinted.
Also, please let me know if you want me to send screenshots of any specific examples.
System Information
Linux
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Gnome on Fedora 36, with MOZ_ENABLE_WAYLAND=1
set
Display: 2560x1440
Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Windows 10 Education, Build 10.0.19044
Display: 1920x1080
Comment 4•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 5•2 years ago
|
||
Comment 6•2 years ago
|
||
Thanks! Closing as not-a-Firefox-bug, then, given comment 5's indication that this was a (now-fixed) bug in LuaMetaTeX / ConTeXt.
Description
•