[poppler] Question regarding font selection
Pierre-Luc Samuel
Pierre-Luc.Samuel at ticketmaster.com
Tue Jul 11 17:25:31 UTC 2017
Hi,
After much debugging, I have found the problem with font selection. It
seems to be related to fontconfig version 2.11.0. The root cause is the
handling of the "spacing" parameter.
$ fc-match -s "Courier" | head -5
n022003l.pfb: "Nimbus Mono L" "Regular"
Courier_New.ttf: "Courier New" "Normal"
Courier_New_Italic.ttf: "Courier New" "Cursiva"
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
$ fc-match -s "Courier:spacing=100" | head -5
n022024l.pfb: "Nimbus Mono L" "Bold Oblique"
n022003l.pfb: "Nimbus Mono L" "Regular"
Courier_New.ttf: "Courier New" "Normal"
Courier_New_Italic.ttf: "Courier New" "Cursiva"
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
$ fc-match -s "Courier:weight=80:spacing=100" | head -5
n022024l.pfb: "Nimbus Mono L" "Bold Oblique"
n022003l.pfb: "Nimbus Mono L" "Regular"
Courier_New.ttf: "Courier New" "Normal"
Courier_New_Italic.ttf: "Courier New" "Cursiva"
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
Problem #1 is that "Nimbus Mono L Bold Oblique" doesn't declare a
"spacing" parameter; it seems its not even a real monospace font.
Problem #2 is that fc-match goes bonkers when we ask for spacing but it
doesn't find one; it wrongly orders the BoldOblique as the first font.
Poppler always requests with a spacing, which triggers the bug. That
problem is fixed in fontconfig 2.11.93.
Even though Debian Stretch was released very recently, they only bundle
fontconfig 2.11.0, so I have forced installed a newer version.
I hope this helps someone else, and thanks for the help.
Pierre-Luc
On 17-07-07 04:24 PM, Pierre-Luc Samuel wrote:
> [This sender failed our fraud detection checks and may not be who they
> appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing]
>
> On 17-07-06 07:39 AM, William Bader wrote:
>>
>> > Interesting, I did not know about this command. Here's the output I
>> get:
>> > Courier 7 0 Nimbus Mono L Bold
>> /usr/local/share/fonts/ghostscript/fonts/n022004l.pfb
>>
>>
>> If it shows /usr/local/share instead of /usr/share, it is coming from
>> a package that you installed rather than a package that came with the
>> distribution, and the problem could be customizations that you made to
>> your system rather than problems with poppler.
>>
>> On Fedora 25, /usr/share/fonts/default/Type1/n022023l.pfb is provided
>> by urw-fonts
>>
>> If it works for most people, the problem is probably something that
>> you did to your system, and the easiest way to track it down might be
>> getting the customized packages out of the path and then adding them
>> back one by one until you find the one that causes the problem.
>>
>> You can use an strace command like the one below to see everything
>> that pdffonts touches
>>
>> strace -e trace=open pdffonts file.pdf 2>&1 | less
>>
>> Could you check that you have your distribution's fonts installed,
>> then temporarily rename /usr/local to get it off the path, and then
>> try pdffonts again?
>
>
> OK I have rebuilt my image, now I have only a raw Debian Stretch with
> packages fontconfig, poppler-utils, strace, less and gsfonts-x11 (which
> seems to be the equivalent for urw-fonts). The situation is even worse
> now because only the Bold Oblique font gets selected now.
>
> Here's the output of strace:
>
> $ strace -e trace=open pdffonts ./courier.pdf -subst 2>&1
> open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libpoppler.so.64", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/liblcms2.so.2", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libtiff.so.5", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libjpeg.so.62", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libpng16.so.16", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libnss3.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libnssutil3.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libsmime3.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libssl3.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libplds4.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libplc4.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libnspr4.so", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libopenjp2.so.7", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libfreetype.so.6", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libjbig.so.0", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
> open("/lib/x86_64-linux-gnu/libexpat.so.1", O_RDONLY|O_CLOEXEC) = 3
> open("/usr/share/poppler/nameToUnicode",
> O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
> open("/usr/share/poppler/nameToUnicode/Thai", O_RDONLY) = 4
> open("/usr/share/poppler/nameToUnicode/Bulgarian", O_RDONLY) = 4
> open("/usr/share/poppler/nameToUnicode/Greek", O_RDONLY) = 4
> open("/usr/share/poppler/cidToUnicode",
> O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
> open("/usr/share/poppler/unicodeMap",
> O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
> open("/usr/share/poppler/cMap",
> O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
> open("./courier.pdf", O_RDONLY) = 3
> open("/etc/fonts/fonts.conf", O_RDONLY|O_CLOEXEC) = 4
> open("/etc/fonts/conf.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
> open("/etc/fonts/conf.d/10-scale-bitmap-fonts.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/11-lcdfilter-default.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-dejavu-lgc-sans-mono.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-dejavu-lgc-sans.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-dejavu-lgc-serif.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-dejavu-sans-mono.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-dejavu-sans.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-dejavu-serif.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/20-unhint-small-vera.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/30-metric-aliases.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/30-urw-aliases.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/40-nonlatin.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/45-latin.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/49-sansserif.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/50-user.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/51-local.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/57-dejavu-sans-mono.conf", O_RDONLY|O_CLOEXEC)
> = 6
> open("/etc/fonts/conf.d/57-dejavu-sans.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/57-dejavu-serif.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/58-dejavu-lgc-sans-mono.conf",
> O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/58-dejavu-lgc-sans.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/58-dejavu-lgc-serif.conf", O_RDONLY|O_CLOEXEC)
> = 6
> open("/etc/fonts/conf.d/60-latin.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/65-fonts-persian.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/65-nonlatin.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/69-unifont.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/70-no-bitmaps.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/80-delicious.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/etc/fonts/conf.d/90-synthetic.conf", O_RDONLY|O_CLOEXEC) = 6
> open("/usr/share/fonts", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//3830d5c3ddfd5cd38a049b759396e72e-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/local/share/fonts", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//4c599c202bc5c08e2d34565a40eac3b2-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/X11", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//c855463f699352c367813e37f3f70ea7-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/cmap", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//57e423e26b20ab21d0f2f29c145174c3-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/truetype", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//7ef2298fde41cc6eeb7af42e48b7d293-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/type1", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//d82eb4fd963d448e2fcb7d7b793b5df3-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/X11/Type1", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//e13b20fdb08344e0e664864cc2ede53d-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/X11/encodings", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//707971e003b4ae6c8121c3a920e507f5-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/X11/util", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//fe547fea3a41b43a38975d292a2b19c7-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/cmap/adobe-cns1", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//f1f2465696798768e9653f19e17ccdc8-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/cmap/adobe-gb1", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//95530828ff6c81d309f8258d8d02a23e-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/cmap/adobe-japan1", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//d3e5c4ee2ceb1fc347f91d4cefc53bc0-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/cmap/adobe-japan2", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//e52a45a1c8c8fe895fc0fc8c4e6999b8-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/cmap/adobe-korea1", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//188ac73a183f12857f63bb60a4a6d603-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/truetype/dejavu", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//d589a48862398ed80a3d6066f4f56f4c-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/type1/gsfonts", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//945677eb7aeaf62f1d50efc3fb3ec7d8-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> open("/usr/share/fonts/X11/encodings/large", O_RDONLY|O_CLOEXEC) = 4
> open("/var/cache/fontconfig//6333f38776742d18e214673cd2c24e34-le64.cache-4",
>
> O_RDONLY|O_CLOEXEC) = 4
> name object ID substitute
> font substitute font file
> ------------------------------------ ---------
> ------------------------------------ ------------------------------------
> Courier 7 0 Nimbus Mono L Bold
> Oblique /usr/share/fonts/X11/Type1/n022024l.pfb
> Courier-Bold 8 0 Nimbus Mono L Bold
> Oblique /usr/share/fonts/X11/Type1/n022024l.pfb
> Courier-Oblique 9 0 Nimbus Mono L Bold
> Oblique /usr/share/fonts/X11/Type1/n022024l.pfb
> Courier-BoldOblique 10 0 Nimbus Mono L Bold
> Oblique /usr/share/fonts/X11/Type1/n022024l.pfb
>
>
>
>
>>
>> ------------------------------------------------------------------------
>> *From:* poppler <poppler-bounces at lists.freedesktop.org> on behalf of
>> Pierre-Luc Samuel <Pierre-Luc.Samuel at ticketmaster.com>
>> *Sent:* Wednesday, July 5, 2017 3:47 PM
>> *To:* poppler at lists.freedesktop.org
>> *Subject:* Re: [poppler] Question regarding font selection
>>
>>
>> On 17-07-05 01:10 PM, Jason Crain wrote:
>> > On Wed, Jul 05, 2017 at 10:45:07AM -0400, Pierre-Luc Samuel wrote:
>> >> On 17-07-04 06:43 PM, Albert Astals Cid wrote:
>> >>> El dimarts, 4 de juliol de 2017, a les 17:06:07 CEST, Pierre-Luc
>> Samuel va
>> >>> escriure:
>> >>>> I am experiencing weird font substitution with pdftocairo and was
>> >>>> wondering what was the algorithm to match fonts when converting
>> from
>> >>>> PDF. The Courier font (regular) is being substituted "Nimbus
>> Mono L
>> >>>> Bold", even if fc-match return the non-bold version.
>> >>>>
>> >>>> $ fc-match "Courier"
>> >>>> n022003l.pfb: "Nimbus Mono L" "Regular"
>> >>>>
>> >>>> $ fc-match "Courier:style=bold"
>> >>>> n022004l.pfb: "Nimbus Mono L" "Bold"
>> >>>>
>> >>>> What could be the reason behind this?
>> >>> The pdf font can be asking for bold even if the name doesn't
>> contain bold.
>> >>>
>> >> Thanks for your answer Albert. I have attached a sample PDF and
>> resulting
>> >> SVG with the problem I'm encountering. I do not understand why the
>> bold
>> >> font is selected for the first "Courier".
>> >>
>> >> pdftocairo version 0.56.0
>> > It works for me:
>> >
>> > $ pdffonts ~/courier.pdf -subst
>> > name object ID substitute
>> font substitute font file
>> > ------------------------------------ ---------
>> ------------------------------------
>> ------------------------------------
>> > Courier 7 0 Nimbus Mono L
>> /usr/share/fonts/type1/gsfonts/n022003l.pfb
>> > Courier-Bold 8 0 Nimbus Mono L Bold
>> /usr/share/fonts/type1/gsfonts/n022004l.pfb
>> > Courier-Oblique 9 0 Nimbus Mono L Regular
>> Oblique /usr/share/fonts/type1/gsfonts/n022023l.pfb
>> > Courier-BoldOblique 10 0 Nimbus Mono L Bold
>> Oblique /usr/share/fonts/type1/gsfonts/n022024l.pfb
>> >
>> > With versions 0.48.0 and from git master.
>>
>> Interesting, I did not know about this command. Here's the output I get:
>>
>>
>> name object ID substitute
>> font substitute font file
>> ------------------------------------ ---------
>> ------------------------------------
>> ------------------------------------
>> Courier 7 0 Nimbus Mono L Bold
>> /usr/local/share/fonts/ghostscript/fonts/n022004l.pfb
>> Courier-Bold 8 0 Nimbus Mono L Bold
>> /usr/local/share/fonts/ghostscript/fonts/n022004l.pfb
>> Courier-Oblique 9 0 Nimbus Mono L Regular
>> Oblique /usr/local/share/fonts/ghostscript/fonts/n022023l.pfb
>> Courier-BoldOblique 10 0 Nimbus Mono L Bold
>> Oblique /usr/local/share/fonts/ghostscript/fonts/n022024l.pfb
>>
>> Pierre-Luc
>> _______________________________________________
>> poppler mailing list
>> poppler at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/poppler
>> poppler Info Page - freedesktop.org
>> <https://lists.freedesktop.org/mailman/listinfo/poppler>
>> lists.freedesktop.org
>> Subscribing to poppler: Subscribe to poppler by filling out the
>> following form. Use of all freedesktop.org lists is subject to our
>> Code of ...
>>
>>
>>
>
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler
More information about the poppler
mailing list