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.
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.
Patch looks ok to me, have you send it upstream?
(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?
(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"
(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.
(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.
+*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].