From: Diederik van Lierop Date: Mon, 28 Dec 2009 12:31:56 +0000 (+0100) Subject: Use correct text anchor for vertical text and when aligning or distributing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=55699a55a25127de4cbd3a068db4dab7443c0643;p=inkscape.git Use correct text anchor for vertical text and when aligning or distributing --- diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index f4e8e4031..0682e3570 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -227,7 +227,11 @@ boost::optional Layout::baselineAnchorPoint() const Geom::Point left_pt = this->characterAnchorPoint(pos); pos.thisEndOfLine(); Geom::Point right_pt = this->characterAnchorPoint(pos); - Geom::Point mid_pt = (left_pt + right_pt)/2; + + if (this->_blockProgression() == LEFT_TO_RIGHT || this->_blockProgression() == RIGHT_TO_LEFT) { + left_pt = Geom::Point(left_pt[Geom::Y], left_pt[Geom::X]); + right_pt = Geom::Point(right_pt[Geom::Y], right_pt[Geom::X]); + } switch (this->paragraphAlignment(pos)) { case LEFT: @@ -235,7 +239,7 @@ boost::optional Layout::baselineAnchorPoint() const return left_pt; break; case CENTER: - return mid_pt; + return (left_pt + right_pt)/2; // middle point break; case RIGHT: return right_pt; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 024d4b2f1..2bba0a0f8 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -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 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 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; + } } }