Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Sorokin <sorok-roma@yandex.ru>2014-10-03 09:54:39 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:27:53 +0300
commitaf701adea57c34914576d5f5548fdb2d9636b652 (patch)
tree3e8e029de3599740711bcff70adb993c27a74252 /drape_frontend
parentcb77e3a51975530284c0691885d5eb7c50aa9214 (diff)
Improved drawing of curved text
Diffstat (limited to 'drape_frontend')
-rw-r--r--drape_frontend/text_layout.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/drape_frontend/text_layout.cpp b/drape_frontend/text_layout.cpp
index fe108a535d..12c64141d9 100644
--- a/drape_frontend/text_layout.cpp
+++ b/drape_frontend/text_layout.cpp
@@ -207,14 +207,14 @@ void TextLayout::LayoutPathText(m2::Spline::iterator const & iterator,
positions.SetFillDirection(df::Backward);
m2::Spline::iterator itr = iterator;
+ m2::Spline::iterator leftTentacle, rightTentacle;
uint32_t glyphCount = GetGlyphCount();
int32_t startIndex = isForwardDirection ? 0 : glyphCount - 1;
int32_t endIndex = isForwardDirection ? glyphCount : -1;
int32_t incSign = isForwardDirection ? 1 : -1;
- m2::PointD accum = itr.m_dir;
- float const koef = 0.7f;
+ float const tentacleLength = m_font.m_size * 1.6f * scalePtoG;
rects.resize(GetGlyphCount());
@@ -227,11 +227,29 @@ void TextLayout::LayoutPathText(m2::Spline::iterator const & iterator,
ASSERT_NOT_EQUAL(advance, 0.0, ());
m2::PointD pos = itr.m_pos;
- itr.Step(advance);
- ASSERT(!itr.BeginAgain(), ());
+ double cosa = 1.0;
+
+ m2::PointD dir;
+ m2::PointD posOffset;
+ if (itr.GetLength() <= tentacleLength || itr.GetLength() >= itr.GetFullLength() - tentacleLength)
+ {
+ dir = itr.m_avrDir.Normalize();
+ }
+ else
+ {
+ leftTentacle = itr;
+ leftTentacle.StepBack(tentacleLength);
+ rightTentacle = itr;
+ rightTentacle.Step(tentacleLength);
+ dir = (-leftTentacle.m_avrDir + rightTentacle.m_avrDir).Normalize();
+ cosa = m2::DotProduct(-leftTentacle.m_avrDir, rightTentacle.m_avrDir) / rightTentacle.m_avrDir.Length() / leftTentacle.m_avrDir.Length();
+ posOffset = (leftTentacle.m_pos + rightTentacle.m_pos) / 2.0;
+ pos = (posOffset + itr.m_pos) / 2.0;
+ }
+
+ itr.Step(advance + (1.0 - cosa) * advance * 0.7);
+ //ASSERT(!itr.BeginAgain(), ());
- m2::PointD dir = (itr.m_avrDir.Normalize() * koef + accum * (1.0f - koef)).Normalize();
- accum = dir;
m2::PointD norm(-dir.y, dir.x);
dir *= halfWidth * scalePtoG;
norm *= halfHeight * scalePtoG;