diff options
| author | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-06-03 13:38:12 +0000 |
|---|---|---|
| committer | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-06-03 13:38:12 +0000 |
| commit | d26076c00288c835cd67d95723c8fed4a96a3784 (patch) | |
| tree | 965bf81cfcbf86e5a431d66a6f5a9313e98f10d5 /src/object | |
| parent | Fix CI (clangtidyfull) (diff) | |
| download | inkscape-d26076c00288c835cd67d95723c8fed4a96a3784.tar.gz inkscape-d26076c00288c835cd67d95723c8fed4a96a3784.zip | |
Crashfix deleting path with invisible text on path
Fixes https://gitlab.com/inkscape/inbox/issues/491
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/sp-tspan.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/object/sp-tspan.cpp b/src/object/sp-tspan.cpp index 7a0db5687..76c9b1a3a 100644 --- a/src/object/sp-tspan.cpp +++ b/src/object/sp-tspan.cpp @@ -482,13 +482,29 @@ void sp_textpath_to_text(SPObject *tp) SPObject *text = tp->parent; Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine()); - + Geom::Point xy; if (!bbox) { - return; + // Text is not shown on canvas at all + // 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); + xy = midpoint; + } else { + xy = bbox->min(); + xy *= tp->document->getDocumentScale().inverse(); // Convert to user-units. } - - 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; |
