Mapnik is the default renderer on the OpenStreetMap main site. We can setup our own OpenStreetMap server for rendering the tiles either online or offline. This note would help you to setup an offline one (online if you do on your server) with special eye on font setup for localized tiles.
To render the tiles using Mapnik, you need to create a PostgreSQL database out of the OSM data. Then install Mapnik depending on the Operating System you run. These primary steps are very well covered in the following pointers.
- Setting up PostgreSQL database out of the OSM data. Read more.
- Build your own OpenStreetMap server – Richard Weait. Read more.
- For Ubuntu Lucid Lynx read here.
- Using Mapnik for rendering the tiles – Richard Weait. Read more.
Once you are done with the above steps, we might think of tweaking the Mapnik rules to render the tiles in a local language. For this all we need to do is point Mapnik to the right font. You can quickly follow the steps briefed by Richard, here.
You can run
python
>>> from mapnik import *
>>> for face in FontEngine.face_names(): print face
… [Enter]DejaVu Sans Bold
DejaVu Sans Bold Oblique
DejaVu Sans Book
DejaVu Sans Condensed
DejaVu Sans Condensed Bold
DejaVu Sans Condensed Bold Oblique
DejaVu Sans Condensed Oblique
DejaVu Sans ExtraLight
DejaVu Sans Mono Bold
DejaVu Sans Mono Oblique……………………………………..
>>> Ctrl-d
to see what fonts are currently being recognized by Mapnik. The second task is to install the local language unicode font to Mapnik’s default font directory. If you have already installed Mapnik, you can run strace -ff, and search for font to see which directory is used by Mapnik. In my case it was the default directory at /usr/share/fonts/
Next, you need to copy the required fonts to the above directory. You might run the python code snippet again to see whether Mapnik recognizes the fonts. For example, in my case, it looks like this.
DejaVu Sans Bold
DejaVu Sans Bold Oblique
DejaVu Sans Book
DejaVu Sans Condensed
DejaVu Sans Condensed Bold
DejaVu Sans Condensed Bold Oblique
DejaVu Sans Condensed Oblique
DejaVu Sans ExtraLight
Rachana Regular —> new one
<FontSet name=”bold-fonts”><Font face_name=”DejaVu Sans Bold”></Font></FontSet><FontSet name=”book-fonts”><Font face_name=”DejaVu Sans Book”></Font></FontSet><FontSet name=”oblique-fonts”><Font face_name=”DejaVu Sans Oblique”></Font></FontSet>
<FontSet name=”bold-fonts”><Font face_name=”Rachana Regular”></Font></FontSet><FontSet name=”book-fonts”><Font face_name=”Rachana Regular”></Font></FontSet><FontSet name=”oblique-fonts”><Font face_name=”Rachana Regular”></Font></FontSet>
<TextSymbolizer name=”name” fontset_name=”book-fonts” size=”11″ fill=”rgb(0,0,0)” halo_radius=”1″></TextSymbolizer>


DejaVu Sans BoldDejaVu Sans Bold ObliqueDejaVu Sans BookDejaVu Sans CondensedDejaVu Sans Condensed BoldDejaVu Sans Condensed Bold ObliqueDejaVu Sans Condensed ObliqueDejaVu Sans ExtraLigh
Thanks to the #osm channel irc.oftc.net and Richard Weait for helping out to figure the changes.
Thanks a lot.
Saved a lot of time of mine.
i want to change the language on the map. Please guide what to do….