Add legacy font lookup support for comma/percent

This commit is contained in:
Dean Herbert 2020-10-15 17:56:37 +09:00
parent 254eba9008
commit 4f6dd15869
1 changed files with 21 additions and 1 deletions

View File

@ -34,7 +34,9 @@ public LegacyGlyphStore(ISkin skin)
public ITexturedCharacterGlyph Get(string fontName, char character) public ITexturedCharacterGlyph Get(string fontName, char character)
{ {
var texture = skin.GetTexture($"{fontName}-{character}"); var lookup = getLookupName(character);
var texture = skin.GetTexture($"{fontName}-{lookup}");
if (texture == null) if (texture == null)
return null; return null;
@ -42,6 +44,24 @@ public ITexturedCharacterGlyph Get(string fontName, char character)
return new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust); return new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, null), texture, 1f / texture.ScaleAdjust);
} }
private static string getLookupName(char character)
{
switch (character)
{
case ',':
return "comma";
case '.':
return "dot";
case '%':
return "percent";
default:
return character.ToString();
}
}
public Task<ITexturedCharacterGlyph> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character)); public Task<ITexturedCharacterGlyph> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
} }
} }