Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions osu.Game.Benchmarks/BenchmarkEmojiStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Text;
using BenchmarkDotNet.Attributes;
using NUnit.Framework;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Rendering.Dummy;
using osu.Framework.IO.Stores;
using osu.Framework.Text;
using osu.Game.Graphics;
using osu.Game.Resources;

namespace osu.Game.Benchmarks
{
public class BenchmarkEmojiStore : BenchmarkTest
{
private TestEmojiStore store = null!;
private ITexturedCharacterGlyph? glyph = null;

public override void SetUp()
{
store = new TestEmojiStore(new DummyRenderer(), new ResourceStore<byte[]>(new DllResourceStore(OsuResources.ResourceAssembly)));
}

[Benchmark]
[Arguments(1)]
[Arguments(10)]
[Arguments(100)]
public void BenchmarkToGetResource(int n)
{
for (int i = 0; i < n; i++)
{
// from 🐀 (U+1F400) we have enough consecutive emojis to test
glyph = store.Get(null, (Grapheme)new Rune(0x1f400 + i));
// clear texture cache, for consistent results
store.Purge(glyph!);
}
}

[Benchmark]
public void BenchmarkMissingEmoji()
{
glyph = store.Get(null, new Grapheme(" "));
Assert.Null(glyph);
}

private class TestEmojiStore : EmojiStore
{
public TestEmojiStore(IRenderer renderer, ResourceStore<byte[]> resourceStore)
: base(renderer, resourceStore) { }

public void Purge(ITexturedCharacterGlyph glyph)
{
Purge(glyph.Texture);
}
}
}
}
116 changes: 116 additions & 0 deletions osu.Game/Graphics/EmojiStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Text;
using osu.Game.IO.Archives;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;

namespace osu.Game.Graphics
{
public class EmojiStore : TextureStore, ITexturedGlyphLookupStore

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 21 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'EmojiStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'
{
public const string FONT_NAME = @"Emoji";

public EmojiStore(IRenderer renderer, ResourceStore<byte[]> resourceStore)
: base(renderer, new EmojiTextureLoaderStore(resourceStore))
{
}

public ITexturedCharacterGlyph? Get(string? fontName, Grapheme character)

Check failure on line 30 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
if (string.IsNullOrEmpty(fontName) || fontName == FONT_NAME)
{
// Convert the character to a sequence of hex values joined by underscores
// Example: "👍" -> "1f44d"
// Example: "👨‍👩‍👧‍👦" -> "1f468_200d_1f469_200d_1f467_200d_1f466"
var texture = Get(string.Join(
"_",
character.ToString().EnumerateRunes().Select(rune => rune.Value.ToString("X").ToLower(CultureInfo.InvariantCulture))
) + ".raw");

return texture != null ? new EmojiGlyph(texture, character) : null;
}

return null;
}

public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, Grapheme character) => Task.Run(() => Get(fontName, character));

Check failure on line 48 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

private sealed class EmojiTextureLoaderStore : IResourceStore<TextureUpload>
{
private readonly ZipArchiveReader store;

public EmojiTextureLoaderStore(ResourceStore<byte[]> resourceStore)
{
store = new ZipArchiveReader(resourceStore.GetStream(@"Textures/Emoji/Emoji.zip"));
}

public Task<TextureUpload> GetAsync(string name, CancellationToken cancellationToken = default) =>
Task.Run(() => Get(name), cancellationToken);

public TextureUpload Get(string name)
{
var stream = store.GetStream(name);

// Each emoji is stored as a 50x50 pixel RGBA32 image (4 bytes per pixel)
// Total size = 50 * 50 * 4 = 10000 bytes
if (stream != null && stream.Length == 50 * 50 * 4)
{
var memory = MemoryAllocator.Default.Allocate<byte>(50 * 50 * 4);

stream.ReadExactly(memory.Memory.Span);

return new TextureUpload(Image.WrapMemory<Rgba32>(memory, 50, 50));
}

return null!;
}

public Stream GetStream(string name) => store.GetStream(name);

public IEnumerable<string> GetAvailableResources() => store.GetAvailableResources();

#region IDisposable Support

public void Dispose()
{
store.Dispose();
}

#endregion
}

public class EmojiGlyph : ITexturedCharacterGlyph

Check failure on line 94 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'EmojiStore.EmojiGlyph' does not implement interface member 'ICharacterGlyph.Character'. 'EmojiStore.EmojiGlyph.Character' cannot implement 'ICharacterGlyph.Character' because it does not have the matching return type of 'char'.

Check failure on line 94 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'EmojiStore.EmojiGlyph' does not implement interface member 'ICharacterGlyph.Character'. 'EmojiStore.EmojiGlyph.Character' cannot implement 'ICharacterGlyph.Character' because it does not have the matching return type of 'char'.

Check failure on line 94 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'EmojiStore.EmojiGlyph' does not implement interface member 'ICharacterGlyph.Character'. 'EmojiStore.EmojiGlyph.Character' cannot implement 'ICharacterGlyph.Character' because it does not have the matching return type of 'char'.

Check failure on line 94 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'EmojiStore.EmojiGlyph' does not implement interface member 'ICharacterGlyph.Character'. 'EmojiStore.EmojiGlyph.Character' cannot implement 'ICharacterGlyph.Character' because it does not have the matching return type of 'char'.
{
public float XOffset => default;
public float YOffset => default;
public float XAdvance => 1;
public float Baseline => 0.79f;
public Grapheme Character { get; }

Check failure on line 100 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 100 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 100 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 100 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

public float GetKerning<T>(T lastGlyph) where T : ICharacterGlyph => 0;

public Texture Texture { get; }
public float Width => 1;
public float Height => 1;
public bool Coloured => true;

public EmojiGlyph(Texture texture, Grapheme character)

Check failure on line 109 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 109 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 109 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 109 in osu.Game/Graphics/EmojiStore.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
Texture = texture;
Character = character;
}
}
}
}
9 changes: 5 additions & 4 deletions osu.Game/Graphics/OsuIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@
this.textures = textures;
}

public ITexturedCharacterGlyph? Get(string? fontName, char character)
public ITexturedCharacterGlyph? Get(string? fontName, Grapheme character)

Check failure on line 414 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 414 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 414 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 414 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 414 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
if (fontName == FONT_NAME)
return new Glyph(textures.Get($@"{fontName}/{((OsuIconMapping)character).GetDescription()}"));
return new Glyph(textures.Get($@"{fontName}/{((OsuIconMapping)character.CharValue).GetDescription()}"));

return null;
}

public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, Grapheme character) => Task.Run(() => Get(fontName, character));

Check failure on line 422 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 422 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 422 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 422 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 422 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

public Texture? Get(string name, WrapMode wrapModeS, WrapMode wrapModeT) => null;

Expand All @@ -439,13 +439,14 @@
public float YOffset => default;
public float XAdvance => default;
public float Baseline => default;
public char Character => default;
public Grapheme Character => default;

Check failure on line 442 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 442 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 442 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Code Quality

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 442 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 442 in osu.Game/Graphics/OsuIcon.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

public float GetKerning<T>(T lastGlyph) where T : ICharacterGlyph => throw new NotImplementedException();

public Texture Texture { get; }
public float Width => Texture.Width;
public float Height => Texture.Height;
public bool Coloured => false;

public Glyph(Texture texture)
{
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Framework.Text;
using osu.Game.Localisation;

namespace osu.Game.Graphics.UserInterface
{
public partial class OsuPasswordTextBox : OsuTextBox
{
protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
protected override Drawable GetDrawableCharacter(Grapheme c) => new FallingDownContainer
{
AutoSizeAxes = Axes.Both,
Child = new PasswordMaskChar(FontSize),
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Graphics/UserInterface/OsuTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Text;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
Expand Down Expand Up @@ -274,7 +275,7 @@
base.OnFocusLost(e);
}

protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
protected override Drawable GetDrawableCharacter(Grapheme c) => new FallingDownContainer

Check failure on line 278 in osu.Game/Graphics/UserInterface/OsuTextBox.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
AutoSizeAxes = Axes.Both,
Child = new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: FontSize) },
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Graphics/UserInterface/ShearedSearchTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Framework.Text;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Resources.Localisation.Web;
Expand Down Expand Up @@ -141,7 +142,7 @@ public override void Hide()
}
}

protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
protected override Drawable GetDrawableCharacter(Grapheme c) => new FallingDownContainer
{
AutoSizeAxes = Axes.Both,
Child = new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: 20, weight: FontWeight.SemiBold) },
Expand Down
12 changes: 10 additions & 2 deletions osu.Game/IO/Archives/ZipArchiveReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public sealed class ZipArchiveReader : ArchiveReader
private readonly Stream archiveStream;
private readonly ZipArchive archive;

private readonly Dictionary<string, ZipArchiveEntry> entries = new Dictionary<string, ZipArchiveEntry>();

static ZipArchiveReader()
{
// Required to support rare code pages.
Expand All @@ -47,12 +49,18 @@ public ZipArchiveReader(Stream archiveStream, string name = null)
{
ArchiveEncoding = DEFAULT_ENCODING
});

// Cache all non-directory entries in the archive and store them in a dictionary for fast lookup
foreach (var entry in archive.Entries.Where(e => !e.IsDirectory))
{
if (entry.Key != null)
entries[entry.Key] = entry;
}
}

public override Stream GetStream(string name)
{
ZipArchiveEntry entry = archive.Entries.SingleOrDefault(e => e.Key == name);
if (entry == null)
if (!entries.TryGetValue(name, out var entry))
return null;

using (Stream s = entry.OpenEntryStream())
Expand Down
1 change: 1 addition & 0 deletions osu.Game/OsuGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ protected virtual void InitialiseFonts()
AddFont(Resources, @"Fonts/Venera/Venera-Bold");
AddFont(Resources, @"Fonts/Venera/Venera-Black");

Fonts.AddStore(new EmojiStore(Host.Renderer, Resources));
Fonts.AddStore(new OsuIcon.OsuIconStore(Textures));
}

Expand Down
14 changes: 7 additions & 7 deletions osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@

// cache common lookups ahead of time.
foreach (char c in new[] { '.', '%', 'x' })
glyphStore.Get(font_name, c);
glyphStore.Get(font_name, new Grapheme(c));
for (int i = 0; i < 10; i++)
glyphStore.Get(font_name, (char)('0' + i));
glyphStore.Get(font_name, new Grapheme((char)('0' + i)));
}

protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);

private class GlyphStore : ITexturedGlyphLookupStore

Check failure on line 161 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'ArgonCounterTextComponent.ArgonCounterSpriteText.GlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 161 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

'ArgonCounterTextComponent.ArgonCounterSpriteText.GlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'

Check failure on line 161 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'ArgonCounterTextComponent.ArgonCounterSpriteText.GlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 161 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'ArgonCounterTextComponent.ArgonCounterSpriteText.GlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'
{
private readonly string fontName;
private readonly TextureStore textures;
Expand All @@ -173,28 +173,28 @@
this.getLookup = getLookup;
}

public ITexturedCharacterGlyph? Get(string? fontName, char character)
public ITexturedCharacterGlyph? Get(string? fontName, Grapheme character)

Check failure on line 176 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 176 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
// We only service one font.
if (fontName != this.fontName)
return null;

if (cache.TryGetValue(character, out var cached))
if (cache.TryGetValue(character.CharValue, out var cached))
return cached;

string lookup = getLookup(character);
string lookup = getLookup(character.CharValue);
var texture = textures.Get($"Gameplay/Fonts/{fontName}-{lookup}");

TexturedCharacterGlyph? glyph = null;

if (texture != null)
glyph = new TexturedCharacterGlyph(new CharacterGlyph(character, 0, 0, texture.Width, texture.Height, null), texture, 0.125f);

cache[character] = glyph;
cache[character.CharValue] = glyph;
return glyph;
}

public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, Grapheme character) => Task.Run(() => Get(fontName, character));

Check failure on line 197 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Build only (iOS)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 197 in osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions osu.Game/Skinning/LegacySpriteText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@

// cache common lookups ahead of time.
foreach (char c in FixedWidthExcludeCharacters)
glyphStore.Get(fontPrefix, c);
glyphStore.Get(fontPrefix, new Grapheme(c));
for (int i = 0; i < 10; i++)
glyphStore.Get(fontPrefix, (char)('0' + i));
glyphStore.Get(fontPrefix, new Grapheme((char)('0' + i)));
}

protected override TextBuilder CreateTextBuilder(ITexturedGlyphLookupStore store) => base.CreateTextBuilder(glyphStore);

private class LegacyGlyphStore : ITexturedGlyphLookupStore

Check failure on line 63 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'LegacySpriteText.LegacyGlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 63 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'LegacySpriteText.LegacyGlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'

Check failure on line 63 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'LegacySpriteText.LegacyGlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.GetAsync(string, char)'

Check failure on line 63 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'LegacySpriteText.LegacyGlyphStore' does not implement interface member 'ITexturedGlyphLookupStore.Get(string?, char)'
{
private readonly ISkin skin;
private readonly Vector2? maxSize;

private readonly string fontName;

private readonly Dictionary<char, ITexturedCharacterGlyph?> cache = new Dictionary<char, ITexturedCharacterGlyph?>();
private readonly Dictionary<Grapheme, ITexturedCharacterGlyph?> cache = new Dictionary<Grapheme, ITexturedCharacterGlyph?>();

Check failure on line 70 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 70 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

public LegacyGlyphStore(string fontName, ISkin skin, Vector2? maxSize)
{
Expand All @@ -76,7 +76,7 @@
this.maxSize = maxSize;
}

public ITexturedCharacterGlyph? Get(string? fontName, char character)
public ITexturedCharacterGlyph? Get(string? fontName, Grapheme character)

Check failure on line 79 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 79 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
// We only service one font.
if (fontName != this.fontName)
Expand All @@ -103,9 +103,9 @@
return glyph;
}

private static string getLookupName(char character)
private static string getLookupName(Grapheme character)

Check failure on line 106 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 106 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
{
switch (character)
switch (character.CharValue)
{
case ',':
return "comma";
Expand All @@ -121,7 +121,7 @@
}
}

public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, char character) => Task.Run(() => Get(fontName, character));
public Task<ITexturedCharacterGlyph?> GetAsync(string fontName, Grapheme character) => Task.Run(() => Get(fontName, character));

Check failure on line 124 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 124 in osu.Game/Skinning/LegacySpriteText.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

The type or namespace name 'Grapheme' could not be found (are you missing a using directive or an assembly reference?)
}
}
}
Loading