From bf598cf487abcd3537d975e801bb54df157cd96c Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Sat, 17 Jan 2009 20:52:24 +0000 Subject: [PATCH] + mapnik-check-fonts-during-load-map.patch from jonb This patch adds some extra exceptions for missing fontsets. Without this checking, you only notice the error at rendering time when it first needs to render a missing font. It also cleans up the font exception messages which were displaying the font name twice. Some minor questions: * Should I wrap the fontset exceptions with if(strict_)? * Should strict default to true? --- src/load_map.cpp | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/load_map.cpp b/src/load_map.cpp index 08af60d52..5790dcf09 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -295,24 +295,11 @@ namespace mapnik void map_parser::parse_font(FontSet & fset, ptree const & f) { - std::string face_name; + std::string face_name = get_attr(f, "face_name", string()); - try + if ( strict_ ) { - face_name = get_attr(f, "face_name", string()); - - if ( strict_ ) - { - ensure_font_face( face_name ); - } - } - catch (const config_error & ex) - { - if (!face_name.empty()) - { - ex.append_context(string("in Font '") + face_name + "'"); - } - throw; + ensure_font_face( face_name ); } fset.add_face_name(face_name); @@ -755,10 +742,18 @@ namespace mapnik { text_symbol.set_fontset(itr->second); } + else + { + throw config_error("Unable to find any fontset named '" + *fontset_name + "'"); + } } else if (face_name) { - text_symbol.set_face_name(*face_name); + if ( strict_ ) + { + ensure_font_face(*face_name); + } + text_symbol.set_face_name(*face_name); } else { @@ -836,11 +831,6 @@ namespace mapnik text_symbol.set_max_char_angle_delta( * max_char_angle_delta); } - if ( strict_ ) - { - ensure_font_face( text_symbol.get_face_name() ); - } - rule.append(text_symbol); } catch (const config_error & ex) @@ -895,10 +885,18 @@ namespace mapnik { shield_symbol.set_fontset(itr->second); } + else + { + throw config_error("Unable to find any fontset named '" + *fontset_name + "'"); + } } else if (face_name) { - shield_symbol.set_face_name(*face_name); + if ( strict_ ) + { + ensure_font_face(*face_name); + } + shield_symbol.set_face_name(*face_name); } else {