1
0
Fork 0
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:
Brian Fiete 2024-12-17 05:45:47 -08:00
parent fa1749b516
commit 40d6195db7

View file

@ -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 curY = 0;
float curX = x;
float curY = y;
Matrix newMatrix = Matrix();
bool hasClipRect = g.mClipRect.HasValue;
@ -944,6 +944,9 @@ namespace Beefy.gfx
}
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)
@ -1060,14 +1063,11 @@ namespace Beefy.gfx
if (g != null)
{
using (g.PushTranslate(useX, useY))
Draw(g, workingStr, fontMetrics);
}
else
{
if (fontMetrics != null)
fontMetrics.mMaxWidth = Math.Max(fontMetrics.mMaxWidth, GetWidth(workingStr));
Draw(g, useX, useY, workingStr, fontMetrics);
}
if (fontMetrics != null)
fontMetrics.mMaxWidth = Math.Max(fontMetrics.mMaxWidth, GetWidth(workingStr));
drawHeight += GetLineSpacing();
if (fontMetrics != null)