1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 13:33:52 +08:00

Fix torus "medium" weight not mapped to "regular" when using With

This commit is contained in:
Salman Ahmed 2022-06-13 04:44:28 +03:00
parent 051aa8f028
commit 7971355660

View File

@ -35,7 +35,10 @@ namespace osu.Game.Graphics
/// <param name="fixedWidth">Whether all characters should be spaced the same distance apart.</param>
/// <returns>The <see cref="FontUsage"/>.</returns>
public static FontUsage GetFont(Typeface typeface = Typeface.Torus, float size = DEFAULT_FONT_SIZE, FontWeight weight = FontWeight.Medium, bool italics = false, bool fixedWidth = false)
=> new FontUsage(GetFamilyString(typeface), size, GetWeightString(typeface, weight), getItalics(italics), fixedWidth);
{
string familyString = GetFamilyString(typeface);
return new FontUsage(familyString, size, GetWeightString(familyString, weight), getItalics(italics), fixedWidth);
}
private static bool getItalics(in bool italicsRequested)
{
@ -72,25 +75,17 @@ namespace osu.Game.Graphics
/// <summary>
/// Retrieves the string representation of a <see cref="FontWeight"/>.
/// </summary>
/// <param name="typeface">The <see cref="Typeface"/>.</param>
/// <param name="weight">The <see cref="FontWeight"/>.</param>
/// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="typeface"/>.</returns>
public static string GetWeightString(Typeface typeface, FontWeight weight)
/// <param name="family">The font family.</param>
/// <param name="weight">The font weight.</param>
/// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="family"/>.</returns>
public static string GetWeightString(string family, FontWeight weight)
{
if (typeface == Typeface.Torus && weight == FontWeight.Medium)
if (family == @"Torus" && weight == FontWeight.Medium)
// torus doesn't have a medium; fallback to regular.
weight = FontWeight.Regular;
return GetWeightString(GetFamilyString(typeface), weight);
return weight.ToString();
}
/// <summary>
/// Retrieves the string representation of a <see cref="FontWeight"/>.
/// </summary>
/// <param name="family">The family string.</param>
/// <param name="weight">The <see cref="FontWeight"/>.</param>
/// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="family"/>.</returns>
public static string GetWeightString(string family, FontWeight weight) => weight.ToString();
}
public static class OsuFontExtensions