Evince displays wrong font for PDF Courier basefont

Bug #327757 reported by Peter Hendrickson
4
Affects Status Importance Assigned to Milestone
Fontconfig
Invalid
Medium
Poppler
Invalid
Undecided
Unassigned
fontconfig (Ubuntu)
Triaged
Low
Unassigned

Bug Description

Binary package hint: evince

My version of Ubuntu:
> $ lsb_release -rd
> Description: Ubuntu 8.04.2
> Release: 8.04

My version of evince:
> $ apt-cache policy evince
> evince:
> Installed: 2.22.2-0ubuntu2
> Candidate: 2.22.2-0ubuntu2
> Version table:
> *** 2.22.2-0ubuntu2 0
> 500 http://us.archive.ubuntu.com hardy-updates/main Packages
> 100 /var/lib/dpkg/status
> 2.22.1.1-0ubuntu1 0
> 500 http://us.archive.ubuntu.com hardy/main Packages

PDFs which specify the basefont of "Courier" are displayed with an oblique typeface which is not at all a good
substitute. It looks radically different from the Courier displayed by xpdf, gv, and Adobe Acrobat.

What I expected: a font which looks like "Courier."

I plan to attach a PDF "rfc3513.txt.pdf" which demonstrates the problem, as well as two Evince screenshots
and a screenshot from gv and xpdf respectively. Gv and xpdf do not have beautiful fonts, but they are
correct. Adobe Acrobat Reader uses a good looking font. (I haven't enclosed a screenshot, but
Reader is a good reference for what it should look like if you have one handy.)

This is the relevant font description line from the above PDF:
> <</Type/Font/Name/R6/Subtype/Type1/BaseFont/Courier>>

The problem may be with poppler or with fontconfig since they are used by Evince. However, I haven't been
able to prove either of them to be the culprit. The problem is only visible in Evince. My guess
is that this will be an easy configuration fix. I believe Evince just needs to not oblique the font and not
embolden it and it will be correct -- but I haven't been able to figure out how that is configured.

The font Evince is very closely related to "Nimbus Mono L" except it is oblique by 10 degrees (I measured
it) and it looks bolder than it should be. Looking through the font-config configuration files in /etc/fonts
suggests that "Nimbus Mono L" is what fontconfig recommends for "Courier." Also, see:
> $ fc-match courier
> n022003l.pfb: "Nimbus Mono L" "Regular"

This is the file where the font appears:
/usr/share/fonts/type1/gsfonts/n022003l.pfb

For cross reference, in oowriter the "Courier 10 Pitch" font if the "tilted A" button is pushed looks almost
exactly the same.

This is the version of fontconfig I'm using:
> $ apt-cache policy fontconfig
> fontconfig:
> Installed: 2.5.0-2ubuntu3
> Candidate: 2.5.0-2ubuntu3
> Version table:
> *** 2.5.0-2ubuntu3 0
> 500 http://us.archive.ubuntu.com hardy/main Packages
> 100 /var/lib/dpkg/status

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :
Revision history for this message
Dimitrios Symeonidis (azimout) wrote :

It displays correctly on my Evince, I don't know if it's because I installed msttcorefonts or ttf-liberation (probably the second). Can you try installing ttf-liberation and open the pdf again with evince?

Changed in evince:
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

I tried installing ttf-liberation -- it didn't work. I removed it. I tried installing msttcorefonts and it
didn't work either.

When it works on your system, are you able to identify the font used? I'm pretty sure that on
my system "Nimbus Mono L" regular would be the right choice. It's just that Evince is using
an emboldened and obliqued version of that font. I haven't been able to figure out why.

Revision history for this message
Dimitrios Symeonidis (azimout) wrote :

It seems to be using courier... See attached screenshot

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

My Evince also claims to be displaying "Courier, Type 1, Not Embedded", but we get different results. What I'm really asking is if there's a way to figure out which actual font is being used to represent "Courier." Specifically, which file is being read for its font information.

I've looked into this enough to know that basically Evince is using Poppler which uses Fontconfig to find an appropriate font. Fontconfig doesn't come up with a vanilla Courier, it comes up with another typeface which looks like Courier. If you look at the files in /etc/fonts you can see the mappings. Also, there is an attachment to this bug called 'fc-match --verbose output for "Courier"' which shows what Fontconfig is choosing on my system.

What's strange is that Fontconfig seems to do the right thing. "Nimbus Mono L", "Regular" should look good and also be correct. Possibly Evince is getting the right font from Poppler/Fontconfig and deciding to make it oblique and bold. I don't know and I don't know how to determine what Evince is doing.

May I suggest raising the priority of this bug? I realize it may not be as exciting as file system corruption, but it is highly visible. *Possibly* there's something funny about my system, but as far as I know I'm running fully up to date stock Ubuntu 8.04LTS. That means this bug probably occurs often.

It's also just the kind of thing that makes a Windows user think they should keep using Windows. That example is not hypothetical.

Revision history for this message
Dimitrios Symeonidis (azimout) wrote :

fc-match courier gives me the same result as yours: n022003l.pfb: "Nimbus Mono L" "Regular"
switching back to "new"

Changed in evince:
status: Incomplete → New
Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

Evince works correctly on "Intrepid Ibex." FWIW, "Feisty Fawn" exhibits similar behavior. FF seems to use the same font as my version of "Hardy Heron", but it's not oblique. (That is, it looks like a heavier non-oblique version of "Nimbus Mono L".)

"fc-match courier" on "Intrepid Ibex" also gives "Nimbus Mono L", "Regular" which is the correct font. To confirm this, do "fc-match --verbose courier" to show you exactly which file stores this font. Then install something like Fontforge which will you look at exactly what is in that file. If you set Evince to 400% you can compare what you see with the contents of the file. On working systems you should see that it's the same typeface. In other words, on every system we've looked at -- working or non-working -- fc-match is doing the same thing and it's probably the right thing.

Which means the problem is probably in Evince or maybe Poppler. The problem was fixed in "Intrepid Ibex". If the fix can be identified, then it should be put into "Hardy Heron" as well since it is still a supported version.

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

I burned a "Hardy Heron" CD and booted it. The problem is still present, which shows that there's nothing special about my installation. (For the record, I used this image: "ubuntu-8.04.2-desktop-i386.iso".) This problem must be widespread or universal among "Hardy Heron" users.

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

I compared the "evince" executable from "Hardy Heron" with the working "evince" executable from "Intrepid Ibex." The Poppler library has changed from "libpoppler-glib.so.2" to "libpoppler.so.3". This suggests the problem exists the first library and not the second.

This bug is related:
https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/131523

On that page, Stephan Klein on 2008-03-31 describes a bug which is clearly the same as this one.

I'll add poppler as an affected product.

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

if that's the same issue should that be closed as duplicate? you should open the bug upstream too where the people writting the software will read it too

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

It's not clear to me that bug #131523 is a duplicate. The symptoms are different. What Stephan Klein describes is the same bug as this one, but he describes it on a page which is addressing what (I think) is possibly a different bug.

I'm currently looking through the bugs for Poppler at freedesktop.org. I'm pretty sure this problem was fixed between Poppler versions 0.6.4 and 0.8.7. The previous is used with "Hardy Heron" and the latter is used with "Intrepid Ibex." That means there may well be a bug report already.

Revision history for this message
In , Peter Hendrickson (pdh-wiredyne) wrote :

The FcFontSort() routine returns fonts sorted in the wrong order. All the details
are at the above URL along with a code sample which demonstrates the problem.
This bug is currently causing Evince to display incorrect fonts under Ubuntu's
"Hardy Heron."

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

Fontconfig is the culprit. Evince calls Popper which calls FcFontSort in libfontconfig to find the font most similar to "Courier." The first font it gets is "Nimbus Mono L", "Bold Oblique". The right font is actually the next one, "Nimbus Mono L", "Regular".

I see this on "Hardy Heron" as well as "Intrepid Ibex." The problem is not visible in Evince or Poppler on "Ibex", probably due to extensive changes in Poppler. It may affect anything that calls libfontconfig, however. On "Heron", I hard wired Evince to choose the second font and everything worked perfectly.

I've attached a code fragment (fchello.c) modelled on the part of Poppler calling libfontconfig. To compile it do:
cc -c -o fchello.o fchello.c
cc -o fchello fchello.o -lfontconfig

The first lines of output look like this:
> 0: "Nimbus Mono L", "Bold Oblique", "/usr/share/fonts/type1/gsfonts/n022024l.pfb"
> 1: "Nimbus Mono L", "Regular", "/usr/share/fonts/type1/gsfonts/n022003l.pfb"
> 2: "Nimbus Mono L", "Bold", "/usr/share/fonts/type1/gsfonts/n022004l.pfb"
> 3: "Nimbus Mono L", "Regular Oblique", "/usr/share/fonts/type1/gsfonts/n022023l.pfb"
> 4: "DejaVu Sans Mono", "Book", "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"

Note that "fc-match Courier" does the right thing (see above) even though this way of calling
libfontconfig does the wrong thing.

This is the "Ibex" release I tested:
> Description: Ubuntu 8.10
> Release: 8.10

This is the version of libfontconfig:
> libfontconfig1:
> Installed: 2.6.0-1ubuntu4
> Candidate: 2.6.0-1ubuntu4
> Version table:
> *** 2.6.0-1ubuntu4 0
> 500 http://us.archive.ubuntu.com intrepid/main Packages
> 100 /var/lib/dpkg/status

This is the "Heron" release I tested:
> Description: Ubuntu 8.04.2
> Release: 8.04

This is the version of libfontconfig:
> libfontconfig1:
> Installed: 2.5.0-2ubuntu3
> Candidate: 2.5.0-2ubuntu3
> Version table:
> *** 2.5.0-2ubuntu3 0
> 500 http://us.archive.ubuntu.com hardy/main Packages
> 100 /var/lib/dpkg/status

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

good debugging work! could you open a bug on freedesktop about that? there is no active fontconfig hacker on the ubuntu bug tracker and you will get better chance of a pertinant reply upstream for this issue

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

This is the upstream bug report: http://bugs.freedesktop.org/show_bug.cgi?id=20226

Revision history for this message
Pedro Villavicencio (pedro) wrote :

thanks you Peter, linking the report and reassigning to fontconfig, thanks again.

Changed in evince:
status: New → Triaged
Changed in fontconfig:
importance: Undecided → Unknown
status: New → Unknown
Changed in poppler:
status: New → Invalid
Changed in fontconfig:
status: Unknown → Confirmed
Revision history for this message
In , Freedesktop (freedesktop) wrote :

I can't access launchpad. Reopen the bug if you are willing to actually report *here*.

Revision history for this message
In , Dimitrios Symeonidis (azimout) wrote :

Created an attachment (id=23451)
pdf file demonstrating the bug

Revision history for this message
In , Dimitrios Symeonidis (azimout) wrote :

reopening

Revision history for this message
In , Dimitrios Symeonidis (azimout) wrote :

Created an attachment (id=23452)
evince screenshot

Revision history for this message
In , Dimitrios Symeonidis (azimout) wrote :

Created an attachment (id=23453)
xpdf screenshot

Revision history for this message
In , Dimitrios Symeonidis (azimout) wrote :

Created an attachment (id=23454)
output of fc-match

Changed in fontconfig:
status: Confirmed → Invalid
Changed in fontconfig:
status: Invalid → Confirmed
Revision history for this message
In , Freedesktop (freedesktop) wrote :

I'm fairly sure that this bug has been fixed in poppler already.

Revision history for this message
In , Peter Hendrickson (pdh-wiredyne) wrote :

I'm pretty sure the bug is in fontconfig and not in poppler. It looked to me like more recent versions of poppler did not exhibit the bug because they call fontconfig differently. However, the underlying bug remains in the fontconfig library and will affect other people who try to use the library.

There's a fair amount of information in the Ubuntu bug report:
https://bugs.launchpad.net/ubuntu/+source/evince/+bug/327757

Specifically, please see this code sample:
http://launchpadlibrarian.net/22890843/fchello.c

It demonstrates that FcFontSort is apparently not sorting correctly and, actually, gives a different result from what fc-match gives.

Revision history for this message
In , Freedesktop (freedesktop) wrote :

It's a bug in the fonts. See bug 17493 and discussion on https://bugzilla.redhat.com/show_bug.cgi?id=478332

*** This bug has been marked as a duplicate of bug 14883 ***

Changed in fontconfig:
status: Confirmed → Invalid
Revision history for this message
Dimitrios Symeonidis (azimout) wrote :

the upstream bug was marked a duplicate of https://bugs.freedesktop.org/show_bug.cgi?id=14883, which has been marked as fixed for a year now...

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

The fix has not made it to users of Hardy Heron. My test code above suggests it hasn't reached Intrepid Ibex, either. I looked at the FreeDesktop bug reports and it looks to me as if a workaround was put into Poppler, but that the underlying bug was not fixed. That bug appears to be that certain typefaces like "Nimbus Mono L Bold Oblique" are not actually monospaced, even though they are supposed to be. "Nimbus Mono L Bold Oblique" is identical on Hardy Heron and Intrepid Ibex. Would the correct solution be simply to correct those fonts, and look around for any other monospace fonts with the same problem?

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

Evince shows this file correctly in Karmic Koala 9.10 with all the latest updates.

Uname: Linux 2.6.31-16-generic i686
Package versions:
evince 2.28.1-0ubuntu1.2
libpoppler5 0.12.0-0ubuntu2.1
fontconfig 2.6.0-1ubuntu12

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

@Peter: I was able to compile your code (a first for me), after figuring out that I need to install libfontconfig1-dev

However typing "exec ./fchello" (without the quotes) at a command prompt produced no output, but instead closed the terminal window.

What am I doing wrong?

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

What does "exec ls" do? I bet it also kills your terminal window. I'm just guessing, but since exec is replacing your shell with another program, I would think that the terminal program is detecting it, not liking it, and giving up. In any event, the problem doesn't seem to be related to "fchello". It will probably work if you just type "./fchello" on the command line. Hope that helps!

Revision history for this message
Peter Hendrickson (pdh-wiredyne) wrote :

On second thought, what is probably happening is that when you replace your shell with "fchello" or "ls", the program runs and then exits. After it exits, the terminal window quits because it thinks you are done. "Exec" is probably not what you want. ;-)

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

OK, got it. Thanks.

The first lines of output are still the same as yours:

0: "Nimbus Mono L", "Bold Oblique", "/usr/share/fonts/type1/gsfonts/n022024l.pfb"
1: "Nimbus Mono L", "Regular", "/usr/share/fonts/type1/gsfonts/n022003l.pfb"
2: "Nimbus Mono L", "Bold", "/usr/share/fonts/type1/gsfonts/n022004l.pfb"
3: "Nimbus Mono L", "Regular Oblique", "/usr/share/fonts/type1/gsfonts/n022023l.pfb"
4: "DejaVu Sans Mono", "Book", "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"

Uname: Linux 2.6.31-16-generic i686
Package: fontconfig 2.6.0-1ubuntu12

Changed in fontconfig:
importance: Unknown → Medium
status: Invalid → Unknown
Changed in fontconfig:
importance: Medium → Unknown
Changed in fontconfig:
importance: Unknown → Medium
Changed in fontconfig:
status: Unknown → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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