diff --git a/src/Murder/Core/Graphics/DrawInfo.cs b/src/Murder/Core/Graphics/DrawInfo.cs index 84925018..2a0ed592 100644 --- a/src/Murder/Core/Graphics/DrawInfo.cs +++ b/src/Murder/Core/Graphics/DrawInfo.cs @@ -59,6 +59,11 @@ public readonly struct DrawInfo public Rectangle Clip { get; init; } = Rectangle.Empty; + /// + /// Whether this should bypass localization fonts. + /// + public bool CultureInvariant { get; init; } = false; + public DrawInfo() { } diff --git a/src/Murder/Data/GameDataManager.cs b/src/Murder/Data/GameDataManager.cs index c9402580..64d8136e 100644 --- a/src/Murder/Data/GameDataManager.cs +++ b/src/Murder/Data/GameDataManager.cs @@ -866,9 +866,9 @@ public ImmutableDictionary FilterOutAssets(params Type[] types) return builder.ToImmutableDictionary(); } - public PixelFont GetFont(int index) + public PixelFont GetFont(int index, bool cultureInvariant = false) { - if (_game is not null) + if (_game is not null && !cultureInvariant) { index = _game.GetLocalizedFont(index); } diff --git a/src/Murder/Services/MurderFonts.cs b/src/Murder/Services/MurderFonts.cs index 6cb331cb..a35468a6 100644 --- a/src/Murder/Services/MurderFonts.cs +++ b/src/Murder/Services/MurderFonts.cs @@ -30,4 +30,10 @@ public static float GetLineWidth(this MurderFonts font, string text) { return GetLineWidth((int)font, text); } + + public static int GetFontHeight(this MurderFonts font) + { + PixelFont f = Game.Data.GetFont((int)font); + return f.LineHeight; + } } \ No newline at end of file diff --git a/src/Murder/Services/RenderServices.cs b/src/Murder/Services/RenderServices.cs index ae682996..9505b664 100644 --- a/src/Murder/Services/RenderServices.cs +++ b/src/Murder/Services/RenderServices.cs @@ -987,9 +987,10 @@ public static Point DrawText(this Batch2D uiBatch, MurderFonts font, string text => DrawText(uiBatch, (int)font, text, position, maxWidth, -1, drawInfo ?? DrawInfo.Default); public static Point DrawText(this Batch2D uiBatch, MurderFonts font, string text, Vector2 position, int maxWidth, int visibleCharacters, DrawInfo? drawInfo = default) => DrawText(uiBatch, (int)font, text, position, maxWidth, visibleCharacters, drawInfo ?? DrawInfo.Default); + public static Point DrawText(this Batch2D uiBatch, int pixelFont, string text, Vector2 position, int maxWidth, int visibleCharacters, DrawInfo drawInfo) { - var font = Game.Data.GetFont(pixelFont); + var font = Game.Data.GetFont(pixelFont, cultureInvariant: drawInfo.CultureInvariant); return font.Draw(uiBatch, text, position + drawInfo.Offset, drawInfo.Origin, drawInfo.Scale, drawInfo.Sort, drawInfo.Color, drawInfo.Outline, drawInfo.Shadow, maxWidth, visibleCharacters, drawInfo.Debug); }