package vendor:stb/truetype

⌘K
Ctrl+K
or
/

    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, 
    }
    Related Procedures With Parameters

    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,
    }
    Related Procedures With Parameters

    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_BOLD ¶

    MACSTYLE_BOLD :: 1

    MACSTYLE_DONTCARE ¶

    MACSTYLE_DONTCARE :: 0

    MACSTYLE_ITALIC ¶

    MACSTYLE_ITALIC :: 2

    MACSTYLE_NONE ¶

    MACSTYLE_NONE :: 8
     

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

    MACSTYLE_UNDERSCORE ¶

    MACSTYLE_UNDERSCORE :: 4

    MAC_EID_ARABIC ¶

    MAC_EID_ARABIC :: 4
     

    encodingID for PLATFORM_ID_MAC; same as Script Manager codes

    MAC_EID_CHINESE_TRAD ¶

    MAC_EID_CHINESE_TRAD :: 2

    MAC_EID_GREEK ¶

    MAC_EID_GREEK :: 6

    MAC_EID_HEBREW ¶

    MAC_EID_HEBREW :: 5

    MAC_EID_JAPANESE ¶

    MAC_EID_JAPANESE :: 1

    MAC_EID_KOREAN ¶

    MAC_EID_KOREAN :: 3

    MAC_EID_ROMAN ¶

    MAC_EID_ROMAN :: 0
     

    encodingID for PLATFORM_ID_MAC; same as Script Manager codes

    MAC_EID_RUSSIAN ¶

    MAC_EID_RUSSIAN :: 7

    MAC_LANG_ARABIC ¶

    MAC_LANG_ARABIC :: 12

    MAC_LANG_CHINESE_SIMPLIFIED ¶

    MAC_LANG_CHINESE_SIMPLIFIED :: 33

    MAC_LANG_CHINESE_TRAD ¶

    MAC_LANG_CHINESE_TRAD :: 19

    MAC_LANG_DUTCH ¶

    MAC_LANG_DUTCH :: 4

    MAC_LANG_ENGLISH ¶

    MAC_LANG_ENGLISH :: 0
     

    languageID for PLATFORM_ID_MAC

    MAC_LANG_FRENCH ¶

    MAC_LANG_FRENCH :: 1

    MAC_LANG_GERMAN ¶

    MAC_LANG_GERMAN :: 2

    MAC_LANG_HEBREW ¶

    MAC_LANG_HEBREW :: 10

    MAC_LANG_ITALIAN ¶

    MAC_LANG_ITALIAN :: 3

    MAC_LANG_JAPANESE ¶

    MAC_LANG_JAPANESE :: 11
     

    languageID for PLATFORM_ID_MAC

    MAC_LANG_KOREAN ¶

    MAC_LANG_KOREAN :: 23

    MAC_LANG_RUSSIAN ¶

    MAC_LANG_RUSSIAN :: 32

    MAC_LANG_SPANISH ¶

    MAC_LANG_SPANISH :: 6

    MAC_LANG_SWEDISH ¶

    MAC_LANG_SWEDISH :: 5

    MS_EID_SHIFTJIS ¶

    MS_EID_SHIFTJIS :: 2

    MS_EID_SYMBOL ¶

    MS_EID_SYMBOL :: 0
     

    encodingID for PLATFORM_ID_MICROSOFT

    MS_EID_UNICODE_BMP ¶

    MS_EID_UNICODE_BMP :: 1

    MS_EID_UNICODE_FULL ¶

    MS_EID_UNICODE_FULL :: 10

    MS_LANG_CHINESE ¶

    MS_LANG_CHINESE :: 0x0804

    MS_LANG_DUTCH ¶

    MS_LANG_DUTCH :: 0x0413

    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_FRENCH ¶

    MS_LANG_FRENCH :: 0x040c

    MS_LANG_GERMAN ¶

    MS_LANG_GERMAN :: 0x0407

    MS_LANG_HEBREW ¶

    MS_LANG_HEBREW :: 0x040d

    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

    MS_LANG_JAPANESE ¶

    MS_LANG_JAPANESE :: 0x0411

    MS_LANG_KOREAN ¶

    MS_LANG_KOREAN :: 0x0412

    MS_LANG_RUSSIAN ¶

    MS_LANG_RUSSIAN :: 0x0419

    MS_LANG_SPANISH ¶

    MS_LANG_SPANISH :: 0x0409

    MS_LANG_SWEDISH ¶

    MS_LANG_SWEDISH :: 0x041D

    UNICODE_EID_ISO_10646 ¶

    UNICODE_EID_ISO_10646 :: 2

    UNICODE_EID_UNICODE_1_0 ¶

    UNICODE_EID_UNICODE_1_0 :: 0
     

    encodingID for PLATFORM_ID_UNICODE

    UNICODE_EID_UNICODE_1_1 ¶

    UNICODE_EID_UNICODE_1_1 :: 1

    UNICODE_EID_UNICODE_2_0_BMP ¶

    UNICODE_EID_UNICODE_2_0_BMP :: 3

    UNICODE_EID_UNICODE_2_0_FULL ¶

    UNICODE_EID_UNICODE_2_0_FULL :: 4

    Variables

    This section is empty.

    Procedures

    BakeFontBitmap ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

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

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

    GetCodepointSDF ¶

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

    GetCodepointSVG ¶

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

    GetCodepointShape ¶

    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 ¶

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

    the bounding box around all possible characters

    GetFontNameString ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

    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 ¶

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

    GetGlyphBitmapBoxSubpixel ¶

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

    GetGlyphBitmapSubpixel ¶

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

    GetGlyphBox ¶

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

    GetGlyphHMetrics ¶

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

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

    GetGlyphKernAdvance ¶

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

    GetGlyphSDF ¶

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

    GetGlyphSVG ¶

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

    GetGlyphShape ¶

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

    GetKerningTable ¶

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

    GetKerningTableLength ¶

    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 ¶

    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 ¶

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

    GetScaledFontVMetrics ¶

    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 ¶

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

    returns true if nothing is drawn for this glyph

    MakeCodepointBitmap ¶

    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 ¶

    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 ¶

    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 ¶

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

    MakeGlyphBitmapSubpixel ¶

    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 ¶

    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, 
    ) -> i32 ---
     

    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 ¶

    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, 
    ) -> i32 ---
     

    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

    PackFontRanges ¶

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

    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.

    PackFontRangesGatherRects ¶

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

    PackFontRangesPackRects ¶

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

    PackFontRangesRenderIntoRects ¶

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

    PackSetOversampling ¶

    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 ¶

    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 ¶

    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 ¶

    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-2024-12 (vendor "odin") Windows_amd64 @ 2024-12-20 21:10:47.878365600 +0000 UTC