summaryrefslogtreecommitdiffstats
path: root/src/sp-text.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mailat-signdiedenrezidotnl>2009-12-13 13:00:22 +0000
committerDiederik van Lierop <mailat-signdiedenrezidotnl>2009-12-13 13:00:22 +0000
commitda49b977d3a7e002c88780c24d9c4020cbe80b0e (patch)
tree9b8013d89cac18fd774622911a140ca1d13f0baf /src/sp-text.cpp
parentReenable new input device dialog for further development (diff)
downloadinkscape-da49b977d3a7e002c88780c24d9c4020cbe80b0e.tar.gz
inkscape-da49b977d3a7e002c88780c24d9c4020cbe80b0e.zip
Position of baseline anchor is now dependent of the text alignment
Fixed bugs: - https://launchpad.net/bugs/168329 (bzr r8887)
Diffstat (limited to 'src/sp-text.cpp')
-rw-r--r--src/sp-text.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index 87c67c646..423922b80 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -431,30 +431,13 @@ sp_text_description(SPItem *item)
static void sp_text_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const */*snapprefs*/)
{
// 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)
+ // 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);
-
- Inkscape::Text::Layout::iterator pos = layout->begin();
- Inkscape::Text::Layout::Alignment text_alignment = layout->paragraphAlignment(pos);
-
- Geom::Point left_pt = layout->characterAnchorPoint(pos) * sp_item_i2d_affine(item);
- pos.thisEndOfLine();
- Geom::Point right_pt = layout->characterAnchorPoint(pos) * sp_item_i2d_affine(item);
- Geom::Point mid_pt = (left_pt + right_pt)/2;
-
- switch (text_alignment) {
- case Inkscape::Text::Layout::LEFT:
- case Inkscape::Text::Layout::FULL:
- p.push_back(std::make_pair(left_pt, type));
- break;
- case Inkscape::Text::Layout::CENTER:
- p.push_back(std::make_pair(mid_pt, type));
- break;
- default: //RIGHT
- p.push_back(std::make_pair(right_pt, type));
- break;
+ 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));
}
}
}