WIP: fonts.

This commit is contained in:
2023-06-20 00:18:35 +02:00
parent 72b6896d3e
commit 193462b747
11 changed files with 79 additions and 9 deletions

View File

@@ -4,13 +4,16 @@ public class FontLoader : IResourceLoader
{
public IEnumerable<string> SupportedExtensions => new string[]
{
".ttf"
"ttf"
};
public Type ResourceType => typeof(Font);
public Resource Load(string path)
{
return default;
byte[] fileBuffer = File.ReadAllBytes(path);
var result = new Font(path, fileBuffer);
result.BufferSize = fileBuffer.Length;
return result;
}
}

View File

@@ -5,6 +5,8 @@ namespace DaggerFramework
public string? Path { get => _path; set => _path = value; }
public byte[]? Buffer { get => _buffer; set => _buffer = value; }
public long BufferSize { get; set; }
public Resource(string path, byte[] buffer)
{
_path = path;

View File

@@ -102,7 +102,8 @@ namespace DaggerFramework.Resources
private readonly Dictionary<Type, IResourceLoader> _resourceLoaderAssociations = new()
{
{typeof(Sound), new SoundLoader()},
{typeof(Texture2d), new Texture2dLoader()}
{typeof(Texture2d), new Texture2dLoader()},
{typeof(Font), new FontLoader()}
};
private Dictionary<string, Resource> _loadedResources = new();

View File

@@ -4,7 +4,6 @@ namespace DaggerFramework
{
public SoundFormat Format { get; set; }
public int SampleRate { get; set; }
public int BufferSize { get; set; }
public Sound(string path, byte[] buffer) : base(path, buffer)
{