FontCollectionExtensions.AddFont(IFontCollection, String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the font specified in filename
to the fontCollection
, with an optional font alias specified in alias
.
public static Microsoft.Maui.Hosting.IFontCollection AddFont (this Microsoft.Maui.Hosting.IFontCollection fontCollection, string filename, string? alias = default);
static member AddFont : Microsoft.Maui.Hosting.IFontCollection * string * string -> Microsoft.Maui.Hosting.IFontCollection
<Extension()>
Public Function AddFont (fontCollection As IFontCollection, filename As String, Optional alias As String = Nothing) As IFontCollection
Parameters
- fontCollection
- IFontCollection
The collection to add the font to.
- filename
- String
The filename of the font to add, such as a True type format (TTF) or open type font (OTF) font file. Font files can be added to the 'Resources\Fonts' of a .NET MAUI project.
- alias
- String
An optional alias that can also be used to reference this font.
Returns
Exceptions
The filename
parameter is null
.
The filename
parameter is empty or only whitespace.