summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-04-22 16:51:46 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-04-22 16:51:46 +0000
commit3ba6a439421cf71986547d9588a5c0bf5bd7a8e7 (patch)
tree6e5260ec5ab6d754d032701910918ca746d88807 /src/libnrtype
parentupdate to trunk (diff)
parentParse xml:lang, required for SVG (CSS uses lang) (diff)
downloadinkscape-3ba6a439421cf71986547d9588a5c0bf5bd7a8e7.tar.gz
inkscape-3ba6a439421cf71986547d9588a5c0bf5bd7a8e7.zip
update to trunk
(bzr r11950.1.333)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/font-lister.cpp28
-rw-r--r--src/libnrtype/font-lister.h6
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
*
*/