summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabiertxof <jabier.arraiza@marker.es>2019-09-04 19:38:00 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-09-07 21:48:33 +0000
commitb39deb401d5d34abceb5ee8caad920b70d734205 (patch)
treebd3134ff6873e1ed7e684e026d9f748ce3b23617 /src
parentAdd Text direction icons (diff)
downloadinkscape-b39deb401d5d34abceb5ee8caad920b70d734205.tar.gz
inkscape-b39deb401d5d34abceb5ee8caad920b70d734205.zip
fixx flowbox on SVG2 mode using tspans
Diffstat (limited to 'src')
-rw-r--r--src/object/sp-text.cpp12
-rw-r--r--src/text-editing.cpp2
-rw-r--r--src/ui/toolbar/text-toolbar.cpp36
3 files changed, 16 insertions, 34 deletions
diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp
index f42a694f0..7035d78b2 100644
--- a/src/object/sp-text.cpp
+++ b/src/object/sp-text.cpp
@@ -838,10 +838,13 @@ void SPText::rebuildLayout()
#endif
// set the x,y attributes on role:line spans
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ bool svg2text = prefs->getBool("/tools/text/use_svg2");
for (auto& child: children) {
if (SP_IS_TSPAN(&child)) {
SPTSpan *tspan = SP_TSPAN(&child);
- if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED)
+ if (!svg2text &&
+ (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED)
&& tspan->attributes.singleXYCoordinates() ) {
Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan);
Geom::Point anchor_point = layout.chunkAnchorPoint(iter);
@@ -1112,12 +1115,17 @@ SPItem *create_text_with_rectangle (SPDesktop *desktop, Geom::Point p0, Geom::Po
sp_repr_css_set(text_repr, css, "style");
sp_repr_css_attr_unref(css);
+ /* Create <tspan> */
+ Inkscape::XML::Node *rtspan = xml_doc->createElement("svg:tspan");
+ rtspan->setAttribute("sodipodi:role", "line"); // otherwise, why bother creating the tspan?
Inkscape::XML::Node *text_node = xml_doc->createTextNode("");
- text_repr->appendChild(text_node);
+ rtspan->appendChild(text_node);
+ text_repr->appendChild(rtspan);
SPItem *item = dynamic_cast<SPItem *>(desktop->currentLayer());
g_assert(item != nullptr);
+ Inkscape::GC::release(rtspan);
Inkscape::GC::release(text_repr);
Inkscape::GC::release(text_node);
Inkscape::GC::release(defs_repr);
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 54261c66f..db3d78ac5 100644
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
@@ -427,6 +427,8 @@ Inkscape::Text::Layout::iterator sp_te_insert_line (SPItem *item, Inkscape::Text
if (split_obj) {
Inkscape::XML::Document *xml_doc = split_obj->document->getReprDoc();
Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, split_obj->getRepr());
+ // if we finaly go to a text element without TSpan we mist set content to none
+ // new_node->setContent("");
split_obj->parent->getRepr()->addChild(new_node, split_obj->getRepr());
Inkscape::GC::release(new_node);
}
diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp
index 042b66e6c..9fc33a391 100644
--- a/src/ui/toolbar/text-toolbar.cpp
+++ b/src/ui/toolbar/text-toolbar.cpp
@@ -1299,11 +1299,7 @@ TextToolbar::lineheight_value_changed()
sp_repr_css_set_property(cssfit, "line-height", parent_lineheight.c_str());
double minheight = 0;
if (parent_style) {
- if (parent_style->line_height.normal) {
- minheight = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
- } else {
- minheight = parent_style->line_height.computed;
- }
+ minheight = parent_style->line_height.computed;
}
if (minheight) {
for (auto i : parent->childList(false)) {
@@ -1311,17 +1307,7 @@ TextToolbar::lineheight_value_changed()
if (!child) {
continue;
}
- double childheight = 0;
- if (child->style) {
- if (child->style->line_height.normal) {
- childheight = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
- } else {
- childheight = child->style->line_height.computed;
- }
- }
- if (minheight == childheight) {
- recursively_set_properties(child, cssfit);
- }
+ recursively_set_properties(child, cssfit);
}
}
sp_repr_css_set_property(cssfit, "line-height", "0");
@@ -1509,11 +1495,7 @@ TextToolbar::lineheight_unit_changed(int /* Not Used */)
sp_repr_css_set_property(cssfit, "line-height", parent_lineheight.c_str());
double minheight = 0;
if (parent_style) {
- if (parent_style->line_height.normal) {
- minheight = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
- } else {
- minheight = parent_style->line_height.computed;
- }
+ minheight = parent_style->line_height.computed;
}
if (minheight) {
for (auto i : parent->childList(false)) {
@@ -1521,17 +1503,7 @@ TextToolbar::lineheight_unit_changed(int /* Not Used */)
if (!child) {
continue;
}
- double childheight = 0;
- if (child->style) {
- if (child->style->line_height.normal) {
- childheight = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
- } else {
- childheight = child->style->line_height.computed;
- }
- }
- if (minheight == childheight) {
- recursively_set_properties(child, cssfit);
- }
+ recursively_set_properties(child, cssfit);
}
}
sp_repr_css_set_property(cssfit, "line-height", "0");