forked from organicmaps/organicmaps
correctly drawing StraightTextElement with non-identity draw matrix.
This commit is contained in:
parent
a07f4f3cde
commit
dae0ebca04
5 changed files with 34 additions and 7 deletions
|
@ -67,7 +67,8 @@ namespace yg
|
|||
: m_firstVisible(0),
|
||||
m_lastVisible(visText.size()),
|
||||
m_fontDesc(fontDesc),
|
||||
m_pivot(pt)
|
||||
m_pivot(pt),
|
||||
m_offset(0, 0)
|
||||
{
|
||||
m_entries.reserve(visText.size());
|
||||
m_metrics.reserve(visText.size());
|
||||
|
@ -145,7 +146,8 @@ namespace yg
|
|||
m_pos(src.m_pos),
|
||||
m_fontDesc(src.m_fontDesc),
|
||||
m_metrics(src.m_metrics),
|
||||
m_pivot(0, 0)
|
||||
m_pivot(0, 0),
|
||||
m_offset(0, 0)
|
||||
{
|
||||
if (!m_fontDesc.IsValid())
|
||||
return;
|
||||
|
@ -167,7 +169,8 @@ namespace yg
|
|||
m_visText(visText),
|
||||
m_pos(pos),
|
||||
m_fontDesc(fontDesc),
|
||||
m_pivot(0, 0)
|
||||
m_pivot(0, 0),
|
||||
m_offset(0, 0)
|
||||
{
|
||||
if (!m_fontDesc.IsValid())
|
||||
return;
|
||||
|
@ -412,6 +415,19 @@ namespace yg
|
|||
m_pivot = pivot;
|
||||
}
|
||||
|
||||
m2::PointD const & GlyphLayout::offset() const
|
||||
{
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
void GlyphLayout::setOffset(m2::PointD const & offset)
|
||||
{
|
||||
for (unsigned i = 0; i < m_boundRects.size(); ++i)
|
||||
m_boundRects[i].Offset(offset - m_offset);
|
||||
|
||||
m_offset = offset;
|
||||
}
|
||||
|
||||
yg::FontDesc const & GlyphLayout::fontDesc() const
|
||||
{
|
||||
return m_fontDesc;
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace yg
|
|||
buffer_vector<m2::AnyRectD, 16> m_boundRects;
|
||||
|
||||
m2::PointD m_pivot;
|
||||
m2::PointD m_offset;
|
||||
|
||||
double getKerning(GlyphLayoutElem const & prevElem, GlyphMetrics const & prevMetrics, GlyphLayoutElem const & curElem, GlyphMetrics const & curMetrics);
|
||||
void computeBoundRects();
|
||||
|
@ -86,9 +87,12 @@ namespace yg
|
|||
buffer_vector<GlyphMetrics, 32> const & metrics() const;
|
||||
buffer_vector<m2::AnyRectD, 16> const & boundRects() const;
|
||||
|
||||
m2::PointD const & pivot() const;
|
||||
yg::FontDesc const & fontDesc() const;
|
||||
|
||||
m2::PointD const & pivot() const;
|
||||
void setPivot(m2::PointD const & pv);
|
||||
|
||||
m2::PointD const & offset() const;
|
||||
void setOffset(m2::PointD const & offs);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ namespace yg
|
|||
m2::PointD const & pivot() const;
|
||||
void setPivot(m2::PointD const & pv);
|
||||
|
||||
m2::PointD const & offset() const;
|
||||
void setOffset(m2::PointD const & offs);
|
||||
|
||||
yg::EPosition position() const;
|
||||
void setPosition(yg::EPosition pos);
|
||||
|
||||
|
|
|
@ -226,7 +226,10 @@ namespace yg
|
|||
setPivot(pivot() * m);
|
||||
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
m_glyphLayouts[i].setPivot(pivot() + m_offsets[i]);
|
||||
{
|
||||
m_glyphLayouts[i].setPivot(pivot());
|
||||
m_glyphLayouts[i].setOffset(m_offsets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
vector<m2::AnyRectD> const & StraightTextElement::boundRects() const
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace yg
|
|||
return;
|
||||
|
||||
m2::PointD pv = layout.pivot();
|
||||
m2::PointD offs = layout.offset();
|
||||
double deltaA = 0;
|
||||
|
||||
if (doTransformPivotOnly)
|
||||
|
@ -113,12 +114,12 @@ namespace yg
|
|||
|
||||
if (doTransformPivotOnly)
|
||||
{
|
||||
glyphPt = pv + elem.m_pt;
|
||||
glyphPt = pv + offs + elem.m_pt;
|
||||
glyphAngle = elem.m_angle;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyphPt = (pv + elem.m_pt) * m;
|
||||
glyphPt = (pv + offs + elem.m_pt) * m;
|
||||
glyphAngle = ang::AngleD(elem.m_angle.val() + deltaA);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue