dplug.graphics.stb_truetype

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.

Members

Aliases

stbtt_vertex_type
alias stbtt_vertex_type = short
Undocumented in source.

Functions

iceil
int iceil(float x)
Undocumented in source. Be warned that the author may not have intended to support it.
ifloor
int ifloor(float x)
Undocumented in source. Be warned that the author may not have intended to support it.
new_active
stbtt__active_edge* new_active(stbtt__edge* e, int off_x, float start_point)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_FindGlyphIndex
int stbtt_FindGlyphIndex(const(stbtt_fontinfo)* info, int unicode_codepoint)

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.

stbtt_FlattenCurves
stbtt__point* stbtt_FlattenCurves(stbtt_vertex* vertices, int num_verts, float objspace_flatness, int** contour_lengths, int* num_contours)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_FreeBitmap
void stbtt_FreeBitmap(ubyte* bitmap)

Frees the allocated bitmap.

stbtt_FreeFont
void stbtt_FreeFont(stbtt_fontinfo* info)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_FreeShape
void stbtt_FreeShape(stbtt_fontinfo* info, stbtt_vertex* v)
stbtt_GetCodepointBitmapBox
void stbtt_GetCodepointBitmapBox(stbtt_fontinfo* font, int codepoint, float scale_x, float scale_y, int* ix0, int* iy0, int* ix1, int* iy1)

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.)

stbtt_GetCodepointBitmapBoxSubpixel
void stbtt_GetCodepointBitmapBoxSubpixel(stbtt_fontinfo* font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int* ix0, int* iy0, int* ix1, int* iy1)

Same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel shift for the character.

stbtt_GetCodepointBox
int stbtt_GetCodepointBox(stbtt_fontinfo* info, int codepoint, int* x0, int* y0, int* x1, int* y1)

Gets the bounding box of the visible part of the glyph, in unscaled coordinates

stbtt_GetCodepointHMetrics
void stbtt_GetCodepointHMetrics(stbtt_fontinfo* info, int codepoint, int* advanceWidth, int* leftSideBearing)

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

stbtt_GetCodepointKernAdvance
int stbtt_GetCodepointKernAdvance(stbtt_fontinfo* info, int ch1, int ch2)

an additional amount to add to the 'advance' value between ch1 and ch2 @TODO; for now always returns 0!

stbtt_GetCodepointShape
int stbtt_GetCodepointShape(stbtt_fontinfo* info, int unicode_codepoint, stbtt_vertex** vertices)
stbtt_GetFontBoundingBox
void stbtt_GetFontBoundingBox(stbtt_fontinfo* info, int* x0, int* y0, int* x1, int* y1)

the bounding box around all possible characters

stbtt_GetFontOffsetForIndex
int stbtt_GetFontOffsetForIndex(const(ubyte)* font_collection, int index)

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.

stbtt_GetFontVMetrics
void stbtt_GetFontVMetrics(stbtt_fontinfo* info, int* ascent, int* descent, int* lineGap)

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

stbtt_GetGlyphBitmapBox
void stbtt_GetGlyphBitmapBox(stbtt_fontinfo* font, int glyph, float scale_x, float scale_y, int* ix0, int* iy0, int* ix1, int* iy1)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_GetGlyphBitmapBoxSubpixel
void stbtt_GetGlyphBitmapBoxSubpixel(stbtt_fontinfo* font, int glyph, float scale_x, float scale_y, float shift_x, float shift_y, int* ix0, int* iy0, int* ix1, int* iy1)

///////////////////////////////////////////////////////////////////////////

stbtt_GetGlyphBox
int stbtt_GetGlyphBox(stbtt_fontinfo* info, int glyph_index, int* x0, int* y0, int* x1, int* y1)

As above, but takes one or more glyph indices for greater efficiency

stbtt_GetGlyphHMetrics
void stbtt_GetGlyphHMetrics(stbtt_fontinfo* info, int glyph_index, int* advanceWidth, int* leftSideBearing)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_GetGlyphKernAdvance
int stbtt_GetGlyphKernAdvance(const(stbtt_fontinfo)* info, int glyph1, int glyph2)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_GetGlyphShape
int stbtt_GetGlyphShape(stbtt_fontinfo* info, int glyph_index, stbtt_vertex** pvertices)
stbtt_InitFont
int stbtt_InitFont(stbtt_fontinfo* info, const(ubyte)* data2, int fontstart)

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.

stbtt_IsGlyphEmpty
int stbtt_IsGlyphEmpty(stbtt_fontinfo* info, int glyph_index)
stbtt_MakeCodepointBitmapSubpixel
void stbtt_MakeCodepointBitmapSubpixel(stbtt_fontinfo* info, ubyte* output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)

Same as stbtt_MakeCodepointBitmap, but you can specify a subpixel shift for the character.

stbtt_MakeGlyphBitmap
void stbtt_MakeGlyphBitmap(stbtt_fontinfo* info, ubyte* output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_MakeGlyphBitmapSubpixel
void stbtt_MakeGlyphBitmapSubpixel(stbtt_fontinfo* info, ubyte* output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_Rasterize
void stbtt_Rasterize(stbtt_fontinfo* info, stbtt__bitmap* result, float flatness_in_pixels, stbtt_vertex* vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_ScaleForMappingEmToPixels
float stbtt_ScaleForMappingEmToPixels(stbtt_fontinfo* info, float pixels)

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.

stbtt_ScaleForPixelHeight
float stbtt_ScaleForPixelHeight(stbtt_fontinfo* info, float height)

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.

stbtt__GetGlyfOffset
int stbtt__GetGlyfOffset(stbtt_fontinfo* info, int glyph_index)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__add_point
void stbtt__add_point(stbtt__point* points, int n, float x, float y)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__close_shape
int stbtt__close_shape(stbtt_vertex* vertices, int num_vertices, int was_off, int start_off, int sx, int sy, int scx, int scy, int cx, int cy)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__fill_active_edges
void stbtt__fill_active_edges(ubyte* scanline, int len, stbtt__active_edge* e, int max_weight)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__find_table
uint stbtt__find_table(const(ubyte)* data, uint fontstart, string tag)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__isfont
bool stbtt__isfont(const(ubyte)* font)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__rasterize
void stbtt__rasterize(stbtt_fontinfo* info, stbtt__bitmap* result, stbtt__point* pts, int* wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__rasterize_sorted_edges
void stbtt__rasterize_sorted_edges(stbtt__bitmap* result, stbtt__edge* e, int n, int vsubsample, int off_x, int off_y)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt__tesselate_curve
int stbtt__tesselate_curve(stbtt__point* points, int* num_points, double x0, double y0, double x1, double y1, double x2, double y2, double objspace_flatness_squared, int n)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_setvertex
void stbtt_setvertex(stbtt_vertex* v, ubyte type, int x, int y, int cx, int cy)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_tag
bool stbtt_tag(const(ubyte)* p, string s)
Undocumented in source. Be warned that the author may not have intended to support it.
stbtt_tag4
bool stbtt_tag4(const(ubyte)* p, ubyte c0, ubyte c1, ubyte c2, ubyte c3)
Undocumented in source. Be warned that the author may not have intended to support it.
ttBYTE
ubyte ttBYTE(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.
ttCHAR
byte ttCHAR(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.
ttFixed
int ttFixed(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.
ttLONG
int ttLONG(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.
ttSHORT
short ttSHORT(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.
ttULONG
uint ttULONG(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.
ttUSHORT
ushort ttUSHORT(const(ubyte)* p)
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

FIX
enum FIX;
Undocumented in source.
FIXMASK
enum FIXMASK;
Undocumented in source.
FIXSHIFT
enum FIXSHIFT;
Undocumented in source.
STBTT_MS_EID_SHIFTJIS
enum STBTT_MS_EID_SHIFTJIS;
Undocumented in source.
STBTT_MS_EID_SYMBOL
enum STBTT_MS_EID_SYMBOL;
Undocumented in source.
STBTT_MS_EID_UNICODE_BMP
enum STBTT_MS_EID_UNICODE_BMP;
Undocumented in source.
STBTT_MS_EID_UNICODE_FULL
enum STBTT_MS_EID_UNICODE_FULL;
Undocumented in source.
STBTT_PLATFORM_ID_ISO
enum STBTT_PLATFORM_ID_ISO;
Undocumented in source.
STBTT_PLATFORM_ID_MAC
enum STBTT_PLATFORM_ID_MAC;
Undocumented in source.
STBTT_PLATFORM_ID_MICROSOFT
enum STBTT_PLATFORM_ID_MICROSOFT;
Undocumented in source.
STBTT_PLATFORM_ID_UNICODE
enum STBTT_PLATFORM_ID_UNICODE;
Undocumented in source.
STBTT_vcurve
enum STBTT_vcurve;
Undocumented in source.
STBTT_vline
enum STBTT_vline;
Undocumented in source.
STBTT_vmove
enum STBTT_vmove;
Undocumented in source.

Structs

stbtt__active_edge
struct stbtt__active_edge
Undocumented in source.
stbtt__bitmap
struct stbtt__bitmap
Undocumented in source.
stbtt__edge
struct stbtt__edge
Undocumented in source.
stbtt__point
struct stbtt__point
Undocumented in source.
stbtt_fontinfo
struct stbtt_fontinfo

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.

stbtt_vertex
struct stbtt_vertex
Undocumented in source.

Meta