Bug#837315: gnuplot-nox: possibly unnecessary patch 05_default_gd_font.diff
Fabian Greffrath
fabian at debian.org
Sat Sep 10 13:14:41 UTC 2016
Package: gnuplot-nox
Version: 5.0.4+dfsg1-3
Severity: minor
Hi there,
I believe the patch 05_default_gd_font.diff that is applied to the
Debian gnuplot package is not necessary (anymore?). In turn, I believe
it is even quite counter-productive.
Let's have a look at the code that the patch changes:
if (external_default)
png_state.ttffont = gp_strdup(external_default);
else /* Might as well try some plausible font; it's no orse than failing immediately */
png_state.ttffont = gp_strdup("arial");
free(png_state.default_ttffont);
png_state.default_ttffont = gp_strdup(png_state.ttffont);
if (png_state.default_ttfsize == 0)
png_state.default_ttfsize = 2 * term->h_char - 2;
/* First try the old GDFONTPATH mechanism for locating fonts */
(void)gdUseFontConfig(0);
err = gdImageStringFT(NULL, &brect[0], 0,
png_state.ttffont, (double)png_state.default_ttfsize*png_state.fontscale,
0.0, 0, 0, "test");
/* If that didn't work, try again using fontconfig mechanism */
if (err && gdUseFontConfig(1)) {
err = gdImageStringFT(NULL, &brect[0], 0,
png_state.ttffont, (double)png_state.default_ttfsize*png_state.fontscale,
0.0, 0, 0, "test");
}
In the first paragraph, if the external_default variable isn't set,
the png_state.ttffont pointer is set to point to the string "arial".
This is the string that is replaced by the patch in question by the
actual path name of the Sans Liberation Regular TTF font file.
Let's ignore the second paragraph.
The third paragraph attempts to locate a font by that name *without*
using fontconfig. This is probably about to fail for "arial" as well
as for most other fonts, as the number of font names recognized by the
gd library itself is rather limited. This paragraph is probably only
interesting if the external_default variable is set.
In the fourth paragraph the font location is attempted again, this
time using fontconfig. This is the most interesting part of the code.
As the gd library in Debian is configured with fontconfig support, it
will try to find the font that matches the search pattern "arial" as
good as possible. On most systems which have fonts-liberation
installed, it will most probably return Liberation Sans Regular, which
is exactly what the patch attempts to achieve. But if you have the
actual Arial font from the msttcorefonts package installed, it will
find and use this. And if you have neither the original Arial nor the
Liberation Sans replacement installed, it will find another font that
matches Arial as closely as possible, because it has dozens of rules
to determine which font is a good replacement for what.
This is where the patch becomes counter-productive: By passing the
full path to the Liberation font to fontconfig, you take away its
ability to substitute this font for something similar and force it to
fall back to the default font if the requested one is not found.
TL;DR: Please consider disabling this patch. Fontconfig already does
what this patch wants to achieve and acts more reasonable if the font
that is hard-coded by the patch cannot be found.
Thanks,
Fabian
-- System Information:
Debian Release: stretch/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'experimental'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
More information about the debian-science-maintainers
mailing list