2

generate_tiles.py has worked fine throughout the transition from mapnik 0.7 to mapnik 2.x in gentoo linux. Now I have switched to debian (wheezy) and I am getting the following error when I run generate_tiles.py:

RuntimeError: Failed to find font face 'unifont Medium' in FontSet 'book-fonts' in map '.../osm.xml'

If I comment out the book-fonts section in fontset-settings.xml.inc, I get:

RuntimeError: Failed to find font face 'unifont Medium' in FontSet 'bold-fonts' in map '.../osm.xml'

However, using tilelite creates the tiles just fine.

$ ls `python -c "import mapnik2;print mapnik2.fontscollectionpath"`
total 9048
drwxr-xr-x  2 root root   4096 2014-10-11 09:10 .
drwxr-xr-x 13 root root   4096 2014-10-11 20:48 ..
-rw-r--r--  1 root root 611212 2011-02-27 07:37 DejaVuSans-BoldOblique.ttf
-rw-r--r--  1 root root 672300 2011-02-27 07:37 DejaVuSans-Bold.ttf
-rw-r--r--  1 root root 580168 2011-02-27 07:37 DejaVuSansCondensed-BoldOblique.ttf
-rw-r--r--  1 root root 631992 2011-02-27 07:37 DejaVuSansCondensed-Bold.ttf
-rw-r--r--  1 root root 576004 2011-02-27 07:37 DejaVuSansCondensed-Oblique.ttf
-rw-r--r--  1 root root 643852 2011-02-27 07:37 DejaVuSansCondensed.ttf
-rw-r--r--  1 root root 345204 2011-02-27 07:37 DejaVuSans-ExtraLight.ttf
-rw-r--r--  1 root root 235848 2011-02-27 07:37 DejaVuSansMono-BoldOblique.ttf
-rw-r--r--  1 root root 313856 2011-02-27 07:37 DejaVuSansMono-Bold.ttf
-rw-r--r--  1 root root 241972 2011-02-27 07:37 DejaVuSansMono-Oblique.ttf
-rw-r--r--  1 root root 333636 2011-02-27 07:37 DejaVuSansMono.ttf
-rw-r--r--  1 root root 611556 2011-02-27 07:37 DejaVuSans-Oblique.ttf
-rw-r--r--  1 root root 720012 2011-02-27 07:37 DejaVuSans.ttf
-rw-r--r--  1 root root 332036 2011-02-27 07:37 DejaVuSerif-BoldItalic.ttf
-rw-r--r--  1 root root 341072 2011-02-27 07:37 DejaVuSerif-Bold.ttf
-rw-r--r--  1 root root 331128 2011-02-27 07:37 DejaVuSerifCondensed-BoldItalic.ttf
-rw-r--r--  1 root root 316440 2011-02-27 07:37 DejaVuSerifCondensed-Bold.ttf
-rw-r--r--  1 root root 338140 2011-02-27 07:37 DejaVuSerifCondensed-Italic.ttf
-rw-r--r--  1 root root 330012 2011-02-27 07:37 DejaVuSerifCondensed.ttf
-rw-r--r--  1 root root 338776 2011-02-27 07:37 DejaVuSerif-Italic.ttf
-rw-r--r--  1 root root 363200 2011-02-27 07:37 DejaVuSerif.ttf

No book font, but there are bold fonts.

These are all the dejavu fonts installed (with their version numbers):

ttf-dejavu                                          2.33-3   
ttf-dejavu-core                                     2.33-3    
ttf-dejavu-extra                                    2.33-3

I've seen a few people having this problem around the web, but no solutions offered.

1
  • apt-get install unifont Just worked for me
    – someone
    Commented Mar 27, 2015 at 18:11

3 Answers 3

0

You can edit the font name from unifont Medium to Unifont Medium in inc/fontset-settings.xml.inc file.

0

unifont Medium (lowercase) is replaced by Unifont Medium (uppercase) with recent Ubuntu or Debian versions.

One solution is to remove/change the unifont Medium reference (lowercase) in the Mapnik style XML file (e.g., renaming from unifont Medium to Unifont Medium).

Alternatively, the error might be related to the severity argument True currently hard-coded inside some (old) versions of generate_tiles.py for mapnik.load_map:

mapnik.load_map(self.m, mapfile, True)

Depending on how the style is written, it might be needed to edit generate_tiles.py and change mapnik.load_map(self.m, mapfile, True) to mapnik.load_map(self.m, mapfile, False):

mapnik.load_map(self.m, mapfile, False)

This way, fonts with alternative names will generate warnings, not errors; it is appropriate when the style declares fonts with alternative names and expressly needs such Mapnik option, like OpenStreetMap Carto; also OSMF Servers are configured to set it.

Another way to fix the issue is installing the old unifont Medium font, like with this example:

mkdir -p ~/src ; cd ~/src
mkdir OldUnifont
cd OldUnifont
wget http://http.debian.net/debian/pool/main/u/unifont/unifont_5.1.20080914.orig.tar.gz
tar xvfz unifont_5.1.20080914.orig.tar.gz unifont-5.1.20080914/font/precompiled/unifont.ttf
sudo cp unifont-5.1.20080914/font/precompiled/unifont.ttf /usr/share/fonts/truetype/unifont/OldUnifont.ttf
sudo fc-cache -fv
fc-list | grep -i unifont # both uppercase and lowercase fonts will be listed
2
  • This is not a solution for the problem. It just doesn't terminate XMl creation process, eventually generated XML is useless.
    – Capan
    Commented Mar 6, 2020 at 9:36
  • It might be a solution in certain cases. I updated the answer with additional clarifications.
    – ircama
    Commented Oct 31, 2020 at 9:59
-1

apt-get install unifont and in inc/fontset-settings.xml.inc.template replace "unifont Medium" with "Unifont Medium".

1
  • 2
    Could you first describe, what your changes should do, and secondly tell us, why you think this is a necessary addition to a 5 years old question?
    – Erik
    Commented Mar 24, 2020 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.