mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Improved handling of font metrics with overflow
This commit is contained in:
parent
fa1749b516
commit
40d6195db7
1 changed files with 10 additions and 10 deletions
|
@ -828,10 +828,10 @@ namespace Beefy.gfx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics g, StringView theString, FontMetrics* fontMetrics = null)
|
public void Draw(Graphics g, float x, float y, StringView theString, FontMetrics* fontMetrics = null)
|
||||||
{
|
{
|
||||||
float curX = 0;
|
float curX = x;
|
||||||
float curY = 0;
|
float curY = y;
|
||||||
|
|
||||||
Matrix newMatrix = Matrix();
|
Matrix newMatrix = Matrix();
|
||||||
bool hasClipRect = g.mClipRect.HasValue;
|
bool hasClipRect = g.mClipRect.HasValue;
|
||||||
|
@ -944,6 +944,9 @@ namespace Beefy.gfx
|
||||||
}
|
}
|
||||||
|
|
||||||
g.PopRenderState();
|
g.PopRenderState();
|
||||||
|
|
||||||
|
if (fontMetrics != null)
|
||||||
|
fontMetrics.mMaxX = Math.Max(fontMetrics.mMaxX, curX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float Draw(Graphics g, StringView theString, float x, float y, int32 justification = -1, float width = 0, FontOverflowMode stringEndMode = FontOverflowMode.Overflow, FontMetrics* fontMetrics = null)
|
public float Draw(Graphics g, StringView theString, float x, float y, int32 justification = -1, float width = 0, FontOverflowMode stringEndMode = FontOverflowMode.Overflow, FontMetrics* fontMetrics = null)
|
||||||
|
@ -1060,14 +1063,11 @@ namespace Beefy.gfx
|
||||||
|
|
||||||
if (g != null)
|
if (g != null)
|
||||||
{
|
{
|
||||||
using (g.PushTranslate(useX, useY))
|
Draw(g, useX, useY, workingStr, fontMetrics);
|
||||||
Draw(g, workingStr, fontMetrics);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fontMetrics != null)
|
|
||||||
fontMetrics.mMaxWidth = Math.Max(fontMetrics.mMaxWidth, GetWidth(workingStr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fontMetrics != null)
|
||||||
|
fontMetrics.mMaxWidth = Math.Max(fontMetrics.mMaxWidth, GetWidth(workingStr));
|
||||||
drawHeight += GetLineSpacing();
|
drawHeight += GetLineSpacing();
|
||||||
|
|
||||||
if (fontMetrics != null)
|
if (fontMetrics != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue