On Monday 13 April 2009 09:10:23 Pierre Joye wrote:
> On Mon, Apr 13, 2009 at 5:56 PM, Ethan Merritt <merritt@...> wrote:
>> Is it true that libgd now looks for fontconfig?
> no, only if you tell it to do so.
I now see that Mojca has pointed out the function gdFTUseFontConfig(),
which I did not know about. This looks very promising, and I think we should
use it to try both the old (GDFONTPATH) and new (fontconfig) mechanisms when
looking for a user-specified font.
However, I coded up a quick test patch for gnuplot's gd driver and ran into
the following problem. Perhaps I am doing something wrong:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/* First try the old GDFONTPATH mechanism for locating fonts */
gdFTUseFontConfig(0);
err = gdImageStringFT(NULL, &brect[0], 0,
png_state.ttffont, (double)png_state.default_ttfsize,
0.0, 0, 0, "test");
/* If that didn't work, try again using fontconfig mechanism */
if (err && gdFTUseFontConfig(1)) {
err = gdImageStringFT(NULL, &brect[0], 0,
png_state.ttffont, (double)png_state.default_ttfsize,
0.0, 0, 0, "test");
fprintf(stderr,"fontconfig %s font %s\n",
err ? "did not find" : "found",
png_state.ttffont);
}
/* If we still haven't found the font, punt to the internal non-TTF default set */
if (err) {
fprintf(stderr,"%s when opening font \"%s\", using internal non-scalable font\n",
err, png_state.ttffont);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This works great the first time through. If the font is not found by file-name in
GDFONTPATH, then it switches over to use fontconfig and correctly finds the font.
However, on subsequent calls it fails if you do in fact provide a file name.
As best as I can make out, gdFTUseFontConfig(1) enables the fontconfig mechanism
but gdFTUseFontConfig(0) does not disable it again.
In fact, contrary to the documentation, passing 0 to gdFTUseFontConfig() seems to
enable fontconfig all by itself, so it is unsafe to use this for a test either.
Is that correct?
If so, is there a work-around?
Can we expect a fix?
Ethan
> On Mon, Apr 13, 2009 at 5:56 PM, Ethan Merritt <merritt@...> wrote:
> > Now I'm confused.
> > Is it true that libgd now looks for fontconfig?
> >
> >
> > ---------- Forwarded Message ----------
> >
> > Subject: [GD-DEVEL] Re: gd2 & fontconfig/freetype fail to find fonts on Mac OS X (macports)
> > Date: Monday 13 April 2009
> > From: Ryan Schmidt <ryandesign@...>
> > To: Mojca Miklavec <mojca.miklavec.lists@...>
> >
> > On Apr 13, 2009, at 01:47, Mojca Miklavec wrote:
> >
> >> I'm using Mac OS X 10.5 with GD installed via Macports
> >> (http://gd2.darwinports.com/) and as many others (I think both linux
> >> and mac users), I have problem using some deafult fonts inside gnuplot
> >> when using GD library to generate plots.
> >
> > Please do not refer to that web site for information about MacPorts.
> > That web site is not affiliated with the MacPorts project. For
> > information about MacPorts, go to
> >
> > http://www.macports.org/
> >
> > For more information on the web site that is not related to our
> > project, please read:
> >
> > http://trac.macports.org/wiki/DarwinPorts
> >
> >
> >>> gnuplot
> >>> set term png
> >> Terminal type set to 'png'
> >> Could not find/open font when opening font "arial", using internal
> >> non-scalable font
> >> Options are 'nocrop medium size 640,480 '
> >>
> >> Please note that this only happens with recent (maybe only
> >> development) version of gnuplot. I'm working with 4.3 from CVS. In
> >> past, gnuplot simply ignored the fact the GD was not able to find
> >> trutype fonts, it's only recently that it issues a warning.
> >>
> >> But the font in available on computer of course and "fc-list arial"
> >> returns this (+ dozens of translations):
> >>
> >> Arial:style=Bold Italic
> >> Arial:style=Italic
> >> Arial:style=Regular
> >> Arial:style=Bold
> >>
> >> Following instructions on http://www.libgd.org/DOC_INSTALL_OSX I
> >> tried to set
> >> export GDFONTPATH=$HOME/Library/Fonts:/Library/Fonts:/System/
> >> Library/Fonts
> >> and afterwards it worked OK.
> >>
> >> But the main question is: why doesn't GD find the font out-of-the-box,
> >> without having to give it a hint about GDFONTPATH? It may be a problem
> >> with configuration in macports that ships this library, but it
> >> probably makes more sense to ask here first. I can try to play a bit
> >> with installation following your instructions and then ask on macports
> >> to change some bits in configuration if needed.
> >
> > What I understand from reading that DOC_INSTALL_OSX page you
> > referenced above is that setting GDFONTPATH is only necessary if
> > fontconfig cannot be found. But the gd2 port does declare a
> > dependency on the fontconfig port so it should be there.
> >
> > If there is something I need to change in the gd2 port or the
> > fontconfig port related to this, please copy me on the replies; I am
> > not subscribed to the gd-devel mailing list.
> >
> >
> >
> > --
> > GD Devel Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > -------------------------------------------------------
> >
> > --
> > Ethan A Merritt
> > Biomolecular Structure Center
> > University of Washington, Seattle 98195-7742
> >
> > ------------------------------------------------------------------------------
> > This SF.net email is sponsored by:
> > High Quality Requirements in a Collaborative Environment.
> > Download a free trial of Rational Requirements Composer Now!
> > http://p.sf.net/sfu/www-ibm-com
> > _______________________________________________
> > gnuplot-beta mailing list
> > gnuplot-beta@...
> > https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
> >
>
>
>
> --
> Pierre
>
> http://blog.thepimp.net | http://www.libgd.org
>
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742
|