[mapserver-users] on truetype fonts

Rodrigo Becke Cabral cabral at cttmar.univali.br
Wed Oct 3 16:55:25 EDT 2001


The following facts are from my tests using mapserver 3.5 with gd 2.0.1 and
freetype 2.0.4. I would appreciate if someone could either confirm the facts
or point out my mistakes.

-- force and postlabelcache

When force or postlabelcache are set true in layer, truetype font errors are
not displayed. when I comment them off, the error appears properly (which
was "msGetLabelSize(): TrueType Font error. Could not find/open font" in my
case). This also occurs with gd 1.2 and freetype 1.3.1, so it's a specific
MapServer thing. Maybe ttf errors should always be displayed - otherwise
one would think that the problem is with their shape data.

-- ms35png_nightly.zip

First, I double-checked 'mapserv' version:
> mapserv -v
MapServer version 3.5 (pre-alpha) OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
SUPPORTS=PROJ SUPPORTS=TTF INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=SHAPEFILE

But when I try to use it with truetype fonts (see SUPPORTS=TTF) the
following error appears:
msGetLabelSize(): TrueType Font error. libgd was not built with TrueType
font support.
That's "almost" weird, I guess.

-- TrueType Font error. Could not find/open font

Now that was a difficult error for me to find out. Why is that? I few months
ago I setup a whole mapserver 3.5 working environment (shapes+fonts+map).
Last week, I downloaded the latest nightly.tar.gz and after I recompiled and
installed it, truetype labels in my previously-working setup disappeared.
First, because I had 'force' set 'true' in 'layer', I didn't get the ttf
error from the beginning, so I thought I had messed up my compilation,
libraries, stuff... Anyway, after I got to the actual error, I decided to
look in the mapserver-user archives to see if someone had had the same
problem I had. Indeed, the archives had some answers, but I decided to dig
in and find out exactly why my mapserver setup was working before, and now
it wasn't. Here's why: current GD versions (either 1.8 or 2) don't deal
with relative paths. "gdft.c" resolves the font path supplied by mapserver
in two ways. Either applying it directly - but only if the path begins with
"/"; or after prepending a DEFAULTPATH which by default is
"/usr/share/fonts/truetype". Path separator is ":", so forget about
providing a fullpath in windows (C:\X) would become two paths to be tested
(C and \X).

But why my setup was working before? Not sure, maybe I was using
gd-1.2 which simply applies the supplied fontpath directly. The point is,
right now, the ONLY way to really make it work is to refer fonts with a
full path, like:

fontset '/home/mapserv/fonts/fonts.txt'

which would be used by mapserver as a hint to build full font name paths,
like

/home/mapserv/fonts/fonts/myfont.ttf

where myfont.ttf is some font registered in fonts.txt. Because I was using
simply fonts/fonts.txt (a relative path), GD couldn't read fonts/myfont.txt
and then I got the error "TrueType Font error. Could not find/open font".
Finally, to end this looong e-mail, here is one thought: can't mapserver
automatically expand relative paths to full paths BEFORE passing them to GD?

Rod.







More information about the mapserver-users mailing list