InfiniText

From PowerUI
Jump to: navigation, search

InfiniText is PowerUI's text library. It directly loads font files and parses out the glyphs and various TTF tables (such as kerning pairs). All of its functionality is available within the InfiniText namespace - virtually all of it is public too so you can pull glyphs from fonts and use them however you'd like.

Font family vs. font face

It's easy to mix these two up, so it's worth just making the distinction clear right away. A font family is a group of font faces. Font files (such as .ttf and .otf) contain exactly one font face and the name of the family they belong to. So, when you load up a font face, InfiniText will automatically create the family to go with it. It indexes all of its loaded font content by family.

Getting started quickly

If you have a block of bytes - either a ttf, otf or woff (1 or 2) - simply call the Fonts.Load method:

// Load a byte[] as a font face. Note that you can use e.g. XMLHttpRequest to get that byte[] with any of your supported protocols.
FontFace myFontFace = InfiniText.Fonts.Load(myFontFaceBytes);

To deal with font families (ones that PowerUI has loaded up will show up here too):

// A dictionary of all loaded font *families*
// InfiniText.Fonts.All

// Get the loaded up font family called 'Arial' (for this to work, at least one face must've been passed to Fonts.Load):
FontFamily arial = InfiniText.Fonts.Get("Arial");