CJK Fonts in OpenStreetMap tiles

OSM Thailand.png I spent many hours on Thursday configuring and installing OpenStreetMap tile rendering, via Mapnik and mod_tile and at the very last step ran into a glaring issue: Japan, China, Korea, Thailand fonts (often referred to as CJK) were just [] symbols instead of the appropriate characters.

Out of the box, the OpenStreetMap style, osm.xml, doesn't have fallback font support. What this means is that when the default font, DejaVu Sans, is missing the specified character then Mapnik doesn't know where else to try to get the character. Mapnik has support for this, but for some reason the default OSM style or package doesn't include it.

Thanks to the late-night help of Dane Springmeyer (and looking past the very bad April Fools joke of telling me Mapnik now has Ruby bindings and KML rendering support), I managed to get it working.

Steps to Reproduce

The solution is quite straight-forward, and I have added my notes to the OSM wiki on Mapnik.

  1. Download the GNU Unifont Glyphs.
  2. Unpack and put the ttf file in your /usr/local/lib/mapnik/fonts (or appropriate path) directory with the other Mapnik fonts.
  3. Modify your osm.xml. Replace face_name="DejaVu Sans Book" with fontset_name="DejaVu Sans Book".
  4. Underneat the declaration, add the font set styling for fallback:

  5. Repeat for Bold and Oblique.
  6. Delete your tile cache and re-render.

You can view my modified osm.xml here.

It is really impressive how well Mapnik and OpenStreetMap work together, and the simplicity of styling. The next step is to figure out how to add English names to all the local language renderings, so that someone can look at תֵּל־אָבִיב-יָפוֹ and also recognize it as Tel-Aviv.

About this article

written on
posted in OpenStreetMap Back to Top