summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp7
-rw-r--r--src/libnrtype/FontFactory.cpp37
-rw-r--r--src/libnrtype/FontFactory.h3
-rw-r--r--src/preferences.cpp6
-rw-r--r--src/sp-root.cpp8
-rw-r--r--src/sp-style-elem.cpp119
-rw-r--r--src/ui/control-manager.cpp4
-rw-r--r--src/ui/dialog/prototype.cpp2
-rw-r--r--src/widgets/spw-utilities.cpp113
-rw-r--r--src/widgets/spw-utilities.h16
-rw-r--r--src/xml/repr-io.cpp5
11 files changed, 165 insertions, 155 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index c56c42267..2d1aa8829 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -1935,11 +1935,18 @@ SPDesktop::show_dialogs()
mapVerbPreference.insert(std::make_pair ("Symbols", "/dialogs/symbols") );
mapVerbPreference.insert(std::make_pair ("ObjectsPanel", "/dialogs/objects") );
mapVerbPreference.insert(std::make_pair ("TagsPanel", "/dialogs/tags") );
+ mapVerbPreference.insert(std::make_pair ("Prototype", "/dialogs/prototype") );
+
for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); ++iter) {
Glib::ustring pref = iter->second;
int visible = prefs->getInt(pref + "/visible", 0);
if (visible) {
+
+ // Try to ensure that the panel is created attached to the correct desktop (bug 1720096).
+ // There must be a better way of handling this problem!
+ INKSCAPE.activate_desktop(this);
+
_dlg_mgr->showDialog(iter->first.c_str(), false); // without grabbing focus, we need focus to remain on the canvas
}
}
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp
index 677b8abe7..9c62e5483 100644
--- a/src/libnrtype/FontFactory.cpp
+++ b/src/libnrtype/FontFactory.cpp
@@ -934,7 +934,10 @@ void font_factory::AddFontsDir(char const *utf8dir)
dir = g_filename_from_utf8(utf8dir, -1, NULL, NULL, NULL);
# endif
- FcConfig *conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
+ FcConfig *conf = NULL;
+# if PANGO_VERSION_CHECK(1,38,0)
+ conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
+# endif
FcBool res = FcConfigAppFontAddDir(conf, (FcChar8 const *)dir);
if (res = FcTrue) {
g_info("Fonts dir '%s' added successfully.", utf8dir);
@@ -946,6 +949,38 @@ void font_factory::AddFontsDir(char const *utf8dir)
#endif
}
+void font_factory::AddFontFile(char const *utf8file)
+{
+#ifdef USE_PANGO_WIN32
+ g_info("Adding additional font only supported for fontconfig backend.");
+#else
+ if (!Inkscape::IO::file_test(utf8file, G_FILE_TEST_IS_REGULAR)) {
+ g_warning("Font file '%s' does not exist and will be ignored.", utf8file);
+ return;
+ }
+
+ gchar *file;
+# ifdef WIN32
+ file = g_win32_locale_filename_from_utf8(utf8file);
+# else
+ file = g_filename_from_utf8(utf8file, -1, NULL, NULL, NULL);
+# endif
+
+ FcConfig *conf = NULL;
+# if PANGO_VERSION_CHECK(1,38,0)
+ conf = pango_fc_font_map_get_config(PANGO_FC_FONT_MAP(fontServer));
+# endif
+ FcBool res = FcConfigAppFontAddFile(conf, (FcChar8 const *)file);
+ if (res = FcTrue) {
+ g_info("Font file '%s' added successfully.", utf8file);
+ } else {
+ g_warning("Could not add font file '%s'.", utf8file);
+ }
+
+ g_free(file);
+#endif
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h
index c273be2f4..12260f99a 100644
--- a/src/libnrtype/FontFactory.h
+++ b/src/libnrtype/FontFactory.h
@@ -139,6 +139,9 @@ public:
/// Add a directory from which to include additional fonts
void AddFontsDir(char const *utf8dir);
+ /// Add a an additional font.
+ void AddFontFile(char const *utf8file);
+
private:
void* loadedPtr;
diff --git a/src/preferences.cpp b/src/preferences.cpp
index 7ebf55a79..b02e71e46 100644
--- a/src/preferences.cpp
+++ b/src/preferences.cpp
@@ -393,6 +393,9 @@ std::vector<Glib::ustring> Preferences::getAllDirs(Glib::ustring const &path)
Inkscape::XML::Node *node = _getNode(path, false);
if (node) {
for (Inkscape::XML::NodeSiblingIterator i = node->firstChild(); i; ++i) {
+ if (i->attribute("id") == NULL) {
+ continue;
+ }
temp.push_back(path + '/' + i->attribute("id"));
}
}
@@ -702,6 +705,9 @@ Inkscape::XML::Node *Preferences::_getNode(Glib::ustring const &pref_key, bool c
}
for (child = node->firstChild(); child; child = child->next()) {
+ if (child->attribute("id") == NULL) {
+ continue;
+ }
if (!strcmp(splits[part_i], child->attribute("id"))) {
break;
}
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 9ea1aa976..3f31588cc 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -245,12 +245,12 @@ void SPRoot::setRootDimensions()
} else {
- if( !this->width._set ) {
- this->width.set( SVGLength::PX, 100, 100 ); // Random default
+ if( !this->width._set || this->width.unit == SVGLength::PERCENT) {
+ this->width.set( SVGLength::PX, 300, 300 ); // CSS/SVG default
}
- if( !this->height._set ) {
- this->height.set( SVGLength::PX, 100, 100 ); // Random default
+ if( !this->height._set || this->height.unit == SVGLength::PERCENT) {
+ this->height.set( SVGLength::PX, 150, 150 ); // CSS/SVG default
}
}
diff --git a/src/sp-style-elem.cpp b/src/sp-style-elem.cpp
index 1a3c194b9..da02d4ef1 100644
--- a/src/sp-style-elem.cpp
+++ b/src/sp-style-elem.cpp
@@ -12,6 +12,9 @@
#include <iostream>
#include <fstream>
+// For font-rule
+#include "libnrtype/FontFactory.h"
+
using Inkscape::XML::TEXT_NODE;
SPStyleElem::SPStyleElem() : SPObject() {
@@ -281,8 +284,10 @@ start_font_face_cb(CRDocHandler *a_handler,
static_cast<void *>(parse_tmp.currStmt), unsigned(parse_tmp.stmtType));
// fixme: Check whether we need to unref currStmt if non-NULL.
}
+ CRStatement *font_face_rule = cr_statement_new_at_font_face_rule (parse_tmp.stylesheet, NULL);
+ g_return_if_fail(font_face_rule && font_face_rule->type == AT_FONT_FACE_RULE_STMT);
parse_tmp.stmtType = FONT_FACE_STMT;
- parse_tmp.currStmt = NULL;
+ parse_tmp.currStmt = font_face_rule;
}
static void
@@ -291,13 +296,76 @@ end_font_face_cb(CRDocHandler *a_handler)
g_return_if_fail(a_handler->app_data != NULL);
ParseTmp &parse_tmp = *static_cast<ParseTmp *>(a_handler->app_data);
g_return_if_fail(parse_tmp.hasMagic());
- if (parse_tmp.stmtType != FONT_FACE_STMT || parse_tmp.currStmt != NULL) {
- g_warning("Expecting currStmt==NULL and stmtType==1 (FONT_FACE_STMT) at end of @font-face, but found currStmt=%p, stmtType=%u",
- static_cast<void *>(parse_tmp.currStmt), unsigned(parse_tmp.stmtType));
- // fixme: Check whether we need to unref currStmt if non-NULL.
- parse_tmp.currStmt = NULL;
+
+ CRStatement *const font_face_rule = parse_tmp.currStmt;
+ if (parse_tmp.stmtType == FONT_FACE_STMT
+ && font_face_rule
+ && font_face_rule->type == AT_FONT_FACE_RULE_STMT)
+ {
+ parse_tmp.stylesheet->statements = cr_statement_append(parse_tmp.stylesheet->statements,
+ font_face_rule);
+ } else {
+ g_warning("Found stmtType=%u, stmt=%p, stmt.type=%u.",
+ unsigned(parse_tmp.stmtType),
+ font_face_rule,
+ unsigned(font_face_rule->type));
+ }
+
+ std::cout << "end_font_face_cb: font face rule limited support." << std::endl;
+ cr_declaration_dump (font_face_rule->kind.font_face_rule->decl_list, stdout, 2, TRUE);
+ printf ("\n");
+
+ // Get document
+ SPDocument* document = parse_tmp.document;
+ if (!document) {
+ std::cerr << "end_font_face_cb: No document!" << std::endl;
+ return;
+ }
+ if (!document->getURI()) {
+ std::cerr << "end_font_face_cb: Document URI is NULL" << std::endl;
+ return;
}
+
+ // Add ttf or otf fonts.
+ CRDeclaration const *cur = NULL;
+ for (cur = font_face_rule->kind.font_face_rule->decl_list; cur; cur = cur->next) {
+ if (cur->property &&
+ cur->property->stryng &&
+ cur->property->stryng->str &&
+ strcmp(cur->property->stryng->str, "src") == 0 ) {
+
+ if (cur->value &&
+ cur->value->content.str &&
+ cur->value->content.str->stryng &&
+ cur->value->content.str->stryng->str) {
+
+ Glib::ustring value = cur->value->content.str->stryng->str;
+ std::size_t found = value.find_last_of("ttf");
+
+ if (value.rfind("ttf") == (value.length() - 3) ||
+ value.rfind("otf") == (value.length() - 3)) {
+
+ // Get file
+ Glib::ustring ttf_file =
+ Inkscape::IO::Resource::get_filename (document->getURI(), value);
+
+ if (!ttf_file.empty()) {
+ font_factory *factory = font_factory::Default();
+ factory->AddFontFile( ttf_file.c_str() );
+ std::cout << "end_font_face_cb: Added font: " << ttf_file << std::endl;
+
+ // FIX ME: Need to refresh font list.
+ } else {
+ std::cout << "end_font_face_cb: Failed to add: " << value << std::endl;
+ }
+ }
+ }
+ }
+ }
+
+ parse_tmp.currStmt = NULL;
parse_tmp.stmtType = NO_STMT;
+
}
static void
@@ -305,26 +373,38 @@ property_cb(CRDocHandler *const a_handler,
CRString *const a_name,
CRTerm *const a_value, gboolean const a_important)
{
+ // std::cout << "property_cb: Entrance: " << a_name->stryng->str << ": " << cr_term_to_string(a_value) << std::endl;
g_return_if_fail(a_handler && a_name);
g_return_if_fail(a_handler->app_data != NULL);
ParseTmp &parse_tmp = *static_cast<ParseTmp *>(a_handler->app_data);
g_return_if_fail(parse_tmp.hasMagic());
- if (parse_tmp.stmtType == FONT_FACE_STMT) {
- if (parse_tmp.currStmt != NULL) {
- g_warning("Found non-NULL currStmt %p though stmtType==FONT_FACE_STMT.", parse_tmp.currStmt);
- }
- /* We currently ignore @font-face descriptors. */
- return;
- }
+
CRStatement *const ruleset = parse_tmp.currStmt;
- g_return_if_fail(ruleset
- && ruleset->type == RULESET_STMT
- && parse_tmp.stmtType == NORMAL_RULESET_STMT);
- CRDeclaration *const decl = cr_declaration_new(ruleset, cr_string_dup(a_name), a_value);
+ g_return_if_fail(ruleset);
+
+ CRDeclaration *const decl = cr_declaration_new (ruleset, cr_string_dup(a_name), a_value);
g_return_if_fail(decl);
decl->important = a_important;
- CRStatus const append_status = cr_statement_ruleset_append_decl(ruleset, decl);
- g_return_if_fail(append_status == CR_OK);
+
+ switch (parse_tmp.stmtType) {
+
+ case NORMAL_RULESET_STMT: {
+ g_return_if_fail (ruleset->type == RULESET_STMT);
+ CRStatus const append_status = cr_statement_ruleset_append_decl (ruleset, decl);
+ g_return_if_fail (append_status == CR_OK);
+ break;
+ }
+ case FONT_FACE_STMT: {
+ g_return_if_fail (ruleset->type == AT_FONT_FACE_RULE_STMT);
+ CRDeclaration *new_decls = cr_declaration_append (ruleset->kind.font_face_rule->decl_list, decl);
+ g_return_if_fail (new_decls);
+ ruleset->kind.font_face_rule->decl_list = new_decls;
+ break;
+ }
+ default:
+ g_warning ("property_cb: Unhandled stmtType: %u", parse_tmp.stmtType);
+ return;
+ }
}
CRParser*
@@ -405,6 +485,7 @@ void SPStyleElem::read_content() {
// If style sheet has changed, we need to cascade the entire object tree, top down
// Get root, read style, loop through children
update_style_recursively( (SPObject *)document->getRoot() );
+ // cr_stylesheet_dump (document->style_sheet, stdout);
}
/**
diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp
index d0285e467..d0106bfcd 100644
--- a/src/ui/control-manager.cpp
+++ b/src/ui/control-manager.cpp
@@ -330,10 +330,12 @@ void ControlManagerImpl::setSelected(SPCanvasItem *item, bool selected)
if (selected && _resizeOnSelect.count(item->ctrlType)) {
item->ctrlResize = 2;
+ } else {
+ item->ctrlResize = 0;
}
// TODO refresh colors
- double targetSize = _sizeTable[item->ctrlType][_size - 1] + _resize;
+ double targetSize = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize;
g_object_set(item, "size", targetSize, NULL);
}
}
diff --git a/src/ui/dialog/prototype.cpp b/src/ui/dialog/prototype.cpp
index b3bf60aab..b7c9f7abf 100644
--- a/src/ui/dialog/prototype.cpp
+++ b/src/ui/dialog/prototype.cpp
@@ -22,6 +22,8 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
+// Note that in order for a dialog to be restored, it must be listed in SPDesktop::show_dialogs().
+
Prototype::Prototype() :
// UI::Widget::Panel("Prototype Label", "/dialogs/prototype", SP_VERB_DIALOG_PROTOTYPE,
// "Prototype Apply Label", true),
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index 29e86b885..992f1f6b7 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -61,31 +61,6 @@ Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int r
return label_widget;
}
-GtkWidget *
-spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row)
-{
- GtkWidget *label_widget;
-
- label_widget = gtk_label_new (label_text);
- g_assert(label_widget != NULL);
- gtk_widget_set_halign(label_widget, GTK_ALIGN_END);
- gtk_widget_show (label_widget);
-
-#if GTK_CHECK_VERSION(3,12,0)
- gtk_widget_set_margin_start(label_widget, 4);
- gtk_widget_set_margin_end(label_widget, 4);
-#else
- gtk_widget_set_margin_left(label_widget, 4);
- gtk_widget_set_margin_right(label_widget, 4);
-#endif
- gtk_widget_set_hexpand(label_widget, TRUE);
- gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL);
- gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1);
-
- return label_widget;
-}
-
/**
* Creates a horizontal layout manager with 4-pixel spacing between children
* and space for 'width' columns.
@@ -104,94 +79,6 @@ Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row)
return hb;
}
-/**
- * Creates a checkbutton widget and adds it to a vbox.
- * This is a compound widget that includes a label.
- */
-GtkWidget *spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *vbox,
- const gchar *label, const gchar *tip, gchar *key, GCallback cb)
-{
- g_assert (dialog != NULL);
- g_assert (vbox != NULL);
-
- GtkWidget *b = gtk_check_button_new_with_label (label);
- gtk_widget_set_tooltip_text(b, tip);
- g_assert (b != NULL);
- gtk_widget_show (b);
- gtk_box_pack_start (GTK_BOX (vbox), b, FALSE, FALSE, 0);
- g_object_set_data (G_OBJECT (b), "key", key);
- g_object_set_data (G_OBJECT (dialog), key, b);
- g_signal_connect (G_OBJECT (b), "toggled", cb, dialog);
- return b;
-}
-
-
-/**
- * Creates a checkbutton widget and adds it to a table.
- * This is a compound widget that includes a label.
- */
-GtkWidget *
-spw_checkbutton(GtkWidget * dialog, GtkWidget * table,
- const gchar * label, gchar * key, int /*col*/, int row,
- int insensitive, GCallback cb)
-{
- GtkWidget *b;
-
- g_assert(dialog != NULL);
- g_assert(table != NULL);
-
- GtkWidget *l = gtk_label_new (label);
- gtk_widget_set_halign(l, GTK_ALIGN_END);
- gtk_widget_show (l);
-
- gtk_widget_set_halign(l, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(l, TRUE);
- gtk_widget_set_valign(l, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1);
-
- b = gtk_check_button_new ();
- gtk_widget_show (b);
-
- gtk_widget_set_halign(b, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(b, TRUE);
- gtk_widget_set_valign(b, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1);
-
- g_object_set_data (G_OBJECT (b), "key", key);
- g_object_set_data (G_OBJECT (dialog), key, b);
- g_signal_connect (G_OBJECT (b), "toggled", cb, dialog);
- if (insensitive == 1) {
- gtk_widget_set_sensitive (b, FALSE);
- }
- return b;
-}
-
-/**
- * Creates a dropdown widget. This is a compound widget that includes
- * a label as well as the dropdown.
- */
-GtkWidget *
-spw_dropdown(GtkWidget * dialog, GtkWidget * table,
- const gchar * label_text, gchar * key, int row,
- GtkWidget * selector
- )
-{
- g_assert(dialog != NULL);
- g_assert(table != NULL);
- g_assert(selector != NULL);
-
- spw_label_old(table, label_text, 0, row);
-
- gtk_widget_show (selector);
- gtk_widget_set_halign(selector, GTK_ALIGN_FILL);
- gtk_widget_set_hexpand(selector, TRUE);
- gtk_widget_set_valign(selector, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1);
-
- g_object_set_data (G_OBJECT (dialog), key, selector);
- return selector;
-}
-
static void
sp_set_font_size_recursive (GtkWidget *w, gpointer font)
{
diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h
index 71b451631..ea0d55279 100644
--- a/src/widgets/spw-utilities.h
+++ b/src/widgets/spw-utilities.h
@@ -27,22 +27,6 @@ namespace Gtk {
Gtk::Label * spw_label(Gtk::Grid *table, gchar const *label_text, int col, int row, Gtk::Widget *target);
Gtk::HBox * spw_hbox(Gtk::Grid *table, int width, int col, int row);
-GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row);
-
-GtkWidget *
-spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *table,
- const gchar *label, const gchar *tip, gchar *key, GCallback cb);
-
-GtkWidget *
-spw_checkbutton(GtkWidget *dialog, GtkWidget *table,
- gchar const *label, gchar *key, int col, int row,
- int sensitive, GCallback cb);
-
-GtkWidget *
-spw_dropdown(GtkWidget *dialog, GtkWidget *table,
- gchar const *label, gchar *key, int row,
- GtkWidget *selector
- );
void sp_set_font_size (GtkWidget *w, guint font);
void sp_set_font_size_smaller (GtkWidget *w);
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 725b313b1..2ff9d4776 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -561,7 +561,10 @@ static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gc
return NULL; // empty text node
}
- bool preserve = (xmlNodeGetSpacePreserve (node) == 1);
+ // Since libxml2 2.9.0, only element nodes are checked, thus check parent.
+ // Note: this only handles XML's rules for white space. SVG's specific rules
+ // are handled in sp-string.cpp.
+ bool preserve = (xmlNodeGetSpacePreserve (node->parent) == 1);
xmlChar *p;
for (p = node->content; *p && g_ascii_isspace (*p) && !preserve; p++)