Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Terrible PDF font kerning
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
mfdeakin
n00b
n00b


Joined: 08 Mar 2017
Posts: 5

PostPosted: Wed Mar 08, 2017 6:53 am    Post subject: [SOLVED] Terrible PDF font kerning Reply with quote

Hi,

Many (but not all; ones produced by TeX look fine) PDFs have terrible font kerning issues in multiple pdf renderers (qpdfview and Chromium's pdf reader produce identical results) for me. See the following image for an example http://i.imgur.com/kY5gSad.png
I've had this issue for years, and failed to find a solution in my previous searches, as similar issues don't seem to be the same (they're either not as bad or bad differently).
Have any of you seen something similar to this or had instructions on how to fix this?

Here's my configure options for poppler:
[ebuild R ~] app-text/poppler-0.52.0:0/66::gentoo USE="cairo cxx introspection jpeg jpeg2k lcms png qt4 tiff utils -cjk -curl -debug -doc -nss -qt5" 0 KiB

In case it's relevant, here's eselect fontconfig list:
Available fontconfig .conf files (* is enabled):
[1] 09-texlive.conf
[2] 10-autohint.conf
[3] 10-no-sub-pixel.conf
[4] 10-scale-bitmap-fonts.conf
[5] 10-sub-pixel-bgr.conf
[6] 10-sub-pixel-rgb.conf
[7] 10-sub-pixel-vbgr.conf
[8] 10-sub-pixel-vrgb.conf
[9] 10-unhinted.conf
[10] 11-lcdfilter-default.conf
[11] 11-lcdfilter-legacy.conf
[12] 11-lcdfilter-light.conf
[13] 20-unhint-small-vera.conf
[14] 25-unhint-nonlatin.conf
[15] 30-metric-aliases.conf
[16] 30-urw-aliases.conf
[17] 40-nonlatin.conf
[18] 45-latin.conf
[19] 49-sansserif.conf
[20] 50-user.conf
[21] 51-local.conf
[22] 59-google-droid-sans-mono.conf *
[23] 59-google-droid-sans.conf *
[24] 59-google-droid-serif.conf *
[25] 60-latin.conf
[26] 60-liberation.conf
[27] 61-stix.conf
[28] 65-fonts-persian.conf
[29] 65-khmer.conf
[30] 65-nonlatin.conf
[31] 69-unifont.conf
[32] 70-no-bitmaps.conf
[33] 70-yes-bitmaps.conf
[34] 75-yes-terminus.conf
[35] 80-delicious.conf
[36] 90-synthetic.conf
[37] 99pdftoopvp.conf


Thanks in advance


Last edited by mfdeakin on Sat Mar 11, 2017 4:32 am; edited 2 times in total
Back to top
View user's profile Send private message
ct85711
Veteran
Veteran


Joined: 27 Sep 2005
Posts: 1791

PostPosted: Wed Mar 08, 2017 7:14 am    Post subject: Reply with quote

From what I am understanding, the are complaining about the ligatures, explained and shown here:
http://tex.stackexchange.com/questions/297426/spacing-between-letters-ligature

This post explains more on how to work around/disable it some.
http://tex.stackexchange.com/questions/1841/how-can-i-completely-suppress-ligatures

If I am misunderstanding, please explain (and maybe an image) pointing the what the issue is.
Back to top
View user's profile Send private message
mfdeakin
n00b
n00b


Joined: 08 Mar 2017
Posts: 5

PostPosted: Wed Mar 08, 2017 3:34 pm    Post subject: Reply with quote

ct85711 wrote:
From what I am understanding, the are complaining about the ligatures, explained and shown here:
http://tex.stackexchange.com/questions/297426/spacing-between-letters-ligature

This post explains more on how to work around/disable it some.
http://tex.stackexchange.com/questions/1841/how-can-i-completely-suppress-ligatures

If I am misunderstanding, please explain (and maybe an image) pointing the what the issue is.

I'm fairly certain these are not ligatures, the image I linked (the same as previously: http://i.imgur.com/kY5gSad.png) to has an example where there's a space between the words "principal means" but it is rendered as "principalm eans"
Also, pdfs produced with TeX do not seem to have this issue
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Wed Mar 08, 2017 4:06 pm    Post subject: Reply with quote

mfdeakin,

Fonts confuse me. If I understand you correctly, your problem is at the creation stage rather than the rendering stage. It's probably not relevant in your case, but I was seeing something a bit like your problem when I use Microsoft Word 2007 under WINE in Gentoo and saved my files to PDF; when the document contained 'smart quotes' (curly quotes) the kerning of the line was messed up badly. Once I changed the quotes in the documents to 'straight quotes' it resolved the problem. What I was having a lot of trouble with on my Compal NBLB2 laptop was the quality of the rendering of the font -- rather than its kerning -- which I resolved by remerging media-libs/freetype with the USE flag selection shown below and changing to the Infinality fonts:

Code:
$ eix -I freetype
[I] media-libs/freetype
     Available versions:  (2) 2.6.3-r1^d (~)2.6.5^d (~)2.7.1-r1^d **9999^d
       {X +adobe-cff bindist bzip2 (+)cleartype_hinting debug doc fontforge harfbuzz infinality png static-libs utils ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  2.7.1-r1(2)^d(18:07:36 03/03/17)(X adobe-cff bzip2 harfbuzz infinality png static-libs utils -bindist -cleartype_hinting -debug -doc -fontforge ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
     Homepage:            http://www.freetype.org/
     Description:         A high-quality and portable font engine

Code:
$ eix -I fontconfig
[I] app-eselect/eselect-fontconfig
     Available versions:  1.0 1.1 (~)1.1-r1
     Installed versions:  1.1-r1(18:27:26 31/12/15)
     Homepage:            https://www.gentoo.org
     Description:         An eselect module to manage /etc/fonts/conf.d symlinks

[I] media-libs/fontconfig
     Available versions:  (1.0) 2.11.1-r2 (~)2.12.0 (~)2.12.1
       {doc static-libs ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  2.12.1(1.0)(20:04:56 10/08/16)(-doc -static-libs ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
     Homepage:            http://fontconfig.org/
     Description:         A library for configuring and customizing font access

[I] media-libs/fontconfig-infinality
     Available versions:  20120619 20130404 {+nyx}
     Installed versions:  20130404(18:07:54 03/03/17)(nyx)
     Homepage:            http://www.infinality.net/blog/infinality-freetype-patches/
     Description:         Configuration to be used in conjunction with the freetype-infinality subpixel hinting

Found 3 matches

Code:
$ eix -I infinality
[I] app-eselect/eselect-infinality
     Available versions:  1
     Installed versions:  1(18:05:51 03/03/17)
     Homepage:            https://github.com/yngwin/eselect-infinality
     Description:         Eselect module to choose an infinality font configuration style

[I] media-libs/fontconfig-infinality
     Available versions:  20120619 20130404 {+nyx}
     Installed versions:  20130404(18:07:54 03/03/17)(nyx)
     Homepage:            http://www.infinality.net/blog/infinality-freetype-patches/
     Description:         Configuration to be used in conjunction with the freetype-infinality subpixel hinting

Found 2 matches

Code:
$ eselect fontconfig list | grep '\*'
Available fontconfig .conf files (* is enabled):
  [28]  52-infinality.conf *
$

Code:
$ eselect infinality list | grep '\*'
  [2]   infinality *
$

Code:
$ eselect lcdfilter list | grep '\*'
  [3]   infinality *
$

I have no idea if what I did to fix my problem would help in your case, but it might be worth a shot.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Wed Mar 08, 2017 6:22 pm    Post subject: Reply with quote

That looks nasty. It looks like it's switching between fonts in the middle of the sentence but using the metrics from only one of them? In Chromium you should be able to right click and open the PDF in the dev console to see which fonts it's trying to use, that might help to see what's wrong.
Back to top
View user's profile Send private message
mfdeakin
n00b
n00b


Joined: 08 Mar 2017
Posts: 5

PostPosted: Thu Mar 09, 2017 7:06 am    Post subject: Reply with quote

The PDF I took a picture of was using the Roboto medium and regular fonts, if I understand chromium's dev console correctly. I don't have the roboto font package installed, so I assume I do understand and that it's using the version embedded in the PDF.
I should also note that while I'm not certain what the cause of the problem is, it appears that it might be font specific, as some text in the PDF is not mangled.
I don't think it's fair to say the issue is with the creation of the PDF, as these PDFs render normally on any other computer or OS.

Here is some more information on possibly relevant packages:
Code:

[?] media-libs/freetype
     Available versions:  (2) 2.5.5^d
       {X +adobe-cff auto-hinter bindist bzip2 debug doc fontforge harfbuzz infinality png static-libs utils ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  2.6.3-r1(2)^d(07:40:04 AM 09/28/2016)(X adobe-cff bzip2 png -bindist -debug -doc -fontforge -harfbuzz -infinality -static-libs -utils ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
     Homepage:            http://www.freetype.org/
     Description:         A high-quality and portable font engine

[I] media-libs/fontconfig
     Available versions:  (1.0) 2.11.1-r2 ~2.11.93
       {doc static-libs ABI_MIPS="n32 n64 o32" ABI_PPC="32 64" ABI_S390="32 64" ABI_X86="32 64 x32"}
     Installed versions:  2.11.1-r2(1.0)(07:43:47 AM 09/28/2016)(-doc -static-libs ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
     Homepage:            http://fontconfig.org/
     Description:         A library for configuring and customizing font access

[I] media-fonts/anonymous-pro
     Available versions:  1.002-r1^bs {X}
     Installed versions:  1.002-r1^bs(07:47:08 AM 09/28/2016)(X)
     Homepage:            http://www.marksimonson.com/fonts/view/anonymous-pro
     Description:         Monospaced truetype font designed with coding in mind

[I] media-fonts/droid
     Available versions:  113-r3 113-r4 {X}
     Installed versions:  113-r4(07:46:45 AM 09/28/2016)(X)
     Homepage:            http://code.google.com/android/RELEASENOTES.html http://www.cosmix.org/software/
     Description:         Font family from Google's Android project

[I] media-fonts/encodings
     Available versions:  1.0.4
     Installed versions:  1.0.4(07:44:59 AM 09/28/2016)
     Homepage:            http://xorg.freedesktop.org/
     Description:         X.Org font encodings

[?] media-fonts/font-util
     Available versions:  1.3.0 ~1.3.1
     Installed versions:  1.3.1(07:22:30 AM 09/28/2016)
     Homepage:            http://xorg.freedesktop.org/
     Description:         X.Org font utilities

[I] media-fonts/freefonts
     Available versions:  0.10-r3 {X}
     Installed versions:  0.10-r3(07:47:19 AM 09/28/2016)(X)
     Homepage:            http://www.gimp.org
     Description:         A Collection of Free Type1 Fonts

[I] media-fonts/freefonts
     Available versions:  0.10-r3 {X}
     Installed versions:  0.10-r3(07:47:19 AM 09/28/2016)(X)
     Homepage:            http://www.gimp.org
     Description:         A Collection of Free Type1 Fonts

[I] media-fonts/inconsolata
     Available versions:  20090222^bs 20140821^bst {X}
     Installed versions:  20140821^bst(07:46:35 AM 09/28/2016)(X)
     Homepage:            http://www.google.com/fonts/specimen/Inconsolata https://code.google.com/p/googlefontdirectory/source/browse/ofl/inconsolata/?name=default
     Description:         A beautiful sans-serif monotype font designed for code listings

[I] media-fonts/liberation-fonts
     Available versions:  ~1.07.4 2.00.0-r1 2.00.1-r1 {X fontforge}
     Installed versions:  2.00.1-r1(07:45:56 AM 09/28/2016)(X -fontforge)
     Homepage:            https://fedorahosted.org/liberation-fonts
     Description:         A Helvetica/Times/Courier replacement TrueType font set, courtesy of Red Hat

[?] media-fonts/noto
     Available versions:  2014.11^bs 2015.04^bs {X}
     Installed versions:  20160305-r1^bs(07:47:30 AM 09/28/2016)(X -cjk)
     Homepage:            https://www.google.com/get/noto/
     Description:         Google's font family that aims to support all the world's languages

[?] media-fonts/noto
     Available versions:  2014.11^bs 2015.04^bs {X}
     Installed versions:  20160305-r1^bs(07:47:30 AM 09/28/2016)(X -cjk)
     Homepage:            https://www.google.com/get/noto/
     Description:         Google's font family that aims to support all the world's languages

[?] media-fonts/stix-fonts
     Available versions:  1.0.0-r1^bs ~1.1.1^bst {X doc}
     Installed versions:  1.1.1^bst(04:06:30 PM 12/18/2016)(X)
     Homepage:            http://www.stixfonts.org/
     Description:         Comprehensive OpenType font set of mathematical symbols and alphabets

[I] media-fonts/terminus-font
     Available versions:  4.36 4.38 ~4.39 4.39-r1 {X a-like-o +center-tilde distinct-l +pcf +pcf-unicode-only +psf quote raw-font-data ru-dv +ru-g ru-i ru-k}
     Installed versions:  4.39-r1(07:46:58 AM 09/28/2016)(X center-tilde pcf pcf-unicode-only psf ru-g -a-like-o -distinct-l -quote -raw-font-data -ru-dv -ru-i -ru-k)
     Homepage:            http://terminus-font.sourceforge.net/
     Description:         A clean fixed font for the console and X11

[I] media-fonts/ttf-bitstream-vera
     Available versions:  1.10-r3 {X}
     Installed versions:  1.10-r3(07:46:25 AM 09/28/2016)(X)
     Homepage:            http://www.gnome.org/fonts/
     Description:         Bitstream Vera font family

[I] media-fonts/urw-fonts
     Available versions:  2.4.9 {X}
     Installed versions:  2.4.9(07:45:45 AM 09/28/2016)(X)
     Homepage:            http://www.urwpp.de/
     Description:         free good quality fonts gpl'd by URW++

Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Mar 09, 2017 9:38 am    Post subject: Reply with quote

mfdeakin wrote:
The PDF I took a picture of was using the Roboto medium and regular fonts, if I understand chromium's dev console correctly. I don't have the roboto font package installed, so I assume I do understand and that it's using the version embedded in the PDF.

mfdeakin ... there probably isn't an embeded font, if the font can't be found a substitute is provided (that is what some *.conf in 'eselect fontconfig' enable). If the following produces a more readable output then it is a font subsitution issue (requires app-text/ghostscript-gpl):

Code:
% gs -o filename-repaired.pdf -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite filename.pdf

mfdeakin wrote:
I should also note that while I'm not certain what the cause of the problem is, it appears that it might be font specific, as some text in the PDF is not mangled. I don't think it's fair to say the issue is with the creation of the PDF, as these PDFs render normally on any other computer or OS.

These other OSes will have different fonts, and different mechanisms by which font substitution occurs.

BTW, rather than use chromium's dev console you can do the following to see what fonts the pdf uses:

Code:
% pdffonts filename.pdf

best ... khay
Back to top
View user's profile Send private message
mfdeakin
n00b
n00b


Joined: 08 Mar 2017
Posts: 5

PostPosted: Thu Mar 09, 2017 3:53 pm    Post subject: Reply with quote

khayyam, replacing the fonts did fix my issue in this PDF, so it is a font substitution problem! Thanks! How would I fix this in a more permanent manner? I've tried changing what's available in 'eselect fontconfig', but that didn't seem to fix the issue in the past. Installing the roboto font does fix it for this font, but I'd rather not have to install all of the fonts to fix this permanently.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Mar 09, 2017 5:50 pm    Post subject: Reply with quote

mfdeakin wrote:
khayyam, replacing the fonts did fix my issue in this PDF, so it is a font substitution problem! Thanks! How would I fix this in a more permanent manner? I've tried changing what's available in 'eselect fontconfig', but that didn't seem to fix the issue in the past. Installing the roboto font does fix it for this font, but I'd rather not have to install all of the fonts to fix this permanently.

mfdeakin ... you might try enabling '30-metric-aliases.conf', this provides metric and shape compatible fonts for some adobe/microsoft font families (and so substitutes/fallbacks to URW, liberation, etc). I expect this will resolve the issue with most pdf's ... if it doesn't then some form of 'alias' might be applied via ~/.fonts.conf.

Also, you probably also want some form of hinting, ie lcdfilter, or infinality, enabled.

HTH & best ... khay
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Thu Mar 09, 2017 7:34 pm    Post subject: Reply with quote

The roboto font itself is pretty badly kerned, that's probably contributing to the problem here. Unfortunately it looks like all good-looking versions of it (version numbers were YYYY.MM) have been removed from the tree...
Back to top
View user's profile Send private message
mfdeakin
n00b
n00b


Joined: 08 Mar 2017
Posts: 5

PostPosted: Fri Mar 10, 2017 2:40 am    Post subject: Reply with quote

Enabling '30-metric-aliases.conf' did fix my issue even after uninstalling the (frankly bad as Ant mentioned) Roboto font; at least for this PDF. Thanks for the help!
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Fri Mar 10, 2017 8:30 am    Post subject: Reply with quote

mfdeakin wrote:
Enabling '30-metric-aliases.conf' did fix my issue even after uninstalling the (frankly bad as Ant mentioned) Roboto font; at least for this PDF. Thanks for the help!

mfdeakin ... ok, good. You should mark the thread as '[SOLVED]' (edit the first post and add to subject line).

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum