Bad rendering (hinting) in Evince and Xpdf

Bug #26118 reported by Marciano Siniscalchi
76
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Poppler
Unknown
Medium
poppler (Ubuntu)
Triaged
Medium
Ubuntu Desktop Bugs

Bug Description

Ubuntu Breezy 5.10/i386

Evince 0.4.0 using Poppler 0.4.2 (splash), as in the standard install
Xpdf 3.0.1

Problem: Fonts in PDF files look quite bad in Evince and Xpdf compared with the
*same* document viewed with the *same* versions of Evince and Xpdf in SUSE 10.0.
In particular, this seems to be a hinting problem.

Could it be because Ubuntu 5.10 uses Freetype-2.1.7? SUSE 2.10 uses Freetype-2.1.10.

I can provide screenshots comparing rendering in Ubuntu and Suse if necessary.

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

Created an attachment (id=5037)
Evince on SUSE 10.0

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

Created an attachment (id=5038)
Evince on Ubuntu 5.10

Revision history for this message
Daniel Holbach (dholbach) wrote :

Dapper has Freetype 2.1.10 now, if you could provide us with a link to that PDF,
we could check.

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

Created an attachment (id=5049)
PDF file generated with PDFLatex, with Type 1 Computer Modern fonts embedded.

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

I have just downloaded the Dapper Drake LiveCD (Flight 2). The problem persists---no change.

Revision history for this message
Sebastien Bacher (seb128) wrote :

maybe Suse has some patches, or maybe that's due to the fontconfig configuration
or the fonts installed beeing different

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

Note 1: installled fonts should not be the issue here. The documents in question only use embedded fonts (the standard LaTeX Type 1
"Computer Modern" fonts, which come with any modern LaTeX disto including TeTeX).

Note 2: Another possibility---Older versions of Kpdf allowed one to toggle font hinting on or off. I seem to remember that hinting
actuallly made things worse and actually quite similar to what I am getting with Evince now. The reason is that the CM fonts did
not have very good hints. Does this make any sense?

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

I AM AN IDIOT^H^H^H^H^H NEWBIE. Sorry for the caps, but I have given you BAD debugging information. Sorrysorrysorry.

OK, here's the deal. The above screenshots are taken from Evince, but I had other screenshots taken from xpdf. I originally thought (due to mislabeling of one file, perhaps) that the same issue arose with xpdf and Evince/Kpdf, but this is NOT the case.

The problem exists only with Evince and Kpdf, and NOT, repeat, NOT with xpdf. Indeed, upon further experimentation, I have found that:

1. Rendering the above file (or other PDF files generated by pdflatex) with xpdf gives THE SAME RESULTS under both Ubuntu Breezy and OpenSuse 10.0.

2. Rendering the same files with Evince or Kpdf gives inferior results on Breezy relative to OpenSuse, as documented by the above screenshots.

BOTTOM LINE: I think Poppler is to blame. xpdf uses t1lib to render Type 1 fonts, and indeed pdflatex embeds Type 1 fonts. Evince and Kpdf instead use poppler-->freetype2 to render both Type 1 and TrueType fonts. Now, it turns out that t1lib does a much better job than freetype2 with Type 1 fonts.

So, perhaps Suse has patched Evince, Kpdf & Co. to use t1lib instead of Poppler for Type 1 fonts. In any case, I cannot get the nice output I get with xpdf from kpdf or evince :-(

Hopefully this clarifies the situation. Again, sorry for the initial mistake I made.

Revision history for this message
Sebastien Bacher (seb128) wrote :

On dapper the rendering seems to be correct, could you comment if you try with the next version?

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote : Re: [Bug 26118] Bad rendering (hinting) in Evince and Xpdf

I just tried Dapper Flight 4 (Kubuntu to be precise). I did see some
improvement over Breezy, but xpdf rendering still seems distinctly
superior to kpdf/poppler rendering. It definitely has to do with the
rendering of Type 1 fonts...

On 2/18/06, Sebastien Bacher <email address hidden> wrote:
> Public bug report changed:
> https://launchpad.net/malone/bugs/26118
>
> Comment:
> On dapper the rendering seems to be correct, could you comment if you
> try with the next version?
>

--
Marciano Siniscalchi

Revision history for this message
Sebastien Bacher (seb128) wrote :

Could be a different fontconfig config. You can changes the options with "sudo dpkg-reconfigure fontconfig" if you want to try

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote : Re: Bad rendering (hinting) in Evince and Xpdf [FIX!]

I think I nailed it!

First of all, the exact same issue arises in Edgy, which is what I am using now. However, it's easy to fix.

Second, it's a poppler problem, not an Evince problem per se.

See file splash/SplashFTFont.cc in poppler-0.5.4 (the Edgy version), lines 180 and following. This is where poppler loads glyphs for the splash output device; this code comes from xpdf, btw.

Basically, there is a compile-time check to see whether freetype has the bytecode interpreter enabled; if so, IT IS USED regardless of whether anti-aliasing is on or off. Otherwise, no hinting is used if anti-aliasing is on. Again, this is a compile-time check.
The problem is that, for most fonts used with LaTeX (but I'd say for most other fonts, too) it's best to omit hinting altogether.

I fixed the problem by simply deleting the portion of the code that is triggered if TT_CONFIG_OPTION_BYTECODE is defined, and instead leaving only the section that is compiled if it is not. Rebuilding with pdebuild and installing with dpkg -i did the trick.

Ideally, this should be a gconf setting, I guess.

Hope this helps,
M

Changed in evince:
assignee: seb128 → desktop-bugs
Revision history for this message
Ilmari Vacklin (wolverian) wrote :

FWIW, I still see bad rendering of serif fonts in Evince on Feisty.

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

That bug has been described on https://launchpad.net/ubuntu/+source/poppler/+bug/26118

"...
http://librarian.launchpad.net/4941174/SplashFTFont.cc
Modified splash/SplashFTFont.cc from poppler-0.5.4

I think I nailed it!

First of all, the exact same issue arises in Edgy, which is what I am using now. However, it's easy to fix.

Second, it's a poppler problem, not an Evince problem per se.

See file splash/SplashFTFont.cc in poppler-0.5.4 (the Edgy version), lines 180 and following. This is where poppler loads glyphs for the splash output device; this code comes from xpdf, btw.

Basically, there is a compile-time check to see whether freetype has the bytecode interpreter enabled; if so, IT IS USED regardless of whether anti-aliasing is on or off. Otherwise, no hinting is used if anti-aliasing is on. Again, this is a compile-time check.
The problem is that, for most fonts used with LaTeX (but I'd say for most other fonts, too) it's best to omit hinting altogether.

I fixed the problem by simply deleting the portion of the code that is triggered if TT_CONFIG_OPTION_BYTECODE is defined, and instead leaving only the section that is compiled if it is not. Rebuilding with pdebuild and installing with dpkg -i did the trick.

Ideally, this should be a gconf setting, I guess.

Hope this helps,
M
..."

Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in poppler:
status: Unconfirmed → Unknown
Changed in poppler:
status: Unknown → Confirmed
Revision history for this message
Ilmari Vacklin (wolverian) wrote :

I had some crufty config enabling the freetype autohinter. Cleaning that up fixed this bug for me.

Revision history for this message
Pauli Virtanen (pauli-virtanen) wrote :

Please specify which crufty config.

I am running on feisty, and the following:

    dpkg --force-depends --purge fontconfig-config
    rm -rf /etc/fonts
    apt-get -f install fontconfig-config
    rm -rf $HOME/.font*

did not fix the problem for me.

Revision history for this message
Ilmari Vacklin (wolverian) wrote :

That's what I did, additionally running dpkg-reconfigure fontconfig-config to make sure the hinter type is "native" instead of autohinter.

Revision history for this message
Pauli Virtanen (pauli-virtanen) wrote :

I was unable to fix the rendering in evince by tweaking those fontconfig-config options. For me, so far only modifying SplashFTFont.cc and recompiling has improved the rendering.

The problem is worst at small font sizes (attachment).

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote : Re: [Bug 26118] Re: Bad rendering (hinting) in Evince and Xpdf

Yes, I did exactly the same, and it works (except that it needs to be
redone every time poppler gets updated...)

Is there any chance of getting the fix incorporated? M

On 2/25/07, Pauli Virtanen <email address hidden> wrote:
> I was unable to fix the rendering in evince by tweaking those
> fontconfig-config options. For me, so far only modifying SplashFTFont.cc
> and recompiling has improved the rendering.
>
> The problem is worst at small font sizes (attachment).
>
> ** Attachment added: "Bad hinting at small font sizes"
> http://librarian.launchpad.net/6527474/evince-bad-hinting.png
>
> --
> Bad rendering (hinting) in Evince and Xpdf
> https://launchpad.net/bugs/26118
>

--
Marciano Siniscalchi

Revision history for this message
Ilmari Vacklin (wolverian) wrote :

Sorry, my "fix" was bogus. I checked the results with a TeXmacs-produced PDF, which apparently includes different fonts than what e.g. pdfetex does. The TeXmacs fonts look fine. (I wonder why.)

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

For the record, the fix that works for me is to change the
#ifdef...#else...#endif block beginning at line 179 of file
SplashFTFont.cc as follows:

  // if we have the FT2 bytecode interpreter, autohinting won't be used
  // MS: actually, disregard bytecode setting, as it yields poor results anyway
// #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
// if (FT_Load_Glyph(ff->face, gid,
// aa ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT)) {
// return gFalse;
// }
//#else
  // FT2's autohinting doesn't always work very well (especially with
  // font subsets), so turn it off if anti-aliasing is enabled; if
  // anti-aliasing is disabled, this seems to be a tossup - some fonts
  // look better with hinting, some without, so leave hinting on
  if (FT_Load_Glyph(ff->face, gid,
      aa ? FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP
                       : FT_LOAD_DEFAULT)) {
    return gFalse;
  }
//#endif

[sorry if I don't generate a patch---I still haven't learned how to do so...]

In other words, I force autohinting off if anti-aliasing is enabled,
regardless of whether or not Freetype was compiled with the bytecode
interpreted on (which, in Ubuntu, it is).

Notice that this compile-time checking that poppler does explains why
this bug is hard to trace. Even if you recompile Freetype without the
BC on, it still won't matter, as poppler is compiled against the
"standard" Ubuntu distribution with BC enabled.

M

--
Marciano Siniscalchi

Revision history for this message
Ilmari Vacklin (wolverian) wrote :

I see a lot better rendering now. I don't see any relevant entries in the poppler changelog though, so maybe it's something local.

Revision history for this message
ropers (ropers) wrote :

I don't know if this is related, but I'm also seeing absolutely atrocious font rendering with some PDF files in evince.

gpdf renders the same PDFs much better, but appears to use different fonts and ignore settings such as "bold".

Please see the following two screenshot for comparison. Yes, this is the same document, in evince and in gpdf on Ubuntu 6.10.

Revision history for this message
ropers (ropers) wrote :
Revision history for this message
ropers (ropers) wrote :

This is the actual PDF file the above screenshots were taken with.

Revision history for this message
Marciano Siniscalchi (msiniscalchi) wrote :

It's not the same bug. The document you attached uses Type 3 fonts,
which in theory are drawn using Postscript (not PDF) primitives, but
in practice are just bitmaps. Ghostview and Acrobad do a fine job with
these, but poppler-based readers don't handle them well at all.

The issue being discussed here only pertains to Type 1 fonts.

So, unfortunately, I'm afraid your best bet for non-atrocious
rendering is Acroread (yech!)

M

On 3/28/07, Jens Ropers <email address hidden> wrote:
> I don't know if this is related, but I'm also seeing absolutely
> atrocious font rendering with some PDF files in evince.
>
> gpdf renders the same PDFs much better, but appears to use different
> fonts and ignore settings such as "bold".
>
> Please see the following two screenshot for comparison. Yes, this is the
> same document, in evince and in gpdf on Ubuntu 6.10.
>
> ** Attachment added: "Evince pdf screenshot"
> http://librarian.launchpad.net/7035137/Screenshot.evince.png
>
> --
> Bad rendering (hinting) in Evince and Xpdf
> https://launchpad.net/bugs/26118
>

--
Marciano Siniscalchi

Revision history for this message
Arnold J Noronha (arnold) wrote :

Same problem here, bad rendering for (most) PDF files on Evince which work well on acroread, kpdf, gv, etc. Btw I'm using a Feisty machine (Breezy->Dapper->Edgy->Feisty upgrade). PS, DVI files work fine.

Revision history for this message
ropers (ropers) wrote :

@Marciano Siniscalchi
Thank you for your comment.
Do you/does anyone know if there is another bug filed for that Type 3 fonts rendering issue?

Changed in poppler:
status: Confirmed → Triaged
Revision history for this message
Peter Berry (pwberry) wrote :

Bug 92296 seems to be the bug you're looking for.

Revision history for this message
ropers (ropers) wrote :

Thanks Peter. I've reposted my info there.

Revision history for this message
In , Albert Astals Cid (aacid) wrote :

removing code?
gconf setting?

Can you make a reasonable suggestion, please?

Revision history for this message
Albert Cardona (cardona) wrote :

Is this solved at all? As of today, I still see some pdf files -but not others (how to tell the difference?) rendering improperly in evince.
When the text is selected, the text is suddenly smooth and nice; when deselected, it's all sketchy and rough.

Also, many equations and punctuation chars disappear when selecting text (an entirely different bug, I assume).

None of the above exist in kpdf. Only evince.

Revision history for this message
Brewster Malevich (brews) wrote :

Will we see this fixed anytime soon?

Revision history for this message
Sebastien Bacher (seb128) wrote :

> Will we see this fixed anytime soon?

Depends if somebody work on the issue

Revision history for this message
madbiologist (me-again) wrote :

The file in comment #25 renders well in Ubuntu 10.10 "Maverick Meerkat" alpha 2 updated to the latest Ubuntu packages.

Uname: Linux 2.6.35-6-generic i686
Packages: evince 2.30.3-1ubuntu2
                  poppler 0.14.1-0ubuntu1
                  libcairo2 1.9.14-1

Changed in poppler:
importance: Unknown → Medium
Changed in poppler:
importance: Medium → Unknown
Changed in poppler:
importance: Unknown → Medium
Revision history for this message
In , Gitlab-migration (gitlab-migration) wrote :

-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/411.

Changed in poppler:
status: Confirmed → Unknown
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.