summaryrefslogtreecommitdiffstats
path: root/src/object/sp-tspan.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-06-20 13:15:10 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-06-20 13:15:10 +0000
commitc17c95092c6522ef1797000d357500d52ad49faf (patch)
treec8787605dcc274a9a8287755d7962ee4dd55472d /src/object/sp-tspan.cpp
parentMerge branch 'hope' of gitlab.com:nathanal/inkscape (diff)
parentChange TextPath to Text positioning (diff)
downloadinkscape-c17c95092c6522ef1797000d357500d52ad49faf.tar.gz
inkscape-c17c95092c6522ef1797000d357500d52ad49faf.zip
Merge branch 'copypasta' of gitlab.com:nathanal/inkscape
Diffstat (limited to 'src/object/sp-tspan.cpp')
-rw-r--r--src/object/sp-tspan.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/object/sp-tspan.cpp b/src/object/sp-tspan.cpp
index 30abb9bb4..5ae889b9d 100644
--- a/src/object/sp-tspan.cpp
+++ b/src/object/sp-tspan.cpp
@@ -480,15 +480,6 @@ SPItem *sp_textpath_get_path_item(SPTextPath *tp)
void sp_textpath_to_text(SPObject *tp)
{
SPObject *text = tp->parent;
-
- Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine());
-
- if (!bbox) {
- return;
- }
-
- Geom::Point xy = bbox->min();
- xy *= tp->document->getDocumentScale().inverse(); // Convert to user-units.
// make a list of textpath children
std::vector<Inkscape::XML::Node *> tp_reprs;
@@ -506,15 +497,27 @@ void sp_textpath_to_text(SPObject *tp)
text->getRepr()->addChild(copy, nullptr); // fixme: copy id
}
+ // set x/y on text (to be near where it was when on path)
+ // Copied from Layout::fitToPathAlign
+ Path *path = dynamic_cast<SPTextPath*>(tp)->originalPath;
+ SVGLength const startOffset = dynamic_cast<SPTextPath*>(tp)->startOffset;
+ double offset = 0.0;
+ if (startOffset._set) {
+ if (startOffset.unit == SVGLength::PERCENT)
+ offset = startOffset.computed * path->Length();
+ else
+ offset = startOffset.computed;
+ }
+ int unused = 0;
+ Path::cut_position *cut_pos = path->CurvilignToPosition(1, &offset, unused);
+ Geom::Point midpoint;
+ Geom::Point tangent;
+ path->PointAndTangentAt(cut_pos[0].piece, cut_pos[0].t, midpoint, tangent);
+ sp_repr_set_svg_double(text->getRepr(), "x", midpoint[Geom::X]);
+ sp_repr_set_svg_double(text->getRepr(), "y", midpoint[Geom::Y]);
+
//remove textpath
tp->deleteObject();
-
- // set x/y on text (to be near where it was when on path)
- /* fixme: Yuck, is this really the right test? */
- if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) {
- sp_repr_set_svg_double(text->getRepr(), "x", xy[Geom::X]);
- sp_repr_set_svg_double(text->getRepr(), "y", xy[Geom::Y]);
- }
}