// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
using System.Collections.Generic;
using System.Globalization;
namespace SixLabors.Fonts {
///
/// Provides a collection of fonts.
///
public static class SystemFonts
{
private static readonly Lazy LazySystemFonts = new(() => new SystemFontCollection(), true);
///
/// Gets the collection containing the globally installed system fonts.
///
public static IReadOnlySystemFontCollection Collection => LazySystemFonts.Value;
///
/// Gets the collection of s installed on current system.
///
public static IEnumerable Families => Collection.Families;
///
public static FontFamily Get(string name) => GetByCulture(name, CultureInfo.InvariantCulture);
///
public static bool TryGet(string fontFamily, out FontFamily family)
=> Collection.TryGet(fontFamily, out family);
///
/// Create a new instance of the for the named font family with regular styling.
///
/// The font family name.
/// The size of the font in PT units.
/// The new .
public static Font CreateFont(string name, float size)
=> Collection.Get(name).CreateFont(size);
///
/// Create a new instance of the for the named font family.
///
/// The font family name.
/// The size of the font in PT units.
/// The font style.
/// The new .
public static Font CreateFont(string name, float size, FontStyle style)
=> Collection.Get(name).CreateFont(size, style);
///
public static IEnumerable GetByCulture(CultureInfo culture)
=> Collection.GetByCulture(culture);
///
public static FontFamily GetByCulture(string fontFamily, CultureInfo culture)
=> Collection.GetByCulture(fontFamily, culture);
///
public static bool TryGetByCulture(string fontFamily, CultureInfo culture, out FontFamily family)
=> Collection.TryGetByCulture(fontFamily, culture, out family);
///
/// Create a new instance of the for the named font family with regular styling.
///
/// The font family name.
/// The font culture.
/// The size of the font in PT units.
/// The new .
public static Font CreateFont(string name, CultureInfo culture, float size)
=> Collection.GetByCulture(name, culture).CreateFont(size);
///
/// Create a new instance of the for the named font family.
///
/// The font family name.
/// The font culture.
/// The size of the font in PT units.
/// The font style.
/// The new .
public static Font CreateFont(string name, CultureInfo culture, float size, FontStyle style)
=> Collection.GetByCulture(name, culture).CreateFont(size, style);
}
}