summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-04-22 14:37:22 +0000
committertavmjong-free <tavmjong@free.fr>2014-04-22 14:37:22 +0000
commitcd13c979453864482930c496f7c4c4d2da891a7a (patch)
treead6082ba7061fb9ab324fa7f8374fe2da4e4886c /src
parentensure backwards compatibility with old hpgl exports (diff)
downloadinkscape-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')
-rw-r--r--src/libnrtype/font-lister.cpp28
-rw-r--r--src/libnrtype/font-lister.h6
-rw-r--r--src/widgets/text-toolbar.cpp7
3 files changed, 41 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
*
*/
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 349fefa12..7b59fa633 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -146,6 +146,13 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb
std::cout << " New active: " << act->active << std::endl;
#endif
if( new_family.compare( fontlister->get_font_family() ) != 0 ) {
+ // Changed font-family
+
+ if( act->active == -1 ) {
+ // New font-family, not in document, not on system (could be fallback list)
+ fontlister->insert_font_family( new_family );
+ act->active = 0; // New family is always at top of list.
+ }
std::pair<Glib::ustring,Glib::ustring> ui = fontlister->set_font_family( act->active );
// active text set in sp_text_toolbox_selection_changed()