diff options
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; |
