How to add font to SystemFonts in SixLabors.Fonts

497 Views Asked by At

According to the source code, SixLabors uses the basic fonts directories to search for fonts:

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
  StandardFontLocations = new[]
  {
    @"%SYSTEMROOT%\Fonts",
    @"%APPDATA%\Microsoft\Windows\Fonts",
    @"%LOCALAPPDATA%\Microsoft\Windows\Fonts",
  };
}

When I try to use this in a Blazor WebAssembly project, it returns 0 fonts.

In the source code of the SystemFonts class, I can only see a CreateFont method, where I can create fonts based on the fonts in the collection - and it is empty for now.

/// <summary>
/// Create a new instance of the <see cref="Font"/> for the named font family with regular styling.
/// </summary>
/// <param name="name">The font family name.</param>
/// <param name="culture">The font culture.</param>
/// <param name="size">The size of the font in PT units.</param>
/// <returns>The new <see cref="Font"/>.</returns>
public static Font CreateFont(string name, CultureInfo culture, float size)
    => Collection.Get(name, culture).CreateFont(size);

Any idea how to add a font from the project or make it found at least 1 font?

0

There are 0 best solutions below