21 lines
662 B
C#
21 lines
662 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using SixLabors.Fonts;
|
|
|
|
namespace ImageProvider.Extensions {
|
|
public static class ServiceCollectionExtensions {
|
|
public static void RegisterImageProvider(this IServiceCollection services) {
|
|
services.AddSingleton<IFontCollection>(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<IImageProvider, ImageProvider>();
|
|
}
|
|
}
|
|
}
|