* fix formatting rules * reformat ersatztv * reformat ersatztv.application * reformat ersatztv.core * refactor ersatztv.core.tests * reformat ersatztv.ffmpeg * reformat ersatztv.ffmpeg.tests * reformat ersatztv.infrastructure * cleanup infra mysql * cleanup infra sqlite * cleanup infra tests * cleanup ersatztv.scanner * cleanup ersatztv.scanner.tests * sln cleanup * update dependencies
32 lines
924 B
C#
32 lines
924 B
C#
using Topten.RichTextKit;
|
|
|
|
namespace ErsatzTV.Infrastructure.Streaming.Graphics;
|
|
|
|
public class GraphicsEngineFonts(CustomFontMapper mapper)
|
|
{
|
|
private static readonly System.Collections.Generic.HashSet<string> LoadedFontFiles
|
|
= new(StringComparer.OrdinalIgnoreCase);
|
|
|
|
public FontMapper Mapper => mapper;
|
|
|
|
public void LoadFonts(string fontsFolder)
|
|
{
|
|
foreach (string file in Directory.EnumerateFiles(fontsFolder, "*.*", SearchOption.AllDirectories))
|
|
{
|
|
if (!file.EndsWith(".ttf", StringComparison.OrdinalIgnoreCase) &&
|
|
!file.EndsWith(".otf", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (!LoadedFontFiles.Add(file))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
using FileStream stream = File.OpenRead(file);
|
|
mapper.LoadPrivateFont(stream, null);
|
|
}
|
|
}
|
|
}
|