diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index 0d3fd791b58f813b10ab94ceb0cedff731276adf..423922b80c991a11207973b3ab800b1185a18ee3 100644 (file)
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
static void sp_text_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const */*snapprefs*/)
{
- // the baseline anchor of the first char
+ // Choose a point on the baseline for snapping from or to, with the horizontal position
+ // of this point depending on the text alignment (left vs. right)
Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item);
- if(layout != NULL) {
- int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE);
- p.push_back(std::make_pair(layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item), type));
+ if (layout != NULL && layout->outputExists()) {
+ boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
+ if (pt) {
+ int type = target ? int(Inkscape::SNAPTARGET_TEXT_BASELINE) : int(Inkscape::SNAPSOURCE_TEXT_BASELINE);
+ p.push_back(std::make_pair((*pt) * sp_item_i2d_affine(item), type));
+ }
}
}