diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2013-05-30 19:39:46 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:55:56 +0300 |
commit | 4140b7552a61ca0b755e52a7036f5cc18e75e24d (patch) | |
tree | b128ebbb324efd630ccfbd3cab439b86b6192ab3 /graphics | |
parent | c138ac9af2f1740c77e19dc8988502871d404b68 (diff) |
we need to allow baseline offset when calculate text position
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/glyph_layout.cpp | 9 | ||||
-rw-r--r-- | graphics/glyph_layout.hpp | 2 | ||||
-rw-r--r-- | graphics/straight_text_element.cpp | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/graphics/glyph_layout.cpp b/graphics/glyph_layout.cpp index fe1e546c09..7e9e0d86ad 100644 --- a/graphics/glyph_layout.cpp +++ b/graphics/glyph_layout.cpp @@ -518,4 +518,13 @@ namespace graphics { return m_fontDesc; } + + int GlyphLayout::baseLineOffset() + { + int result = 0; + for (size_t i = 0; i < m_metrics.size(); ++i) + result = min(m_metrics[i].m_yOffset, result); + + return -result; + } } diff --git a/graphics/glyph_layout.hpp b/graphics/glyph_layout.hpp index 356b93d27a..9ed34fcee4 100644 --- a/graphics/glyph_layout.hpp +++ b/graphics/glyph_layout.hpp @@ -120,5 +120,7 @@ namespace graphics m2::PointD const & offset() const; void setOffset(m2::PointD const & offs); + + int baseLineOffset(); }; } diff --git a/graphics/straight_text_element.cpp b/graphics/straight_text_element.cpp index 5cab7fc41a..d3cb0a3cb4 100644 --- a/graphics/straight_text_element.cpp +++ b/graphics/straight_text_element.cpp @@ -129,6 +129,9 @@ namespace graphics m_glyphLayouts.push_back(GlyphLayout(p.m_glyphCache, p.m_auxFontDesc, m2::PointD(0, 0), auxRes[i], graphics::EPosCenter)); } + for (size_t i = 0; i < m_glyphLayouts.size(); ++i) + allElemHeight -= m_glyphLayouts[i].baseLineOffset(); + double curShift = allElemHeight / 2; /// performing aligning of glyphLayouts as for the center position |