diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2011-06-30 20:46:15 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mail@diedenrezi.nl> | 2011-06-30 20:46:15 +0000 |
| commit | 8911d9a8ca0c7f4ef1476b2f056adf2afa4e99cd (patch) | |
| tree | bc14be1ac41f82196fc5a07ac99ff3613eeb4cd7 /src/libnrtype | |
| parent | Minimise GTK version changes in text-edit dialog (diff) | |
| download | inkscape-8911d9a8ca0c7f4ef1476b2f056adf2afa4e99cd.tar.gz inkscape-8911d9a8ca0c7f4ef1476b2f056adf2afa4e99cd.zip | |
Implement decent snapping to text (baseline & anchor), and provide a toggle button for this (as requested in LP bug #727281 )
(bzr r10392)
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/Layout-TNG-OutIter.cpp | 21 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index 4d461a486..1d300b210 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -13,6 +13,7 @@ #include "font-instance.h" #include "svg/svg-length.h" #include <2geom/transforms.h> +#include <2geom/line.h> #include "style.h" namespace Inkscape { @@ -250,6 +251,26 @@ boost::optional<Geom::Point> Layout::baselineAnchorPoint() const } } +Geom::Path Layout::baseline() const +{ + iterator pos = this->begin(); + Geom::Point left_pt = this->characterAnchorPoint(pos); + pos.thisEndOfLine(); + Geom::Point right_pt = this->characterAnchorPoint(pos); + + 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]); + } + + Geom::Path baseline; + baseline.start(left_pt); + baseline.appendNew<Geom::LineSegment>(right_pt); + + return baseline; +} + + Geom::Point Layout::chunkAnchorPoint(iterator const &it) const { unsigned chunk_index; diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 7d0c58c3e..6ab02c0e3 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -486,6 +486,8 @@ public: For rightmost text, the rightmost... you probably got it by now ;-)*/ boost::optional<Geom::Point> baselineAnchorPoint() const; + Geom::Path baseline() const; + /** This is that value to apply to the x,y attributes of tspan role=line elements, and hence it takes alignment into account. */ Geom::Point chunkAnchorPoint(iterator const &it) const; |
