From 55a3ba9d19a1ecbaa9f499e482e8f6c4fdec139e Mon Sep 17 00:00:00 2001 From: rachytski Date: Tue, 29 Nov 2011 19:35:31 +0400 Subject: [PATCH] fixed logic upon which the secondary text is drawn. --- yg/font_desc.cpp | 5 +++++ yg/font_desc.hpp | 3 ++- yg/glyph_layout.cpp | 7 +++++++ yg/straight_text_element.cpp | 4 +++- yg/text_element.cpp | 12 ++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/yg/font_desc.cpp b/yg/font_desc.cpp index 3f577b8490..68a0bd88df 100644 --- a/yg/font_desc.cpp +++ b/yg/font_desc.cpp @@ -22,6 +22,11 @@ namespace yg m_size += static_cast(rank * m_size); } + bool FontDesc::IsValid() const + { + return m_size != -1; + } + bool FontDesc::operator ==(FontDesc const & src) const { return (m_size == src.m_size) diff --git a/yg/font_desc.hpp b/yg/font_desc.hpp index b8e108927b..3df47fa196 100644 --- a/yg/font_desc.hpp +++ b/yg/font_desc.hpp @@ -11,10 +11,11 @@ namespace yg bool m_isMasked; yg::Color m_maskColor; - FontDesc(int size = 10, yg::Color const & color = yg::Color(0, 0, 0, 255), + FontDesc(int size = -1, yg::Color const & color = yg::Color(0, 0, 0, 255), bool isMasked = true, yg::Color const & maskColor = yg::Color(255, 255, 255, 255)); void SetRank(double rank); + bool IsValid() const; bool operator != (FontDesc const & src) const; bool operator == (FontDesc const & src) const; diff --git a/yg/glyph_layout.cpp b/yg/glyph_layout.cpp index 0edb65742f..f2c0af14b2 100644 --- a/yg/glyph_layout.cpp +++ b/yg/glyph_layout.cpp @@ -69,6 +69,9 @@ namespace yg m_fontDesc(fontDesc), m_pivot(pt) { + if (!m_fontDesc.IsValid()) + return; + m2::RectD boundRect; m2::PointD curPt(0, 0); @@ -141,6 +144,8 @@ namespace yg m_metrics(src.m_metrics), m_pivot(0, 0) { + if (!m_fontDesc.IsValid()) + return; m_boundRects.push_back(m2::AnyRectD(m2::RectD(0, 0, 0, 0))); m_fullLength = (m2::PointD(src.m_fullLength, 0) * m).Length(m2::PointD(0, 0) * m); m_pathOffset = (m2::PointD(src.m_pathOffset, 0) * m).Length(m2::PointD(0, 0) * m); @@ -165,6 +170,8 @@ namespace yg m_fontDesc(fontDesc), m_pivot(0, 0) { + if (!m_fontDesc.IsValid()) + return; m_boundRects.push_back(m2::AnyRectD(m2::RectD(0, 0, 0, 0))); for (size_t i = 0; i < m_visText.size(); ++i) m_metrics.push_back(glyphCache->getGlyphMetrics(GlyphKey(visText[i], m_fontDesc.m_size, m_fontDesc.m_isMasked, yg::Color(0, 0, 0, 0)))); diff --git a/yg/straight_text_element.cpp b/yg/straight_text_element.cpp index da73bda6ad..e68c7ddb91 100644 --- a/yg/straight_text_element.cpp +++ b/yg/straight_text_element.cpp @@ -84,6 +84,8 @@ namespace yg StraightTextElement::StraightTextElement(Params const & p) : TextElement(p) { + ASSERT(p.m_fontDesc.IsValid(), ()); + buffer_vector res; if ((p.m_doSplit) && (!isBidi())) { @@ -109,7 +111,7 @@ namespace yg buffer_vector auxRes; - if (!auxVisText().empty()) + if (p.m_auxFontDesc.IsValid() && (!auxVisText().empty())) { GlyphLayout l(p.m_glyphCache, p.m_auxFontDesc, m2::PointD(0, 0), auxVisText(), yg::EPosCenter); if (l.boundRects().back().GetGlobalRect().SizeX() > allElemWidth) diff --git a/yg/text_element.cpp b/yg/text_element.cpp index 406b506bfe..99e35538b4 100644 --- a/yg/text_element.cpp +++ b/yg/text_element.cpp @@ -75,6 +75,9 @@ namespace yg FontDesc const & fontDesc, double depth) const { + if (!fontDesc.IsValid()) + return; + m2::PointD pv = layout.pivot(); double deltaA = 0; @@ -123,6 +126,9 @@ namespace yg StylesCache * stylesCache, FontDesc const & desc) const { + if (!desc.IsValid()) + return; + shared_ptr const & skinPage = stylesCache->cachePage(); GlyphCache * glyphCache = stylesCache->glyphCache(); @@ -152,6 +158,9 @@ namespace yg bool TextElement::find(GlyphLayout const & layout, StylesCache * stylesCache, FontDesc const & desc) const { + if (!desc.IsValid()) + return false; + shared_ptr const & skinPage = stylesCache->cachePage(); for (unsigned i = layout.firstVisible(); i < layout.lastVisible(); ++i) @@ -175,6 +184,9 @@ namespace yg StylesCache * stylesCache, vector & v) const { + if (!desc.IsValid()) + return; + shared_ptr const & skinPage = stylesCache->cachePage(); GlyphCache * glyphCache = stylesCache->glyphCache();