From bb0190888e9c3ce7628e4662e963d115d7855b15 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 29 May 2014 11:52:45 +0200 Subject: Use SPStyle value for 'font-family' rather than parse 'style' ourselves. This fixes the problem of a 'font-family' declared via the 'font' shorthand being ignored when creating the document font list. (bzr r13341.1.41) --- src/libnrtype/font-lister.cpp | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 300273378..333c4ef5b 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -240,37 +240,12 @@ namespace Inkscape font_list_store->thaw_notify(); } - // FIXME: why do we parse the style attribute instead of the object's SPStyle? void FontLister::update_font_list_recursive( SPObject *r, std::list *l ) { - const gchar *style = r->getRepr()->attribute("style"); - if( style != NULL ) { - - std::vector tokens = Glib::Regex::split_simple(";", style ); - for( size_t i=0; i < tokens.size(); ++i ) { - - Glib::ustring token = tokens[i]; - size_t found = token.find("font-family:"); - - if( found != Glib::ustring::npos ) { - - // Remove "font-family:" - token.erase(found,12); - - // Remove any leading single or double quote - if( token[0] == '\'' || token[0] == '"' ) { - token.erase(0,1); - } - - // Remove any trailing single or double quote - if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) { - token.erase(token.length()-1); - } - - l->push_back( token ); - } - } + const gchar *font_family = r->style->font_family.value; + if( font_family ) { + l->push_back( Glib::ustring( font_family ) ); } for (SPObject *child = r->firstChild(); child; child = child->getNext()) { -- cgit v1.2.3