diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index 4636a44e49..0b69ee1b61 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -261,7 +261,7 @@ bool DrawerYG::drawPathText(di::PathInfo const & info, string const & name, uint name, info.GetLength(), info.GetOffset(), - yg::gl::Screen::middle_line, + yg::EPosCenter, yg::maxDepth); } diff --git a/yg/text_renderer.cpp b/yg/text_renderer.cpp index 2fface166a..ad96a997b0 100644 --- a/yg/text_renderer.cpp +++ b/yg/text_renderer.cpp @@ -397,7 +397,7 @@ namespace yg bool TextRenderer::drawPathText( FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text, - double fullLength, double pathOffset, TextPos pos, double depth) + double fullLength, double pathOffset, yg::EPosition pos, double depth) { if (!m_drawTexts) return false; @@ -418,7 +418,7 @@ namespace yg bool TextRenderer::drawPathTextImpl( FontDesc const & fontDesc, m2::PointD const * path, size_t s, string const & utf8Text, - double fullLength, double pathOffset, TextPos pos, double depth) + double fullLength, double pathOffset, yg::EPosition pos, double depth) { pts_array arrPath(path, s, fullLength, pathOffset); @@ -428,9 +428,10 @@ namespace yg float blOffset = 2; switch (pos) { - case under_line: blOffset -= fontDesc.m_size; break; - case middle_line: blOffset -= fontDesc.m_size / 2; break; - case above_line: blOffset -= 0; break; + case yg::EPosUnder: blOffset -= fontDesc.m_size; break; + case yg::EPosCenter: blOffset -= fontDesc.m_size / 2; break; + case yg::EPosAbove: blOffset -= 0; break; + default: blOffset -= fontDesc.m_size / 2; break; } size_t const count = text.size(); diff --git a/yg/text_renderer.hpp b/yg/text_renderer.hpp index 1114f4aa53..f18fad3b51 100644 --- a/yg/text_renderer.hpp +++ b/yg/text_renderer.hpp @@ -20,9 +20,6 @@ namespace yg { public: - enum TextPos { under_line, middle_line, above_line }; - - class TextObj { FontDesc m_fontDesc; @@ -79,7 +76,7 @@ namespace yg string const & utf8Text, double fullLength, double pathOffset, - TextPos pos, + yg::EPosition pos, double depth); /// Drawing text from point rotated by the angle. @@ -131,7 +128,7 @@ namespace yg string const & utf8Text, double fullLength, double pathOffset, - TextPos pos, + yg::EPosition pos, double depth); diff --git a/yg/yg_tests/screengl_test.cpp b/yg/yg_tests/screengl_test.cpp index ff07037ec3..38cf9267e8 100644 --- a/yg/yg_tests/screengl_test.cpp +++ b/yg/yg_tests/screengl_test.cpp @@ -719,7 +719,33 @@ namespace { p->drawPath(&m_path[0], m_path.size(), p->skin()->mapPenInfo(m_penInfo), 0); yg::FontDesc fontDesc(false, 10); - p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, calc_length(m_path), 0.0, yg::gl::Screen::middle_line, 0); + p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, calc_length(m_path), 0.0, yg::EPosCenter, 0); + } + }; + + struct TestDrawTextOnPathZigZag + { + std::vector m_path; + std::string m_text; + yg::PenInfo m_penInfo; + + TestDrawTextOnPathZigZag() + { + m_path.push_back(m2::PointD(40, 200)); + m_path.push_back(m2::PointD(100, 100)); + m_path.push_back(m2::PointD(160, 200)); + m_path.push_back(m2::PointD(200, 100)); + m_text = "Simplicity is the ultimate sophistication. Leonardo Da Vinci."; + + double pat[] = { 2, 2 }; + m_penInfo = yg::PenInfo(yg::Color(0, 0, 0, 0xFF), 2, &pat[0], ARRAY_SIZE(pat), 0); + } + + void DoDraw(shared_ptr p) + { + p->drawPath(&m_path[0], m_path.size(), p->skin()->mapPenInfo(m_penInfo), 0); + yg::FontDesc fontDesc(false, 10); + p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, calc_length(m_path), 0.0, yg::EPosCenter, 0); } }; @@ -732,8 +758,8 @@ namespace double const len = calc_length(m_path); yg::FontDesc fontDesc(false, 10); - p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::gl::Screen::above_line, 0); - p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::gl::Screen::under_line, 0); + p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::EPosAbove, 0); + p->drawPathText(fontDesc, &m_path[0], m_path.size(), m_text, len, 0.0, yg::EPosUnder, 0); } }; @@ -1008,7 +1034,8 @@ namespace // UNIT_TEST_GL(TestDrawUnicodeSymbols); // UNIT_TEST_GL(TestDrawTextRectWithFixedFont); // UNIT_TEST_GL(TestDrawStringOnString); -// UNIT_TEST_GL(TestDrawTextOnPath); +// UNIT_TEST_GL(TestDrawTextOnPath); + UNIT_TEST_GL(TestDrawTextOnPathZigZag); // UNIT_TEST_GL(TestDrawTextOnPathWithOffset); // UNIT_TEST_GL(TestDrawTextOverflow); // UNIT_TEST_GL(TestDrawTextFiltering); @@ -1023,7 +1050,7 @@ namespace // UNIT_TEST_GL(TestDrawPathSolid2PX); // UNIT_TEST_GL(TestDrawPathSolid); // UNIT_TEST_GL(TestDrawSector); - UNIT_TEST_GL(TestDrawPathSolidDiffWidth); +// UNIT_TEST_GL(TestDrawPathSolidDiffWidth); // UNIT_TEST_GL(TestDrawPathZigZag); // UNIT_TEST_GL(TestDrawPathSolidWithZ); // UNIT_TEST_GL(TestDrawPathSolidWithClipRect);