Search This Blog

Saturday, April 9, 2011

Changing the font in MapServer 5.x+


The first step to change the size and font type of labels and legends provided by MapServer is to create a fontset file in the root specified in the configuration as it is explained in http://mapserver.org/mapfile/fontset.html.

Legends:

The MapServer 5.x+ configuration required to change the font used in legends is shown below:

MAP
 ...
 FONTSET "../fonts/fonts.list"

 ...

 LEGEND
   LABEL
     FONT "arial"
     TYPE truetype
     SIZE 8
   END
   TRANSPARENT ON
 END

 LAYER
 ...
 END

 ...
END

Once this has been done, you can query the legends to MapServer using for example an OGC standard query:


https://localhost/cgi-bin/mapserv?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetLegendGraphic&FORMAT=image%2Fpng&LAYER=mylayer

Labels: 
To associate this font also to the labels included in the map images provided by MapServer you have to include the same configuration in each layer:


MAP
 ...
 FONTSET "../fonts/fonts.list"

 ...

 LAYER
   CLASS
      ...
      LABEL
          ...
          FONT "arial"
          TYPE truetype
          SIZE 8

      END                  
    END   
 ...
 END

 ...
END

No comments:

Post a Comment