Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 462996 - sci-visualization/gnuplot - gd terminal should use fontconfig but erroneous version check prevents it
Summary: sci-visualization/gnuplot - gd terminal should use fontconfig but erroneous v...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Ulrich Müller
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2013-03-24 17:28 UTC by Bernardo Costa
Modified: 2013-03-26 07:35 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Change #ifdef condition to allow gd-2.0.35-r3's fontconfig mechanism (gnuplot-4.6.2-gdversion.patch,569 bytes, patch)
2013-03-24 17:30 UTC, Bernardo Costa
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bernardo Costa 2013-03-24 17:28:09 UTC
Gnuplot supports using fontconfig in gd terminals (png, gif, etc.) since commit http://gnuplot.cvs.sourceforge.net/viewvc/gnuplot/gnuplot/term/gd.trm?r1=1.135&r2=1.136 in 2009. At that time, there was a bug in media-libs/gd-2.0.35 that prevented this from working, and therefore they blocked the mechanism with some #ifdefs on GD_ version numbers. This is related in http://gnuplot.10905.n7.nabble.com/Fwd-GD-DEVEL-Re-gd2-amp-fontconfig-freetype-fail-to-find-fonts-on-Mac-OS-X-macports-td12375.html

Since, gentoo has backported the fix into media-libs/gd-2.0.35-r3 (bug #363367) so gentoo's test can be different.

Reproducible: Always

Steps to Reproduce:
1. have media-libs/gd-2.0.35-r3[fontconfig]
2. install gnuplot-4.6.2
3. run gnuplot
4. type "set term png"

Actual Results:  
gnuplot-gd fails ton find fonts with the following message:

Could not find/open font when opening font "arial", using internal non-scalable font

It searches some default (hard-coded in gd? in gnuplot?) paths (most of them very ancient as /usr/X11R6/lib/X11/fonts/Type1/ /usr/X11R6/lib/X11/fonts/TrueType/) 

Expected Results:  
Load the default font using fontconfig's search mechanism.
Comment 1 Bernardo Costa 2013-03-24 17:30:53 UTC
Created attachment 343122 [details, diff]
Change #ifdef condition to allow gd-2.0.35-r3's fontconfig mechanism

This is a very simple patch.

Enabling this should probably be conditionned to having gd-2.0.35-r3[fontconfig] installed, but I don't know how to do that. At the moment, this is the only version of gd in the portage tree, so perhaps just adding and epatch line is not a problem.
Comment 2 Christoph Junghans (RETIRED) gentoo-dev 2013-03-24 19:05:08 UTC
Patch looks ok to me, have you send it upstream?
Comment 3 Ulrich Müller gentoo-dev 2013-03-24 19:50:30 UTC
(In reply to comment #2)
> Patch looks ok to me, have you send it upstream?

If the backport of the bugfix to gd-2.0.35-r3 is Gentoo specific, then the patch shouldn't be sent upstream.

(In reply to comment #1)
> Enabling this should probably be conditionned to having
> gd-2.0.35-r3[fontconfig] installed, [...]

Linking against gd[-fontconfig] succeeds, so I wonder if we really need that USE dependency?
Comment 4 Bernardo Costa 2013-03-24 20:07:51 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Patch looks ok to me, have you send it upstream?
> 
> If the backport of the bugfix to gd-2.0.35-r3 is Gentoo specific, then the
> patch shouldn't be sent upstream.

Please note that the patch is for gnuplot-4.6.2, but otherwise, yes, I think this is pretty much gentoo-only.

Of course, we could also try to update gd to 2.0.36, which is out since 2007-11 or something like that (and at least 2008-09, per https://bitbucket.org/pierrejoye/gd-libgd/diff/NEWS?diff2=72f83e829f56&at=default)

> (In reply to comment #1)
> > Enabling this should probably be conditionned to having
> > gd-2.0.35-r3[fontconfig] installed, [...]
> 
> Linking against gd[-fontconfig] succeeds, so I wonder if we really need that
> USE dependency?

You're probably right, since then another #ifdef will fail (HAVE_GD_TTF) that will not include code containing anything enabled by the GD_versions check.

What does gnuplot tell you if you run my "set term png" experiment if it's linked to gd[-fontconfig] ? You would also have to try the GDFONTPATH way: setting it to something meaningful for you (such as /usr/share/fonts) and then passing a font such as 

$ GDFONTPATH=/usr/share/fonts gnuplot
[...]
gnuplot> set term png font "liberation-fonts/LiberationSans-Regular"
gnuplot> set output "/tmp/testgd.png"
gnuplot> plot sin(x)

This should produce a png with the chosen font, and if you skip the "font ..." part it should produce a png with the "default GD font"
Comment 5 Ulrich Müller gentoo-dev 2013-03-25 03:29:09 UTC
(In reply to comment #4)
> Of course, we could also try to update gd to 2.0.36, which is out since
> 2007-11 or something like that (and at least 2008-09, per
> https://bitbucket.org/pierrejoye/gd-libgd/diff/
> NEWS?diff2=72f83e829f56&at=default)

@vapier: Can you comment on this? The upstream status of gd isn't entirely clear to me.
Comment 6 SpanKY gentoo-dev 2013-03-25 21:04:34 UTC
(In reply to comment #5)

the OP's logic makes sense to me -- let's apply this patch to the Gentoo ebuild only and have the gd dep require >=gd-2.0.35-r3.

there doesn't appear to be a way to do runtime detection on whether the functionality is supported and/or works.  the flags bits go into libgd, but there's no way to read them back out.
Comment 7 Ulrich Müller gentoo-dev 2013-03-26 07:35:04 UTC
+*gnuplot-4.6.2-r1 (26 Mar 2013)
+
+  26 Mar 2013; Ulrich Müller <ulm@gentoo.org> +gnuplot-4.6.2-r1.ebuild,
+  +files/gnuplot-4.6.2-gdversion.patch:
+  Update test for GD version, bug 462996. Thanks to Bernardo Costa
+  <bernardofpc@gmail.com> for the bug report and the patch.
+

(In reply to comment #4)
> What does gnuplot tell you if you run my "set term png" experiment if it's
> linked to gd[-fontconfig] ? You would also have to try the GDFONTPATH way:
> setting it to something meaningful for you (such as /usr/share/fonts) and
> then passing a font such as 
> 
> $ GDFONTPATH=/usr/share/fonts gnuplot
> [...]
> gnuplot> set term png font "liberation-fonts/LiberationSans-Regular"
> gnuplot> set output "/tmp/testgd.png"
> gnuplot> plot sin(x)
> 
> This should produce a png with the chosen font, and if you skip the "font
> ..." part it should produce a png with the "default GD font"

Works for me (i.e. uses the chosen font) in both cases, with gd[fontconfig] and with gd[-fontconfig].