using Microsoft.Extensions.DependencyInjection; using SixLabors.Fonts; namespace ImageProvider.Extensions { public static class ServiceCollectionExtensions { public static void RegisterImageProvider(this IServiceCollection services) { services.AddSingleton(x => { var fontCollection = new FontCollection(); foreach (var font in Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Fonts"), "*.ttf", SearchOption.AllDirectories)) fontCollection.Install(font); return fontCollection; }); services.AddSingleton(); } } }