Code

Use correct text anchor for vertical text and when aligning or distributing
[inkscape.git] / src / ui / dialog / align-and-distribute.cpp
index 024d4b2f12dff91a762342732b72c57d1f586bde..2bba0a0f8e22d6c85cd3c401828d861d69c3a5ef 100644 (file)
@@ -705,14 +705,16 @@ private :
         {
             if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
                 Inkscape::Text::Layout const *layout = te_get_layout(*it);
-                Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
-                if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
-                if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
-                if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
-                if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y];
-
-                Baselines b (*it, base, _orientation);
-                sorted.push_back(b);
+                boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
+                if (pt) {
+                    Geom::Point base = *pt * sp_item_i2d_affine(*it);
+                    if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
+                    if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
+                    if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
+                    if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y];
+                    Baselines b (*it, base, _orientation);
+                    sorted.push_back(b);
+                }
             }
         }
 
@@ -746,11 +748,14 @@ private :
             {
                 if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
                     Inkscape::Text::Layout const *layout = te_get_layout(*it);
-                    Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
-                    Geom::Point t(0.0, 0.0);
-                    t[_orientation] = b_min[_orientation] - base[_orientation];
-                    sp_item_move_rel(*it, Geom::Translate(t));
-                    changed = true;
+                    boost::optional<Geom::Point> pt = layout->baselineAnchorPoint();
+                    if (pt) {
+                        Geom::Point base = *pt * sp_item_i2d_affine(*it);
+                        Geom::Point t(0.0, 0.0);
+                        t[_orientation] = b_min[_orientation] - base[_orientation];
+                        sp_item_move_rel(*it, Geom::Translate(t));
+                        changed = true;
+                    }
                 }
             }