Class FontBuildingExtensions
- Namespace
- Icy.Configuration
- Assembly
- IcyUI.dll
Font steps for IFontConfigurationBuilder. Each runs on the built configuration's Fonts, in declaration order.
public static class FontBuildingExtensions
- Inheritance
-
FontBuildingExtensions
- Inherited Members
Examples
builder.ConfigureFonts()
.ImportFont("Fonts/MyFont.ttf")
.WithDefaultFontFamily("My Font");
Methods
ConfigureFonts(IConfigurationBuilder, Action<FontSystem>)
Configures the font system with a callback once the configuration is built.
public static IFontConfigurationBuilder ConfigureFonts(this IConfigurationBuilder builder, Action<FontSystem> configure)
Parameters
builderIConfigurationBuilderThe configuration builder.
configureAction<FontSystem>Receives the built FontSystem.
Returns
- IFontConfigurationBuilder
The fonts section of the builder.
ImportFont(IFontConfigurationBuilder, string)
Imports a font file shipped with the game, relative to the default asset context (the application folder unless changed).
public static IFontConfigurationBuilder ImportFont(this IFontConfigurationBuilder builder, string path)
Parameters
builderIFontConfigurationBuilderThe fonts section of a configuration builder.
pathstringThe font file's path, for example
"Fonts/MyFont.ttf". Copy it to the output folder.
Returns
- IFontConfigurationBuilder
The same fonts section, for chaining.
Remarks
The file is loaded when the configuration is built; a missing file throws there.
UseSystemFonts(IFontConfigurationBuilder, bool)
Lets fonts installed on this system be found by family name (EnableSystemFonts()), or stops it (DisableSystemFonts()).
public static IFontConfigurationBuilder UseSystemFonts(this IFontConfigurationBuilder builder, bool enabled = true)
Parameters
builderIFontConfigurationBuilderThe fonts section of a configuration builder.
enabledbooltrue (the default) to look fonts up on the system; false to use only imported fonts.
Returns
- IFontConfigurationBuilder
The same fonts section, for chaining.
Examples
game.UseIcyUI(ui => ui.ConfigureFonts()
.UseSystemFonts(false)
.ImportFont("Fonts/Inter.ttf")
.WithDefaultFontFamily("Inter"));
Remarks
On Windows this is the Windows fonts folder. On Linux and macOS, .NET maps it to the user's font folder
(~/.fonts, ~/Library/Fonts), so ship the font with the game and use
ImportFont(IFontConfigurationBuilder, string) there instead.
The engine defaults turn system fonts on. Since the last step wins, UseSystemFonts(false) in your own
configuration turns them off again; import your fonts and set
WithDefaultFontFamily(IFontConfigurationBuilder, string) to one of them, as the default family
(Segoe UI) is a system font.
WithDefaultFontFamily(IFontConfigurationBuilder, string)
Sets the family text uses when it doesn't name one (DefaultFontFamily).
public static IFontConfigurationBuilder WithDefaultFontFamily(this IFontConfigurationBuilder builder, string family)
Parameters
builderIFontConfigurationBuilderThe fonts section of a configuration builder.
familystringThe family name stored in the font file, such as
"Segoe UI".
Returns
- IFontConfigurationBuilder
The same fonts section, for chaining.
WithFallbackFont(IFontConfigurationBuilder, Func<IcyConfiguration, IFont>)
Sets the font used when nothing else resolves (FallbackFont).
public static IFontConfigurationBuilder WithFallbackFont(this IFontConfigurationBuilder builder, Func<IcyConfiguration, IFont> createFont)
Parameters
builderIFontConfigurationBuilderThe fonts section of a configuration builder.
createFontFunc<IcyConfiguration, IFont>Creates the font from the built configuration.
Returns
- IFontConfigurationBuilder
The same fonts section, for chaining.