diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-04-22 14:37:22 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-04-22 14:37:22 +0000 |
| commit | cd13c979453864482930c496f7c4c4d2da891a7a (patch) | |
| tree | ad6082ba7061fb9ab324fa7f8374fe2da4e4886c /src/libnrtype | |
| parent | ensure backwards compatibility with old hpgl exports (diff) | |
| download | inkscape-cd13c979453864482930c496f7c4c4d2da891a7a.tar.gz inkscape-cd13c979453864482930c496f7c4c4d2da891a7a.zip | |
Restore ability to insert a font-family that is not on system or a font-fallback list.
(bzr r13296)
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 * */ |
