Status
ordering "chilled monkey brain" is harder to do than movies would have you believe
Location
Madhya Pradesh, India
Subscribe to GeoRSS Subscribe to KML


CJK Fonts in OpenStreetMap tiles

Published in OpenStreetMap  |  4 Comments


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 <Map/> declaration, add the font set styling for fallback:
    <FontSet name="DejaVu Sans Book">
    <Font face_name="DejaVu Sans Book" />
    <Font face_name="unifont Medium" />
    </FontSet>
    
    
  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.

Similar Posts


Responses

  1. Schuyler Erle says:

    April 3rd, 2009 at 1:53 pm (#)

    That’s “Tel Aviv-Yafo” to you, buddy! ;)

  2. Edgemaster says:

    April 3rd, 2009 at 3:34 pm (#)

    How about this file? http://svn.openstreetmap.org/applications/rendering/mapnik/osm-template-fontset.xml

  3. Andrew Turner says:

    April 8th, 2009 at 7:58 am (#)

    Thanks @Edgemaster – I didn’t see that stylesheet.

    However, like most bugs/issues are – it was a great learning experience in how OSM styling works with fonts.

  4. Himanshu says:

    March 5th, 2010 at 8:32 am (#)

    Dear Sir,
    My system is not able to decode the hindi font of India and it is showing different symbols in place of names of cities
    How to do that.

    Step 4 is not very clear to me that where I need to add these fonts tag so please let me know the procedure in detail.

    Can it also needed to register unicode fonts in the mapnik?
    If yes so how to do this.

    Please help me.

Leave a Response