Skip to content

Commit

Permalink
Don't modify Font.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
c4llv07e committed Jan 22, 2025
1 parent ea727f5 commit 888382b
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions Robust.Client/Graphics/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,7 @@ public VectorFont(FontResource res, int size)
public override int GetDescent(float scale) => Handle.GetDescent(scale);
public override int GetLineHeight(float scale) => Handle.GetLineHeight(scale);

public override float DrawChar(
DrawingHandleBase handle,
Rune rune,
Vector2 baseline,
float scale,
Color color,
bool fallback = true)
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
{
var metrics = Handle.GetCharMetrics(rune, scale);
if (!metrics.HasValue)
Expand All @@ -137,7 +131,6 @@ public override float DrawChar(
return metrics.Value.Advance;
}

var start = baseline;
baseline += new Vector2(metrics.Value.BearingX, -metrics.Value.BearingY);
if(handle is DrawingHandleWorld worldhandle)
worldhandle.DrawTextureRect(texture, Box2.FromDimensions(baseline, texture.Size), color);
Expand Down Expand Up @@ -179,13 +172,7 @@ public StackedFont(params Font[] args)
public override int GetLineHeight(float scale) => _main.GetLineHeight(scale);

// DrawChar just proxies to the stack, or invokes _main's fallback.
public override float DrawChar(
DrawingHandleBase handle,
Rune rune,
Vector2 baseline,
float scale,
Color color,
bool fallback = true)
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
{
foreach (var f in Stack)
{
Expand Down Expand Up @@ -223,13 +210,7 @@ public sealed class DummyFont : Font
public override int GetDescent(float scale) => default;
public override int GetLineHeight(float scale) => default;

public override float DrawChar(
DrawingHandleBase handle,
Rune rune,
Vector2 baseline,
float scale,
Color color,
bool fallback = true)
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
{
// Nada, it's a dummy after all.
return 0;
Expand Down

0 comments on commit 888382b

Please sign in to comment.