diff options
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/font-lister.cpp | 28 | ||||
| -rw-r--r-- | src/libnrtype/font-lister.h | 6 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 89d0cb037..dde0ee4a9 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -97,6 +97,34 @@ namespace Inkscape // } // font_list_store->foreach_iter( sigc::mem_fun(*this, &FontLister::print_document_font )); + + /* Used to insert a font that was not in the document and not on the system into the font list. */ + void + FontLister::insert_font_family( Glib::ustring new_family ) { + + GList *styles = default_styles; + + /* In case this is a fallback list, check if first font-family on system. */ + std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", new_family ); + if( !tokens.empty() && !tokens[0].empty() ) { + + Gtk::TreeModel::iterator iter2 = font_list_store->get_iter( "0" ); + while( iter2 != font_list_store->children().end() ) { + Gtk::TreeModel::Row row = *iter2; + if( row[FontList.onSystem] && tokens[0].compare( row[FontList.family] ) == 0 ) { + styles = row[FontList.styles]; + break; + } + ++iter2; + } + } + + Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); + (*treeModelIter)[FontList.family] = reinterpret_cast<const char*>(g_strdup(new_family.c_str())); + (*treeModelIter)[FontList.styles] = styles; + (*treeModelIter)[FontList.onSystem] = false; + } + void FontLister::update_font_list( SPDocument* document ) { diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 5a8f578d9..c42bf98fd 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -127,6 +127,12 @@ namespace Inkscape const Glib::RefPtr<Gtk::ListStore> get_style_list () const; + /** Inserts a font family or font-fallback list (for use when not + * already in document or on system). + */ + void + insert_font_family ( Glib::ustring new_family ); + /** Updates font list to include fonts in document * */ |
