From d10c022235418544b843a86f7fe2392c1ab0ea74 Mon Sep 17 00:00:00 2001 From: jsfer Date: Fri, 5 Nov 2021 16:14:49 -0400 Subject: [PATCH 1/3] Fix: Subsequent font changes to words in the same textbox now apply Extract clump of into a private function FontLister.font_family_row_update() Add call to FontLister.font_family_row_update() in function FontLister.selection_update() There are many issues related but here is the one I looked at: https://gitlab.com/inkscape/inkscape/issues/2056 --- src/libnrtype/font-lister.cpp | 58 +++++++++++++++++++---------------- src/libnrtype/font-lister.h | 2 ++ 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 75ff172c05..ed94b8bc07 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -367,32 +367,8 @@ void FontLister::update_font_list(SPDocument *document) } - /* Now we do a song and dance to find the correct row as the row corresponding - * to the current_family may have changed. We can't simply search for the - * family name in the list since it can occur twice, once in the document - * font family part and once in the system font family part. Above we determined - * which part it is in. - */ - if (current_family_row > -1) { - int start = 0; - if (row_is_system) - start = font_data.size(); - int length = font_list_store->children().size(); - for (int i = 0; i < length; ++i) { - int row = i + start; - if (row >= length) - row -= length; - Gtk::TreePath path; - path.push_back(row); - Gtk::TreeModel::iterator iter = font_list_store->get_iter(path); - if (iter) { - if (familyNamesAreEqual(current_family, (*iter)[FontList.family])) { - current_family_row = row; - break; - } - } - } - } + int start_row = (row_is_system) ? font_data.size() : 0; + font_family_row_update(start_row); // std::cout << " Out: row: " << current_family_row << " " << current_family << std::endl; font_list_store->thaw_notify(); @@ -526,6 +502,33 @@ std::pair FontLister::ui_from_fontspec(Glib::ustri return std::make_pair(Family, Style); } +/* Now we do a song and dance to find the correct row as the row corresponding + * to the current_family may have changed. We can't simply search for the + * family name in the list since it can occur twice, once in the document + * font family part and once in the system font family part. Above we determined + * which part it is in. + */ +void FontLister::font_family_row_update(int start) +{ + if (this->current_family_row > -1 && start > -1) { + int length = this->font_list_store->children().size(); + for (int i = 0; i < length; ++i) { + int row = i + start; + if (row >= length) + row -= length; + Gtk::TreePath path; + path.push_back(row); + Gtk::TreeModel::iterator iter = this->font_list_store->get_iter(path); + if (iter) { + if (familyNamesAreEqual(this->current_family, (*iter)[FontList.family])) { + this->current_family_row = row; + break; + } + } + } + } +} + std::pair FontLister::selection_update() { #ifdef DEBUG_FONT @@ -574,6 +577,9 @@ std::pair FontLister::selection_update() //std::cout << " fontspec from thin air :" << fontspec << ":" << std::endl; } + // Need to update font family row too + font_family_row_update(0); + std::pair ui = ui_from_fontspec(fontspec); set_font_family(ui.first); set_font_style(ui.second); diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 769f021723..047734dee1 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -305,6 +305,8 @@ private: void update_font_data_recursive(SPObject& r, std::map> &font_data); + void font_family_row_update(int start); + Glib::RefPtr font_list_store; Glib::RefPtr style_list_store; -- GitLab From 93ce3a28eeaa721b470e7d0fc059f573398c03ba Mon Sep 17 00:00:00 2001 From: jsfer Date: Fri, 5 Nov 2021 16:14:49 -0400 Subject: [PATCH 2/3] Fix: Subsequent font changes to words in the same textbox now apply Extract clump of into a private function FontLister.font_family_row_update() Add call to FontLister.font_family_row_update() in function FontLister.selection_update() There are many issues related but here is the one I looked at: https://gitlab.com/inkscape/inkscape/issues/2056 --- src/libnrtype/font-lister.cpp | 58 +++++++++++++++++++---------------- src/libnrtype/font-lister.h | 2 ++ 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 75ff172c05..ed94b8bc07 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -367,32 +367,8 @@ void FontLister::update_font_list(SPDocument *document) } - /* Now we do a song and dance to find the correct row as the row corresponding - * to the current_family may have changed. We can't simply search for the - * family name in the list since it can occur twice, once in the document - * font family part and once in the system font family part. Above we determined - * which part it is in. - */ - if (current_family_row > -1) { - int start = 0; - if (row_is_system) - start = font_data.size(); - int length = font_list_store->children().size(); - for (int i = 0; i < length; ++i) { - int row = i + start; - if (row >= length) - row -= length; - Gtk::TreePath path; - path.push_back(row); - Gtk::TreeModel::iterator iter = font_list_store->get_iter(path); - if (iter) { - if (familyNamesAreEqual(current_family, (*iter)[FontList.family])) { - current_family_row = row; - break; - } - } - } - } + int start_row = (row_is_system) ? font_data.size() : 0; + font_family_row_update(start_row); // std::cout << " Out: row: " << current_family_row << " " << current_family << std::endl; font_list_store->thaw_notify(); @@ -526,6 +502,33 @@ std::pair FontLister::ui_from_fontspec(Glib::ustri return std::make_pair(Family, Style); } +/* Now we do a song and dance to find the correct row as the row corresponding + * to the current_family may have changed. We can't simply search for the + * family name in the list since it can occur twice, once in the document + * font family part and once in the system font family part. Above we determined + * which part it is in. + */ +void FontLister::font_family_row_update(int start) +{ + if (this->current_family_row > -1 && start > -1) { + int length = this->font_list_store->children().size(); + for (int i = 0; i < length; ++i) { + int row = i + start; + if (row >= length) + row -= length; + Gtk::TreePath path; + path.push_back(row); + Gtk::TreeModel::iterator iter = this->font_list_store->get_iter(path); + if (iter) { + if (familyNamesAreEqual(this->current_family, (*iter)[FontList.family])) { + this->current_family_row = row; + break; + } + } + } + } +} + std::pair FontLister::selection_update() { #ifdef DEBUG_FONT @@ -574,6 +577,9 @@ std::pair FontLister::selection_update() //std::cout << " fontspec from thin air :" << fontspec << ":" << std::endl; } + // Need to update font family row too + font_family_row_update(0); + std::pair ui = ui_from_fontspec(fontspec); set_font_family(ui.first); set_font_style(ui.second); diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 769f021723..047734dee1 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -305,6 +305,8 @@ private: void update_font_data_recursive(SPObject& r, std::map> &font_data); + void font_family_row_update(int start); + Glib::RefPtr font_list_store; Glib::RefPtr style_list_store; -- GitLab From ef4a710c8dbadb5da7b0188a1498f83bc8aa2ee2 Mon Sep 17 00:00:00 2001 From: jsfer Date: Wed, 24 Nov 2021 14:56:04 -0500 Subject: [PATCH 3/3] Fix: Position of flowed text no longer applies extra transforms on text Add function to check if an objectset is present in set When objects found, inside ObjectSet.applyAffine, call SPItem.readAttr() Issue https://gitlab.com/inkscape/inkscape/-/issues/1029 --- src/selection-chemistry.cpp | 4 ++++ src/style-internal.cpp | 13 +++++++++---- src/style-internal.h | 4 ++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ed2947f48e..6764c51675 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1691,6 +1691,8 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe auto offset = dynamic_cast(item); bool transform_offset_with_source = offset && offset->sourceHref && includes(sp_offset_get_source(offset)); + bool has_multiple_shapes = item->style->shape_inside.doesContain(this); + // If we're moving a connector, we want to detach it // from shapes that aren't part of the selection, but // leave it attached if they are @@ -1803,6 +1805,8 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe // just apply the result item->doWriteTransform(result, &t, compensate); } + } else if (has_multiple_shapes) { + item->readAttr(SPAttr::TRANSFORM); } else { if (set_i2d) { diff --git a/src/style-internal.cpp b/src/style-internal.cpp index f50046d6c1..b1e66b61a5 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -36,6 +36,7 @@ #include "strneq.h" #include "object/sp-text.h" +#include "object/object-set.h" #include "svg/svg.h" #include "svg/svg-color.h" @@ -1302,11 +1303,15 @@ SPIShapes::SPIShapes() { } +bool SPIShapes::doesContain(Inkscape::ObjectSet *set) { + for (auto ref : hrefs) { + if (set->includes(ref->getObject())) { + return true; + } + } -//SPIShapes::~SPIShapes() { -// clear(); // Will segfault if called here. Seems to be already cleared. -//} - + return false; +} // Used to add/remove listeners for text wrapped in shapes. // Note: this is done differently than for patterns, etc. where presentation attributes can be used. diff --git a/src/style-internal.h b/src/style-internal.h index 3bece16714..ded725fbc5 100644 --- a/src/style-internal.h +++ b/src/style-internal.h @@ -39,6 +39,9 @@ #include "xml/repr.h" +namespace Inkscape { +class ObjectSet; +}; static const unsigned SP_STYLE_FLAG_ALWAYS (1 << 2); static const unsigned SP_STYLE_FLAG_IFSET (1 << 0); @@ -653,6 +656,7 @@ public: public: std::vector hrefs; + bool doesContain(Inkscape::ObjectSet *set); }; /// Color type internal to SPStyle, FIXME Add string value to store SVG named color. -- GitLab