Module truetype
Free functions used to create and prepare some font objects.
Functions
- GetFontOffsetForIndex (bytes[, index=1])
-
Each .ttf / .ttc file may have more than one font. Each font has a sequential
index number starting from 1. Call this function to get the font offset for
a given index. A regular .ttf file will only define one font that will always be
at offset 0, so it will return 0 for index 1, and -1 for all other indices.
You can just skip this step if you know it's that kind of font.
Parameters:
- bytes Bytes or string Font data, e.g. as read from a file. Data is assumed to be valid.
- index uint Font index, ≥ 1. (default 1)
Returns:
-
int
Offset into bytes, or -1 if index is out of range.
See also:
- NewFont (bytes[, offset=0])
-
Given an offset into the file that defines a font, this function builds
the necessary cached info for the rest of the system. You don't need to
do anything special to free it, because the contents are pure value data
with no additional data structures.
Parameters:
- bytes Bytes or string Font data, typically the contents of a file.
- offset int Offset into bytes, cf. GetFontOffsetForIndex. (default 0)
Returns:
- NewPacking (width, height[, stride_in_bytes=0[, packing=1]])
-
Initializes a packing context. Future calls using this context will pack
characters into its 1-channel, width x height bitmap.
TODO: options for bitmap...
Parameters:
- width uint Packing width...
- height uint ...and height.
- stride_in_bytes uint Distance from one row to the next (or 0 to mean they are packed tightly together). (default 0)
- packing uint Amount of padding to leave between each character (normally you want 1 for bitmaps you'll use as textures with bilinear filtering). (default 1)
Returns:
- PointSize (size)
-
Encode a size so that certain methods associate it with FontInfo:ScaleForMappingEmToPixels.
Parameters:
- size number Font size, > 0.
Returns:
-
string
Encoded size.