Skip to content

Commit

Permalink
Merge branch 'master' into circular-progress-protected
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach authored Nov 27, 2023
2 parents 583c9de + 7261bc7 commit 272e04e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Benchmarks/BenchmarkTextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void initialiseBuilder(bool withDifferentBaselines)

private class TestStore : ITexturedGlyphLookupStore
{
public ITexturedCharacterGlyph Get(string fontName, char character) => new TexturedCharacterGlyph(
public ITexturedCharacterGlyph Get(string? fontName, char character) => new TexturedCharacterGlyph(
new CharacterGlyph(character, character, character, character, character, null),
new DummyRenderer().CreateTexture(1, 1));

Expand Down
21 changes: 13 additions & 8 deletions osu.Framework/IO/Stores/FontStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Textures;
Expand All @@ -20,7 +19,7 @@ public class FontStore : TextureStore, ITexturedGlyphLookupStore
{
private readonly List<IGlyphStore> glyphStores = new List<IGlyphStore>();

private readonly List<FontStore> nestedFontStores = new List<FontStore>();
private readonly List<ITexturedGlyphLookupStore> nestedFontStores = new List<ITexturedGlyphLookupStore>();

private Storage cacheStorage;

Expand Down Expand Up @@ -77,12 +76,18 @@ public override void AddTextureSource(IResourceStore<TextureUpload> store)

public override void AddStore(ITextureStore store)
{
if (store is FontStore fs)
switch (store)
{
// if null, share the main store's atlas.
fs.Atlas ??= Atlas;
fs.cacheStorage ??= cacheStorage;
nestedFontStores.Add(fs);
case FontStore fs:
// if null, share the main store's atlas.
fs.Atlas ??= Atlas;
fs.cacheStorage ??= cacheStorage;
nestedFontStores.Add(fs);
break;

case ITexturedGlyphLookupStore gs:
nestedFontStores.Add(gs);
break;
}

base.AddStore(store);
Expand Down Expand Up @@ -132,7 +137,7 @@ public override void RemoveStore(ITextureStore store)
base.RemoveStore(store);
}

public ITexturedCharacterGlyph Get([CanBeNull] string fontName, char character)
public ITexturedCharacterGlyph Get(string fontName, char character)
{
var key = (fontName, character);

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/IO/Stores/GlyphStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public GlyphStore(ResourceStore<byte[]> store, string assetName = null, IResourc
AssetName = assetName;
TextureLoader = textureLoader;

FontName = assetName?.Split('/').Last();
FontName = assetName?.Split('/').Last() ?? string.Empty;
}

private Task fontLoadTask;
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Text/ITexturedGlyphLookupStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ITexturedGlyphLookupStore
/// <param name="fontName">The name of the font.</param>
/// <param name="character">The character to retrieve.</param>
/// <returns>The character glyph.</returns>
ITexturedCharacterGlyph? Get(string fontName, char character);
ITexturedCharacterGlyph? Get(string? fontName, char character);

/// <summary>
/// Retrieves a glyph from the store asynchronously.
Expand Down

0 comments on commit 272e04e

Please sign in to comment.