/// <summary> /// Load a system font and register it in the texture storage. /// </summary> /// <param name="name">Name of the system font.</param> /// <param name="size">Size to render the font at.</param> /// <param name="ranges">The character ranges to render to the font atlas.</param> /// <param name="fallbackCharacter">Optional fallback character for the font. Defaults to <c>0</c> (no fallback).</param> public static TextureFont LoadSystemFont(this ITextureStorage storage, string name, float size, IEnumerable <Range <int> > ranges, int fallbackCharacter = 0) { FontAtlasHelpers.CreateSystemFont(name, size, ranges, out var glyphMap, out var image); var width = image.Width; var height = image.Height; var texId = RegisterImage(storage, image); image.Dispose(); return(new TextureFont(glyphMap.ToUvGlyphMap(width, height), texId, fallbackCharacter)); }
/// <summary> /// Load a font and register it in the texture storage. /// </summary> /// <param name="storage">The texture storage to register the font atlas.</param> /// <param name="path">Path to the font file.</param> /// <param name="size">Size to render the font at.</param> /// <param name="fallbackCharacter">Optional fallback character for the font. Defaults to <c>0</c> (no fallback).</param> public static TextureFont LoadFont(this ITextureStorage storage, string path, float size, int fallbackCharacter = 0) { FontAtlasHelpers.CreateFont(path, size, out var glyphMap, out var image); var width = image.Width; var height = image.Height; var texId = RegisterImage(storage, image); image.Dispose(); return(new TextureFont(glyphMap.ToUvGlyphMap(width, height), texId, fallbackCharacter)); }