[Geoserver-users] Font for GetLegendGraphic on version 1.7.x

Ron Bentley ha scritto:

We're using the GetLegendGraphic WMS request on several instances of Geoserver 1.7.6. We can't determine which font is used to render the text in the legend.

We don't need lots of control over the font, but in one particular instance an inappropriate font is being selected (no Roman characters) and we'd like to change that.

We do have several non-Roman fonts involved here, and we've had no problems selecting appropriate fonts in the SLD. It's just the font used to render the legend that is perplexing us at the moment.

Googling for "geoserver getlegendgraphics font" turns out this
page as the first result:
http://geoserver.org/display/GEOSDOC/GetLegendGraphic+Improvements

As far as I remember these improvements were actually implemented,
you can try to give them a go

Andrea,

Thank you. I certainly did go down that road.

Best I can tell, version 1.7.6 ignores LEGEND_OPTIONS in
GetLegendGraphic requests. (I tried it.) The option is documented in
the 2.0 manual, but it's not clear even there whether fontName was ever
implemented.

In any case, I don't have immediate control over the version running. I
was hoping someone might have an idea how to control the legend font in
1.7.x.

Ron Bentley

Ron Bentley ha scritto:

Ron Bentley ha scritto:

We're using the GetLegendGraphic WMS request on several instances of Geoserver 1.7.6. We can't determine which font is used to render the text in the legend.

We don't need lots of control over the font, but in one particular instance an inappropriate font is being selected (no Roman characters) and we'd like to change that.

We do have several non-Roman fonts involved here, and we've had no problems selecting appropriate fonts in the SLD. It's just the font used to render the legend that is perplexing us at the moment.

Googling for "geoserver getlegendgraphics font" turns out this
page as the first result:
http://geoserver.org/display/GEOSDOC/GetLegendGraphic+Improvements

As far as I remember these improvements were actually implemented,
you can try to give them a go

Andrea,

Thank you. I certainly did go down that road.

Best I can tell, version 1.7.6 ignores LEGEND_OPTIONS in
GetLegendGraphic requests. (I tried it.) The option is documented in
the 2.0 manual, but it's not clear even there whether fontName was ever
implemented.

In any case, I don't have immediate control over the version running. I
was hoping someone might have an idea how to control the legend font in
1.7.x.

sigma.opengeo.org:8080/geoserver is a 1.7.6 instance.

The default output there is sans serif:
http://sigma.openplans.org:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states

If I change that to "Serif":
http://sigma.openplans.org:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states&legend_options=fontName:Serif

the font actually changes. It may be you're trying with a font name that
is not available to your runtime or that you're using the wrong case.
For example, "arial" won't work on Sigma since that is a unix machine
without the Microsoft web fonts installed, and it won't work on a
Windows machine either since the font name has case issues, but if you
use "Arial" is should work.

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Dear Ron,
a question, are you trying to use this option for raster data or for
vector data, or both?
Simone.
-------------------------------------------------------
Ing. Simone Giannecchini
GeoSolutions S.A.S.
Founder - Software Engineer
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/simonegiannecchini
http://twitter.com/simogeo

-------------------------------------------------------

On Tue, Feb 2, 2010 at 2:25 PM, Ron Bentley <rtbentley@anonymised.com> wrote:

Ron Bentley ha scritto:

We're using the GetLegendGraphic WMS request on several instances of
Geoserver 1.7.6. We can't determine which font is used to render the
text in the legend.

We don't need lots of control over the font, but in one particular
instance an inappropriate font is being selected (no Roman characters)
and we'd like to change that.

We do have several non-Roman fonts involved here, and we've had no
problems selecting appropriate fonts in the SLD. It's just the font
used to render the legend that is perplexing us at the moment.

Googling for "geoserver getlegendgraphics font" turns out this
page as the first result:
http://geoserver.org/display/GEOSDOC/GetLegendGraphic+Improvements

As far as I remember these improvements were actually implemented,
you can try to give them a go

Andrea,

Thank you. I certainly did go down that road.

Best I can tell, version 1.7.6 ignores LEGEND_OPTIONS in
GetLegendGraphic requests. (I tried it.) The option is documented in
the 2.0 manual, but it's not clear even there whether fontName was ever
implemented.

In any case, I don't have immediate control over the version running. I
was hoping someone might have an idea how to control the legend font in
1.7.x.

Ron Bentley

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

If I change that to "Serif":
http://sigma.openplans.org:8080/geoserver/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=topp:states&legend_options=fontName:Serif

the font actually changes. It may be you're trying with a font name that
is not available to your runtime or that you're using the wrong case.

Andrea, thank you for the example. That solved it. I forced a rational font and it works.

On one server I'm working with, the default Java font has only one face. It was unresponsive to things like LEGEND_OPTIONS=fontStyle:bold, and it gave the impression it was ignoring that extension.

On another, SansSerif defaults to a font without a Roman character set. Those are both JVM problems I'll deal with separately.

Simone, this was for vector layers.

For what it's worth, then, I can take fontName to be included with all the other options at the bottom of this page:

http://docs.geoserver.org/2.0.x/en/user/services/wms/get_legend_graphic/legendgraphic.html

Once again, thank you very much for the help.

Ron Bentley