summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/libcroco/cr-sel-eng.c6
-rw-r--r--src/libnrtype/font-lister.cpp28
-rw-r--r--src/libnrtype/font-lister.h6
-rw-r--r--src/widgets/text-toolbar.cpp7
4 files changed, 45 insertions, 2 deletions
diff --git a/src/libcroco/cr-sel-eng.c b/src/libcroco/cr-sel-eng.c
index 0eba2b403..4f501ee05 100644
--- a/src/libcroco/cr-sel-eng.c
+++ b/src/libcroco/cr-sel-eng.c
@@ -136,8 +136,9 @@ lang_pseudo_class_handler (CRSelEng *const a_this,
node_iface = PRIVATE(a_this)->node_iface;
- if (strqcmp (a_sel->content.pseudo->name->stryng->str,
- "lang", 4)
+ /* "xml:lang" needed for SVG */
+ if ( (strqcmp (a_sel->content.pseudo->name->stryng->str, "lang", 4 ) &&
+ (strqcmp (a_sel->content.pseudo->name->stryng->str, "xml:lang", 8 ) ) )
|| !a_sel->content.pseudo->type == FUNCTION_PSEUDO) {
cr_utils_trace_info ("This handler is for :lang only");
return FALSE;
@@ -149,6 +150,7 @@ lang_pseudo_class_handler (CRSelEng *const a_this,
return FALSE;
for (; node; node = get_next_parent_element_node (node_iface, node)) {
char *val = node_iface->getProp (node, "lang");
+ if (!val) val = node_iface->getProp (node, "xml:lang");
if (val) {
if (!strcasecmp(val, a_sel->content.pseudo->extra->stryng->str)) {
result = TRUE;
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()