MCPcopy Create free account
hub / github.com/comaps/comaps / PathTextLayout

Method PathTextLayout

libs/drape_frontend/text_layout.cpp:392–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392PathTextLayout::PathTextLayout(m2::PointD const & tileCenter, std::string const & text, float fontSize,
393 ref_ptr<dp::TextureManager> textureManager,
394 localisation::LanguageIndex const textLanguageIndex)
395 : m_tileCenter(tileCenter)
396{
397 /*
398 * TODO Temporary workaround: If the string contains newlines, replace them with whitespaces.
399 * On the long run, this should be fixed in the map generator and this workaround removed after
400 * a few months, when maps with buggy data can be expected to have been phased out.
401 */
402 std::string stext = text;
403 while (stext.find('\n') != std::string::npos)
404 stext[stext.find('\n')] = ' ';
405 ASSERT_EQUAL(std::string::npos, stext.find('\n'), ("Multiline text is not expected", stext));
406
407 auto const fontScale = static_cast<float>(VisualParams::Instance().GetFontScale());
408 m_textSizeRatio = fontSize * fontScale / dp::kBaseFontSizePixels;
409
410 // TODO(AB): StraightTextLayout used a logic to split a longer string into two strings.
411 m_shapedGlyphs =
412 textureManager->ShapeSingleTextLine(dp::kBaseFontSizePixels, stext, &m_glyphRegions, textLanguageIndex);
413}
414
415void PathTextLayout::CacheStaticGeometry(dp::TextureManager::ColorRegion const & colorRegion,
416 dp::TextureManager::ColorRegion const & outlineRegion,

Callers

nothing calls this directly

Calls 3

GetFontScaleMethod · 0.80
ShapeSingleTextLineMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected