package vendor:stb/truetype

⌘K
Ctrl+K
or
/

    Overview

    Bindings for stb_truetype.h.

    Index

    Constants (48)
    Variables (0)

    This section is empty.

    Procedures (60)
    Procedure Groups (0)

    This section is empty.

    Types

    PLATFORM_ID ¶

    PLATFORM_ID :: enum i32 {
    	// platformID
    	PLATFORM_ID_UNICODE   = 0, 
    	PLATFORM_ID_MAC       = 1, 
    	PLATFORM_ID_ISO       = 2, 
    	PLATFORM_ID_MICROSOFT = 3, 
    }

    aligned_quad ¶

    aligned_quad :: struct {
    	x0: f32,
    	y0: f32,
    	s0: f32,
    	t0: f32,
    	x1: f32,
    	y1: f32,
    	s1: f32,
    	t1: f32,
    }

    Related Procedures With Parameters

    bakedchar ¶

    bakedchar :: struct {
    	x0:       u16,
    	y0:       u16,
    	x1:       u16,
    	y1:       u16,
    	// coordinates of bbox in bitmap
    	xoff:     f32,
    	yoff:     f32,
    	xadvance: f32,
    }

    Related Procedures With Parameters

    kerningentry ¶

    kerningentry :: struct {
    	glyph1:  rune,
    	// use FindGlyphIndex
    	glyph2:  rune,
    	advance: i32,
    }

    pack_context ¶

    pack_context :: struct {
    	user_allocator_context: rawptr,
    	pack_info:              rawptr,
    	width:                  i32,
    	height:                 i32,
    	stride_in_bytes:        i32,
    	padding:                i32,
    	skip_missing:           b32,
    	h_oversample:           u32,
    	v_oversample:           u32,
    	pixels:                 [^]u8,
    	nodes:                  rawptr,
    }

    Related Procedures With Parameters

    pack_range ¶

    pack_range :: struct {
    	font_size:                        f32,
    	first_unicode_codepoint_in_range: i32,
    	array_of_unicode_codepoints:      [^]rune,
    	num_chars:                        i32,
    	chardata_for_range:               [^]packedchar,
    	_:                                u8,
    	_:                                u8,
    }

    Related Procedures With Parameters

    packedchar ¶

    packedchar :: struct {
    	x0:       u16,
    	y0:       u16,
    	x1:       u16,
    	y1:       u16,
    	xoff:     f32,
    	yoff:     f32,
    	xadvance: f32,
    	xoff2:    f32,
    	yoff2:    f32,
    }

    Related Procedures With Parameters

    vertex ¶

    vertex :: struct {
    	x:       vertex_type,
    	y:       vertex_type,
    	cx:      vertex_type,
    	cy:      vertex_type,
    	cx1:     vertex_type,
    	cy1:     vertex_type,
    	type:    u8,
    	padding: u8,
    }

    Related Procedures With Parameters

    vertex_type ¶

    vertex_type :: distinct i16
     

    can't use stbtt_int16 because that's not visible in the header file

    vmove ¶

    vmove :: enum i32 {
    	none, 
    	vmove  = 1, 
    	vline, 
    	vcurve, 
    	vcubic, 
    }

    Constants

    MACSTYLE_NONE ¶

    MACSTYLE_NONE :: 8
     

    <= not same as 0, this makes us check the bitfield is 0

    MAC_EID_ARABIC ¶

    MAC_EID_ARABIC :: 4
     

    encodingID for PLATFORM_ID_MAC; same as Script Manager codes

    MAC_EID_ROMAN ¶

    MAC_EID_ROMAN :: 0
     

    encodingID for PLATFORM_ID_MAC; same as Script Manager codes

    MAC_LANG_ENGLISH ¶

    MAC_LANG_ENGLISH :: 0
     

    languageID for PLATFORM_ID_MAC

    MAC_LANG_JAPANESE ¶

    MAC_LANG_JAPANESE :: 11
     

    languageID for PLATFORM_ID_MAC

    MS_EID_SYMBOL ¶

    MS_EID_SYMBOL :: 0
     

    encodingID for PLATFORM_ID_MICROSOFT

    MS_LANG_ENGLISH ¶

    MS_LANG_ENGLISH :: 0x0409
     

    languageID for PLATFORM_ID_MICROSOFT; same as LCID... problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs

    MS_LANG_ITALIAN ¶

    MS_LANG_ITALIAN :: 0x0410
     

    languageID for PLATFORM_ID_MICROSOFT; same as LCID... problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs

    UNICODE_EID_UNICODE_1_0 ¶

    UNICODE_EID_UNICODE_1_0 :: 0
     

    encodingID for PLATFORM_ID_UNICODE

    Variables

    This section is empty.

    Procedures

    BakeFontBitmap ¶
    C · stbtt_BakeFontBitmapSource · stb_truetype.odin:66

    BakeFontBitmap :: proc "c" (
    	data:                  [^]u8, 
    	offset:                i32, 
    	pixel_height:          f32, 
    	pixels:                [^]u8, 
    	pw, ph:                i32, 
    	first_char, num_chars: i32, 
    	chardata:              [^]bakedchar, 
    ) -> i32 ---
     

    if return is positive, the first unused row of the bitmap if return is negative, returns the negative of the number of characters that fit if return is 0, no characters fit and no rows were used This uses a very crappy packing.

    CompareUTF8toUTF16_bigendian ¶
    C · stbtt_CompareUTF8toUTF16_bigendianSource · stb_truetype.odin:575

    CompareUTF8toUTF16_bigendian :: proc "c" (
    	s1:   cstring, 
    	len1: i32, 
    	s2:   cstring, 
    	len2: i32, 
    ) -> i32 ---
     

    returns 1/0 whether the first string interpreted as utf8 is identical to the second string interpreted as big-endian utf16... useful for strings from next func

    FindGlyphIndex ¶
    C · stbtt_FindGlyphIndexSource · stb_truetype.odin:277

    FindGlyphIndex :: proc "c" (info: ^fontinfo, unicode_codepoint: rune) -> i32 ---
     

    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. Returns 0 if the character codepoint is not defined in the font.

    FindMatchingFont ¶
    C · stbtt_FindMatchingFontSource · stb_truetype.odin:571

    FindMatchingFont :: proc "c" (fontdata: [^]u8, name: cstring, flags: i32) -> i32 ---
     

    returns the offset (not index) of the font that matches, or -1 if none if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". if you use any other flag, use a font name like "Arial"; this checks the 'macStyle' header field; i don't know if fonts set this consistently

    FindSVGDoc ¶
    C · stbtt_FindSVGDocSource · stb_truetype.odin:392

    FindSVGDoc :: proc "c" (info: ^fontinfo, gl: b32) -> [^]u8 ---
     

    fills svg with the character's SVG data. returns data size or 0 if SVG not found.

    FreeBitmap ¶
    C · stbtt_FreeBitmapSource · stb_truetype.odin:411

    FreeBitmap :: proc "c" (bitmap: [^]u8, userdata: rawptr) ---
     

    frees the bitmap allocated below

    FreeSDF ¶

    FreeSDF :: proc "c" (bitmap: [^]u8, userdata: rawptr) ---
     

    frees the SDF bitmap allocated below

    FreeShape ¶

    FreeShape :: proc "c" (info: ^fontinfo, vertices: [^]vertex) ---
     

    frees the data allocated above

    GetBakedQuad ¶
    C · stbtt_GetBakedQuadSource · stb_truetype.odin:82

    GetBakedQuad :: proc "c" (
    	chardata:        ^bakedchar, 
    	pw, ph:          i32, 
    	char_index:      i32, 
    	xpos, ypos:      ^f32, 
    	q:               ^aligned_quad, 
    	opengl_fillrule: b32, 
    ) ---
     

    Call GetBakedQuad with char_index = 'character - first_char', and it creates the quad you need to draw and advances the current position.

    The coordinate system used assumes y increases downwards.

    Characters will extend both above and below the current position; see discussion of "BASELINE" above.

    It's inefficient; you might want to c&p it and optimize it.

    GetCodepointBitmap ¶
    C · stbtt_GetCodepointBitmapSource · stb_truetype.odin:420

    GetCodepointBitmap :: proc "c" (
    	info:                ^fontinfo, 
    	scale_x, scale_y:    f32, 
    	codepoint:           rune, 
    	width, height, xoff, 
    	yoff:                ^i32, 
    ) -> [^]u8 ---
     

    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.

    xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap

    GetCodepointBitmapBox ¶
    C · stbtt_GetCodepointBitmapBoxSource · stb_truetype.odin:445

    GetCodepointBitmapBox :: proc "c" (
    	font:             ^fontinfo, 
    	codepoint:        rune, 
    	scale_x, scale_y: f32, 
    	ix0, iy0, ix1, 
    	iy1:              ^i32, 
    ) ---
     

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

    GetCodepointBitmapBoxSubpixel ¶
    C · stbtt_GetCodepointBitmapBoxSubpixelSource · stb_truetype.odin:449

    GetCodepointBitmapBoxSubpixel :: proc "c" (
    	font:                               ^fontinfo, 
    	codepoint:                          rune, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	ix0, iy0, ix1, 
    	iy1:                                ^i32, 
    ) ---
     

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

    GetCodepointBitmapSubpixel ¶
    C · stbtt_GetCodepointBitmapSubpixelSource · stb_truetype.odin:424

    GetCodepointBitmapSubpixel :: proc "c" (
    	info:                               ^fontinfo, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	codepoint:                          rune, 
    	width, height, xoff, 
    	yoff:                               ^i32, 
    ) -> [^]u8 ---
     

    the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel shift for the character

    GetCodepointBox ¶
    C · stbtt_GetCodepointBoxSource · stb_truetype.odin:326

    GetCodepointBox :: proc "c" (
    	info:       ^fontinfo, 
    	codepoint:  rune, 
    	x0, y0, x1, 
    	y1:         ^i32, 
    ) -> i32 ---
     

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

    GetCodepointHMetrics ¶
    C · stbtt_GetCodepointHMetricsSource · stb_truetype.odin:320

    GetCodepointHMetrics :: proc "c" (
    	info:            ^fontinfo, 
    	codepoint:       rune, 
    	advanceWidth, 
    	leftSideBearing: ^i32, 
    ) ---
     

    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

    GetCodepointKernAdvance ¶
    C · stbtt_GetCodepointKernAdvanceSource · stb_truetype.odin:323

    GetCodepointKernAdvance :: proc "c" (info: ^fontinfo, ch1, ch2: rune) -> (advance: i32) ---
     

    an additional amount to add to the 'advance' value between ch1 and ch2

    GetCodepointSDF ¶
    C · stbtt_GetCodepointSDFSource · stb_truetype.odin:533

    GetCodepointSDF :: proc "c" (
    	info:                ^fontinfo, 
    	scale:               f32, 
    	codepoint, padding:  i32, 
    	onedge_value:        u8, 
    	pixel_dist_scale:    f32, 
    	width, height, xoff, 
    	yoff:                ^i32, 
    ) -> [^]u8 ---

    GetCodepointSVG ¶
    C · stbtt_GetCodepointSVGSource · stb_truetype.odin:393

    GetCodepointSVG :: proc "c" (info: ^fontinfo, unicode_codepoint: rune, svg: ^cstring) -> i32 ---

    GetCodepointShape ¶
    C · stbtt_GetCodepointShapeSource · stb_truetype.odin:384

    GetCodepointShape :: proc "c" (
    	info:              ^fontinfo, 
    	unicode_codepoint: rune, 
    	vertices:          ^[^]vertex, 
    ) -> i32 ---
     

    returns # of vertices and fills *vertices with the pointer to them these are expressed in "unscaled" coordinates

    The shape is a series of contours. Each one starts with a STBTT_moveto, then consists of a series of mixed STBTT_lineto and STBTT_curveto segments. A lineto draws a line from previous endpoint to its x,y; a curveto draws a quadratic bezier from previous endpoint to its x,y, using cx,cy as the bezier control point.

    GetFontBoundingBox ¶
    C · stbtt_GetFontBoundingBoxSource · stb_truetype.odin:315

    GetFontBoundingBox :: proc "c" (info: ^fontinfo, x0, y0, x1, y1: ^i32) ---
     

    the bounding box around all possible characters

    GetFontNameString ¶
    C · stbtt_GetFontNameStringSource · stb_truetype.odin:583

    GetFontNameString :: proc "c" (
    	font:                   ^fontinfo, 
    	length:                 ^i32, 
    	platformID:             PLATFORM_ID, 
    	encodingID, languageID, 
    	nameID:                 i32, 
    ) -> cstring ---
     

    returns the string (which may be big-endian double byte, e.g. for unicode) and puts the length in bytes in *length.

    some of the values for the IDs are below; for more see the truetype spec: http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html http://www.microsoft.com/typography/otspec/name.htm

    GetFontOffsetForIndex ¶
    C · stbtt_GetFontOffsetForIndexSource · stb_truetype.odin:263

    GetFontOffsetForIndex :: proc "c" (data: [^]u8, index: i32) -> i32 ---
     

    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.

    GetFontVMetrics ¶
    C · stbtt_GetFontVMetricsSource · stb_truetype.odin:306

    GetFontVMetrics :: proc "c" (info: ^fontinfo, ascent, descent, lineGap: ^i32) ---
     

    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

    GetFontVMetricsOS2 ¶
    C · stbtt_GetFontVMetricsOS2Source · stb_truetype.odin:312

    GetFontVMetricsOS2 :: proc "c" (
    	info:                    ^fontinfo, 
    	typoAscent, typoDescent, 
    	typoLineGap:             ^i32, 
    ) -> b32 ---
     

    analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 table (specific to MS/Windows TTF files).

    Returns 1 on success (table present), 0 on failure.

    GetGlyphBitmap ¶
    C · stbtt_GetGlyphBitmapSource · stb_truetype.odin:453

    GetGlyphBitmap :: proc "c" (
    	info:                ^fontinfo, 
    	scale_x, scale_y:    f32, 
    	glyph:               i32, 
    	width, height, xoff, 
    	yoff:                ^i32, 
    ) -> [^]u8 ---
     

    the following functions are equivalent to the above functions, but operate on glyph indices instead of Unicode codepoints (for efficiency)

    GetGlyphBitmapBox ¶
    C · stbtt_GetGlyphBitmapBoxSource · stb_truetype.odin:458

    GetGlyphBitmapBox :: proc "c" (
    	font:             ^fontinfo, 
    	glyph:            i32, 
    	scale_x, scale_y: f32, 
    	ix0, iy0, ix1, 
    	iy1:              ^i32, 
    ) ---

    GetGlyphBitmapBoxSubpixel ¶
    C · stbtt_GetGlyphBitmapBoxSubpixelSource · stb_truetype.odin:459

    GetGlyphBitmapBoxSubpixel :: proc "c" (
    	font:                               ^fontinfo, 
    	glyph:                              i32, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	ix0, iy0, ix1, 
    	iy1:                                ^i32, 
    ) ---

    GetGlyphBitmapSubpixel ¶
    C · stbtt_GetGlyphBitmapSubpixelSource · stb_truetype.odin:454

    GetGlyphBitmapSubpixel :: proc "c" (
    	info:                               ^fontinfo, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	glyph:                              i32, 
    	width, height, xoff, 
    	yoff:                               ^i32, 
    ) -> [^]u8 ---

    GetGlyphBox ¶
    C · stbtt_GetGlyphBoxSource · stb_truetype.odin:331

    GetGlyphBox :: proc "c" (
    	info:        ^fontinfo, 
    	glyph_index: i32, 
    	x0, y0, x1, 
    	y1:          ^i32, 
    ) -> i32 ---

    GetGlyphHMetrics ¶
    C · stbtt_GetGlyphHMetricsSource · stb_truetype.odin:329

    GetGlyphHMetrics :: proc "c" (
    	info:            ^fontinfo, 
    	glyph_index:     i32, 
    	advanceWidth, 
    	leftSideBearing: ^i32, 
    ) ---
     

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

    GetGlyphKernAdvance ¶
    C · stbtt_GetGlyphKernAdvanceSource · stb_truetype.odin:330

    GetGlyphKernAdvance :: proc "c" (info: ^fontinfo, glyph1, glyph2: i32) -> i32 ---

    GetGlyphSDF ¶
    C · stbtt_GetGlyphSDFSource · stb_truetype.odin:532

    GetGlyphSDF :: proc "c" (
    	info:                ^fontinfo, 
    	scale:               f32, 
    	glyph, padding:      i32, 
    	onedge_value:        u8, 
    	pixel_dist_scale:    f32, 
    	width, height, xoff, 
    	yoff:                ^i32, 
    ) -> [^]u8 ---

    GetGlyphSVG ¶
    C · stbtt_GetGlyphSVGSource · stb_truetype.odin:394

    GetGlyphSVG :: proc "c" (info: ^fontinfo, gl: b32, svg: ^cstring) -> i32 ---

    GetGlyphShape ¶
    C · stbtt_GetGlyphShapeSource · stb_truetype.odin:385

    GetGlyphShape :: proc "c" (info: ^fontinfo, glyph_index: i32, vertices: ^[^]vertex) -> i32 ---

    GetKerningTable ¶
    C · stbtt_GetKerningTableSource · stb_truetype.odin:346

    GetKerningTable :: proc "c" (
    	info:         ^fontinfo, 
    	table:        [^]kerningentry, 
    	table_length: i32, 
    ) -> i32 ---

    GetKerningTableLength ¶
    C · stbtt_GetKerningTableLengthSource · stb_truetype.odin:345

    GetKerningTableLength :: proc "c" (info: ^fontinfo) -> i32 ---
     

    Retrieves a complete list of all of the kerning pairs provided by the font stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write. The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1)

    GetNumberOfFonts ¶
    C · stbtt_GetNumberOfFontsSource · stb_truetype.odin:256

    GetNumberOfFonts :: proc "c" (data: [^]u8) -> i32 ---
     

    This function will determine the number of fonts in a font file. TrueType collection (.ttc) files may contain multiple fonts, while TrueType font (.ttf) files only contain one font. The number of fonts can be used for indexing with the previous function where the index is between zero and one less than the total fonts. If an error occurs, -1 is returned.

    GetPackedQuad ¶
    C · stbtt_GetPackedQuadSource · stb_truetype.odin:192

    GetPackedQuad :: proc "c" (
    	chardata:         ^packedchar, 
    	pw, ph:           i32, 
    	char_index:       i32, 
    	xpos, ypos:       ^f32, 
    	q:                ^aligned_quad, 
    	align_to_integer: b32, 
    ) ---

    GetScaledFontVMetrics ¶
    C · stbtt_GetScaledFontVMetricsSource · stb_truetype.odin:90

    GetScaledFontVMetrics :: proc "c" (
    	fontdata:        [^]u8, 
    	index:           i32, 
    	size:            f32, 
    	ascent, descent, 
    	lineGap:         ^f32, 
    ) ---
     

    Query the font vertical metrics without having to create a font first.

    InitFont ¶

    InitFont :: proc "c" (info: ^fontinfo, data: [^]u8, offset: i32) -> b32 ---
     

    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.

    IsGlyphEmpty ¶
    C · stbtt_IsGlyphEmptySource · stb_truetype.odin:373

    IsGlyphEmpty :: proc "c" (info: ^fontinfo, glyph_index: i32) -> b32 ---
     

    returns true if nothing is drawn for this glyph

    MakeCodepointBitmap ¶
    C · stbtt_MakeCodepointBitmapSource · stb_truetype.odin:430

    MakeCodepointBitmap :: proc "c" (
    	info:                     ^fontinfo, 
    	output:                   [^]u8, 
    	out_w, out_h, out_stride: i32, 
    	scale_x, scale_y:         f32, 
    	codepoint:                rune, 
    ) ---
     

    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.

    MakeCodepointBitmapSubpixel ¶
    C · stbtt_MakeCodepointBitmapSubpixelSource · stb_truetype.odin:434

    MakeCodepointBitmapSubpixel :: proc "c" (
    	info:                               ^fontinfo, 
    	output:                             [^]u8, 
    	out_w, out_h, out_stride:           i32, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	codepoint:                          rune, 
    ) ---
     

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

    MakeCodepointBitmapSubpixelPrefilter ¶
    C · stbtt_MakeCodepointBitmapSubpixelPrefilterSource · stb_truetype.odin:438

    MakeCodepointBitmapSubpixelPrefilter :: proc "c" (
    	info:                               ^fontinfo, 
    	output:                             [^]u8, 
    	out_w, out_h, out_stride:           i32, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	oversample_x, oversample_y:         b32, 
    	sub_x, sub_y:                       ^f32, 
    	codepoint:                          rune, 
    ) ---
     

    same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering is performed (see stbtt_PackSetOversampling)

    MakeGlyphBitmap ¶
    C · stbtt_MakeGlyphBitmapSource · stb_truetype.odin:455

    MakeGlyphBitmap :: proc "c" (
    	info:                     ^fontinfo, 
    	output:                   [^]u8, 
    	out_w, out_h, out_stride: i32, 
    	scale_x, scale_y:         f32, 
    	glyph:                    i32, 
    ) ---

    MakeGlyphBitmapSubpixel ¶
    C · stbtt_MakeGlyphBitmapSubpixelSource · stb_truetype.odin:456

    MakeGlyphBitmapSubpixel :: proc "c" (
    	info:                               ^fontinfo, 
    	output:                             [^]u8, 
    	out_w, out_h, out_stride:           i32, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	glyph:                              i32, 
    ) ---

    MakeGlyphBitmapSubpixelPrefilter ¶
    C · stbtt_MakeGlyphBitmapSubpixelPrefilterSource · stb_truetype.odin:457

    MakeGlyphBitmapSubpixelPrefilter :: proc "c" (
    	info:                               ^fontinfo, 
    	output:                             [^]u8, 
    	out_w, out_h, out_stride:           i32, 
    	scale_x, scale_y, shift_x, shift_y: f32, 
    	oversample_x, oversample_y:         i32, 
    	sub_x, sub_y:                       ^f32, 
    	glyph:                              i32, 
    ) ---

    POINT_SIZE ¶

    POINT_SIZE :: proc(x: $T) -> T {…}
     

    @NOTE: this was a macro

    PackBegin ¶

    PackBegin :: proc "c" (
    	spc:                                     ^pack_context, 
    	pixels:                                  [^]u8, 
    	width, height, stride_in_bytes, padding: i32, 
    	alloc_context:                           rawptr, 
    ) -> b32 ---
     

    Initializes a packing context stored in the passed-in stbtt_pack_context. Future calls using this context will pack characters into the bitmap passed in here: a 1-channel bitmap that is width * height. stride_in_bytes is the distance from one row to the next (or 0 to mean they are packed tightly together). "padding" is the amount of padding to leave between each character (normally you want '1' for bitmaps you'll use as textures with bilinear filtering).

    Returns 0 on failure, 1 on success.

    PackEnd ¶

    PackEnd :: proc "c" (spc: ^pack_context) ---
     

    Cleans up the packing context and frees all memory.

    PackFontRange ¶
    C · stbtt_PackFontRangeSource · stb_truetype.odin:160

    PackFontRange :: proc "c" (
    	spc:                                             ^pack_context, 
    	fontdata:                                        [^]u8, 
    	font_index:                                      i32, 
    	font_size:                                       f32, 
    	first_unicode_char_in_range, num_chars_in_range: i32, 
    	chardata_for_range:                              [^]packedchar, 
    ) -> b32 ---
     

    Creates character bitmaps from the font_index'th font found in fontdata (use font_index=0 if you don't know what that is). It creates num_chars_in_range bitmaps for characters with unicode values starting at first_unicode_char_in_range and increasing. Data for how to render them is stored in chardata_for_range; pass these to stbtt_GetPackedQuad to get back renderable quads.

    font_size is the full height of the character from ascender to descender, as computed by stbtt_ScaleForPixelHeight. To use a point size as computed by stbtt_ScaleForMappingEmToPixels, wrap the point size in POINT_SIZE() and pass that result as 'font_size': ..., 20 , ... // font max minus min y is 20 pixels tall ..., POINT_SIZE(20), ... // 'M' is 20 pixels tall

    Returns 0 on failure, 1 on success.

    PackFontRanges ¶
    C · stbtt_PackFontRangesSource · stb_truetype.odin:168

    PackFontRanges :: proc "c" (
    	spc:        ^pack_context, 
    	fontdata:   [^]u8, 
    	font_index: i32, 
    	ranges:     [^]pack_range, 
    	num_ranges: i32, 
    ) -> b32 ---
     

    Creates character bitmaps from multiple ranges of characters stored in ranges. This will usually create a better-packed bitmap than multiple calls to stbtt_PackFontRange. Note that you can call this multiple times within a single PackBegin/PackEnd.

    Returns 0 on failure, 1 on success.

    PackFontRangesGatherRects ¶
    C · stbtt_PackFontRangesGatherRectsSource · stb_truetype.odin:211

    PackFontRangesGatherRects :: proc "c" (
    	spc:        ^pack_context, 
    	info:       ^fontinfo, 
    	ranges:     [^]pack_range, 
    	num_ranges: i32, 
    	rects:      [^]stb_rect_pack.Rect, 
    ) -> i32 ---
     

    Calling these functions in sequence is roughly equivalent to calling stbtt_PackFontRanges(). If you more control over the packing of multiple fonts, or if you want to pack custom data into a font texture, take a look at the source to of stbtt_PackFontRanges() and create a custom version using these functions, e.g. call GatherRects multiple times, building up a single array of rects, then call PackRects once, then call RenderIntoRects repeatedly. This may result in a better packing than calling PackFontRanges multiple times (or it may not).

    Returns the number of rects which were not skipped. PackSetSkipMissingCodepoints controls this behavior.

    PackFontRangesPackRects ¶
    C · stbtt_PackFontRangesPackRectsSource · stb_truetype.odin:212

    PackFontRangesPackRects :: proc "c" (
    	spc:       ^pack_context, 
    	rects:     [^]stb_rect_pack.Rect, 
    	num_rects: i32, 
    ) ---

    PackFontRangesRenderIntoRects ¶
    C · stbtt_PackFontRangesRenderIntoRectsSource · stb_truetype.odin:214

    PackFontRangesRenderIntoRects :: proc "c" (
    	spc:        ^pack_context, 
    	info:       ^fontinfo, 
    	ranges:     [^]pack_range, 
    	num_ranges: i32, 
    	rects:      [^]stb_rect_pack.Rect, 
    ) -> b32 ---
     

    Returns 0 on failure, 1 on success.

    PackSetOversampling ¶
    C · stbtt_PackSetOversamplingSource · stb_truetype.odin:184

    PackSetOversampling :: proc "c" (spc: ^pack_context, h_oversample, v_oversample: u32) ---
     

    Oversampling a font increases the quality by allowing higher-quality subpixel positioning, and is especially valuable at smaller text sizes.

    This function sets the amount of oversampling for all following calls to stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given pack context. The default (no oversampling) is achieved by h_oversample=1 and v_oversample=1. The total number of pixels required is h_oversample*v_oversample larger than the default; for example, 2x2 oversampling requires 4x the storage of 1x1. For best results, render oversampled textures with bilinear filtering. Look at the readme in stb/tests/oversample for information about oversampled fonts

    To use with PackFontRangesGather etc., you must set it before calls call to PackFontRangesGatherRects.

    PackSetSkipMissingCodepoints ¶
    C · stbtt_PackSetSkipMissingCodepointsSource · stb_truetype.odin:190

    PackSetSkipMissingCodepoints :: proc "c" (spc: ^pack_context, skip: b32) ---
     

    If skip != false, this tells stb_truetype to skip any codepoints for which there is no corresponding glyph. If skip=false, which is the default, then codepoints without a glyph recived the font's "missing character" glyph, typically an empty box by convention.

    Rasterize ¶

    Rasterize :: proc "c" (
    	result:             ^_bitmap, 
    	flatness_in_pixels: f32, 
    	vertices:           [^]vertex, 
    	num_verts:          i32, 
    	scale_x, scale_y:   f32, 
    	shift_x, shift_y:   f32, 
    	x_off, y_off:       i32, 
    	invert:             b32, 
    	userdata:           rawptr, 
    ) ---
     

    rasterize a shape with quadratic beziers into a bitmap

    ScaleForMappingEmToPixels ¶
    C · stbtt_ScaleForMappingEmToPixelsSource · stb_truetype.odin:298

    ScaleForMappingEmToPixels :: proc "c" (info: ^fontinfo, pixels: f32) -> f32 ---
     

    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.

    ScaleForPixelHeight ¶
    C · stbtt_ScaleForPixelHeightSource · stb_truetype.odin:293

    ScaleForPixelHeight :: proc "c" (info: ^fontinfo, pixels: f32) -> f32 ---
     

    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.

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2026-10 (vendor "odin") Windows_amd64 @ 2026-10-12 23:22:57.846843600 +0000 UTC