If you're going to perform multiple operations on the same character and you want a speed-up, call this function with the character you're going to process, then use glyph-based functions instead of the codepoint-based functions.
Frees the allocated bitmap.
Allocates a large-enough single-channel 8bpp bitmap and renders the specified character/glyph at the specified scale into it, with antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). *width & *height are filled out with the width & height of the bitmap, which is stored left-to-right, top-to-bottom.
Gets the bbox of the bitmap centered around the glyph origin; so the bitmap width is ix1-ix0, height is iy1-iy0, and location to place the bitmap top left is (leftSideBearing*scale,iy0). (Note that the bitmap uses y-increases-down, but the shape uses y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
Same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel shift for the character.
The same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel shift for the character.
Gets the bounding box of the visible part of the glyph, in unscaled coordinates
leftSideBearing is the offset from the current horizontal position to the left edge of the character advanceWidth is the offset from the current horizontal position to the next horizontal position these are expressed in unscaled coordinates
an additional amount to add to the 'advance' value between ch1 and ch2 @TODO; for now always returns 0!
the bounding box around all possible characters
Each .ttf/.ttc file may have more than one font. Each font has a sequential index number starting from 0. Call this function to get the font offset for a given index; it returns -1 if the index is out of range. A regular .ttf file will only define one font and it always be at offset 0, so it will return '0' for index 0, and -1 for all other indices. You can just skip this step if you know it's that kind of font.
Ascent is the coordinate above the baseline the font extends; descent is the coordinate below the baseline the font extends (i.e. it is typically negative) lineGap is the spacing between one row's descent and the next row's ascent... so you should advance the vertical position by "*ascent - *descent + *lineGap" these are expressed in unscaled coordinates, so you must multiply by the scale factor for a given size
///////////////////////////////////////////////////////////////////////////
As above, but takes one or more glyph indices for greater efficiency
Given an offset into the file that defines a font, this function builds the necessary cached info for the rest of the system. You must allocate the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't need to do anything special to free it, because the contents are pure value data with no additional data structures. Returns 0 on failure.
The same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the width and height and positioning info for it first.
Same as stbtt_MakeCodepointBitmap, but you can specify a subpixel shift for the character.
computes a scale factor to produce a font whose EM size is mapped to 'pixels' tall. This is probably what traditional APIs compute, but I'm not positive.
Computes a scale factor to produce a font whose "height" is 'pixels' tall. Height is measured as the distance from the highest ascender to the lowest descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics and computing: scale = pixels / (ascent - descent) so if you prefer to measure height by the ascent only, use a similar calculation.
The following structure is defined publically so you can declare one on the stack or as a global or etc, but you should treat it as opaque.
D translation of stb_truetype v0.7 by Sean Barrett More information on http://nothings.org/stb/stb_truetype.h Removed: - texture baking API - font finding in the TTF itself. Make sure there is only one font in the TTF.