Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 301775 - media-libs/gd DEFAULT_PATH useless, perhaps provide GDFONTPATH?
Summary: media-libs/gd DEFAULT_PATH useless, perhaps provide GDFONTPATH?
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo Graphics Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-21 21:36 UTC by Fabian Groffen
Modified: 2010-12-01 11:48 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Groffen gentoo-dev 2010-01-21 21:36:44 UTC
Background:

gnuplot links against gd to do font resolution.  gd allows to use fontconfig for font resolution.  fontconfig has a proper search path with caches to find all installed fonts, great.  However, gd does not use fontconfig by default, each application needs to request this:
  http://lib.gd/Font#int_gdFTUseFontConfig.28int_flag.29_.28FUNCTION.29
gnuplot seems not to request this, hence gd falls back to doing a search itself.

The searchpath of gd is defined by DEFAULT_PATH in the source.  When already defined, it will take the set value (so we can override during the build).  This default is set to /usr/share/fonts/truetype.  After a quick question in #-dev it seems noone has this directory on all their machines checked.  Conclusion, the default is not helping any Gentoo user.  Unfortunately gd doesn't look recursively into subdirs, so setting the default to /usr/share/fonts won't help.  Initially I thought setting it to /usr/share/fonts/corefonts would make sense, but when others started suggesting dejavu, etc. I realised there is basically no good default for this, since it depends on the user.

At runtime the search path for gd when not using fontconfig can be overridden using GDFONTPATH.  I suggest, to make apps like gnuplot work by default as expected (and avoid elog messages about GDFONTPATH in the ebuild as such) by setting GDFONTPATH via env.d or something.  It's value should be updated by the font.eclass (in the font_xft_config function perhaps?) such that after resourcing, apps using gd without requesting fontconfig will find installed fonts.

I have no patches other than changing the default path in gd via the ebuild, as I first want to validate the idea and see how much support there is to solve it like this.
Comment 1 W. Trevor King 2010-09-17 02:01:59 UTC
> Unfortunately gd doesn't look recursively into subdirs, so setting
> the default to /usr/share/fonts won't help.

But you can look recursively when setting up GDFONTPATH in env.d:
  GDFONTPATH=""
  for x in $(find /usr/share/fonts/ -type d); do
      GDFONTPATH="$GDFONTPATH:$x"
  done
  GDFONTPATH="${GDFONTPATH:1}"
  export GDFONTPATH
Unfortunately, this would have to live in /etc/profile, since /etc/env.d/ only allows static definitions (I think).
Comment 2 SpanKY gentoo-dev 2010-09-17 04:52:24 UTC
where exactly do you see it being set to /usr/share/fonts/truetype ?  looks to me like the default is multiple paths and is perfectly sane.  adding stuff like that to env.d is not desirable at all.

$ grep -C 2 DEFAULT_FONTPATH.*True /usr/include/gd.h 
#ifndef DEFAULT_FONTPATH
/* default fontpath for unix systems  - whatever happened to standards ! */
#define DEFAULT_FONTPATH "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1"
#endif
#ifndef PATHSEPARATOR

$ strings /usr/lib/libgd.so | grep TrueType
/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1