logo
Back to blog list
Blog Image

Custom fonts for labels in GeoServer

Posted on June 15, 2024

2 minutes

Geoserver has capability of loading fonts externally whenever required. It supports True Type Fonts and this blog, we'll discover how to add them.

We recently worked on the project where client had data in Hindi langauge and even though the data was visible in layer preview, it was not in style.

Download font (.TTF )

We first need to find out correct font that can load our text, you can simply Google ( or DuckDuck ) hindi ttf fonts and download the font.

Put font in data_dir

We need to put font in geoserver in order to use it. the path to follow is

{GEOSERVER_DATA_DIR}/styles

Reload geoserver

Once you put .ttf file in correct location , go to geoserver and Clear Resource cache and Reload configuration and catelog

Confirm font name

To confirm if the font is added successfully, run following Geoserver REST API.

curl --location 'http://IP:8080/geoserver/rest/fonts.json' \
--header 'Authorization: Basic YWRtaW46eW91cmdlb3NlclcnBhc3N3b3Jk'

in the response check for the font you have added

Use font in the style

You can then start using the same font name as shown by REST API in geoserver style.

<TextSymbolizer>
 <Label>
 <ogc:PropertyName>district_h</ogc:PropertyName>
 </Label>
 <Font>
 <CssParameter name="font-family">Akshar Unicode</CssParameter>
 <CssParameter name="font-style">Normal</CssParameter>
 <CssParameter name="font-weight">bold</CssParameter>
 <CssParameter name="font-size">12</CssParameter>
 </Font>
</TextSymbolizer>

˛

Image

Unlock Exclusive Content and Stay updated.

Subscribe today!

Interesting content are in store for you.

What are you interested to know more about?