Font.FromFile

static Font FromFile(string fontFile)

   
string fontFile A file address for the font! For example: ‘C:/Windows/Fonts/segoeui.ttf’
RETURNS: Font A font from the given file, or null if the file failed to load properly!

Loads a font and creates a font asset from it.

Examples

Drawing text with and without a TextStyle

Basic text We can use a TextStyle object to control how text gets displayed!

TextStyle style;

In initialization, we can create the style from a font, a size, a material, and a base color.

style = Text.MakeStyle(
    Font.FromFile("C:/Windows/Fonts/Arial.ttf"), 
    2 * U.cm,
lt.MaterialFont.Copy(), 
    Color.HSV(0.05f, 0.7f, 0.8f));

Then it’s pretty trivial to just draw some text on the screen! Just call Text.Add on update. If you don’t have a TextStyle available, calling it without one will just fall back on the default style.

// Text with an explicit text style
Text.Add(
    "Here's\nSome\nMulti-line\nText!!", 
    Matrix.TRS(new Vec3(0.1f, 0, 0), Quat.LookDir(0, 0, 1)),
    style);
// Text using the default text style
Text.Add(
    "Here's\nSome\nMulti-line\nText!!", 
    Matrix.TRS(new Vec3(-0.1f, 0, 0), Quat.LookDir(0, 0, 1)));