Utility/SimpleTextDrawer: Fix line bounds
This commit is contained in:
parent
65c6996ccd
commit
d68346ca17
|
|
@ -89,6 +89,7 @@ Nazara Engine:
|
|||
- Added AbstractTextDrawer::GetLineGlyphCount, which returns the number of glyph part of the line
|
||||
- Fixed Font handling of whitespace glyphs (which were triggering an error)
|
||||
- ⚠️ Translucent2D pipeline no longer has depth sorting
|
||||
- Fixed SimpleTextDrawer line bounds
|
||||
|
||||
Nazara Development Kit:
|
||||
- Added ImageWidget (#139)
|
||||
|
|
|
|||
|
|
@ -354,42 +354,38 @@ namespace Nz
|
|||
{
|
||||
glyph.atlas = nullptr;
|
||||
|
||||
glyph.bounds.Set(float(m_drawPos.x), float(0.f), float(advance), float(sizeInfo.lineHeight));
|
||||
glyph.bounds.Set(float(m_drawPos.x), m_lines.back().bounds.y, float(advance), float(sizeInfo.lineHeight));
|
||||
|
||||
glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop));
|
||||
glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop));
|
||||
glyph.corners[2].Set(glyph.bounds.GetCorner(RectCorner_LeftBottom));
|
||||
glyph.corners[3].Set(glyph.bounds.GetCorner(RectCorner_RightBottom));
|
||||
|
||||
switch (character)
|
||||
{
|
||||
case '\n':
|
||||
{
|
||||
// Extend the line bounding rect to the last glyph it contains, thus extending upon all glyphs of the line
|
||||
if (!m_glyphs.empty())
|
||||
{
|
||||
Glyph& lastGlyph = m_glyphs.back();
|
||||
m_lines.back().bounds.ExtendTo(lastGlyph.bounds);
|
||||
}
|
||||
|
||||
// Reset cursor
|
||||
advance = 0;
|
||||
m_drawPos.x = 0;
|
||||
m_drawPos.y += sizeInfo.lineHeight;
|
||||
|
||||
m_workingBounds.ExtendTo(m_lines.back().bounds);
|
||||
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lines.back().bounds.ExtendTo(glyph.bounds);
|
||||
|
||||
switch (character)
|
||||
{
|
||||
case '\n':
|
||||
{
|
||||
// Reset cursor
|
||||
advance = 0;
|
||||
m_drawPos.x = 0;
|
||||
m_drawPos.y += sizeInfo.lineHeight;
|
||||
|
||||
m_workingBounds.ExtendTo(m_lines.back().bounds);
|
||||
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
m_drawPos.x += advance;
|
||||
break;
|
||||
}
|
||||
|
||||
m_drawPos.x += advance;
|
||||
m_glyphs.push_back(glyph);
|
||||
}
|
||||
m_lines.back().bounds.ExtendTo(m_glyphs.back().bounds);
|
||||
|
||||
m_workingBounds.ExtendTo(m_lines.back().bounds);
|
||||
|
||||
m_bounds.Set(Rectf(std::floor(m_workingBounds.x), std::floor(m_workingBounds.y), std::ceil(m_workingBounds.width), std::ceil(m_workingBounds.height)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue