fontutil is a small collection of utility functions to make working with fonts easier.
Find returns the path to a font file given a font name. It's (intended to be) an OS-agnostic way to locate font files installed on the system. If you need to include fonts with your application instead of finding them on the system, this isn't for you.
Find currently only supports Windows but contributions for other systems are quite welcome! I'm also open to changing the interface. For example, separately specifying style, variant, or weight or a css-like list of prioritized font or family names. I'm unsure if/how these changes could be implemented on the different systems.
- Windows (REG: Fonts Entries)
- OS X (Font locations and their purposes)
- Linux (Debian, Ubuntu, others?)
FindAndParse calls Find to find a font file, reads it, parses it, and returns the *truetype.Font
.
DrawWidth returns the width of a string if it were drawn to a Context, as the X coordinate of a raster.Point
.
CenterX returns the the start point required to center a string within a Rectangle, as the X coordinate of a raster.Point
.