package vendor:fontstash

⌘K
Ctrl+K
or
/

    Types

    AlignHorizontal ¶

    AlignHorizontal :: enum int {
    	LEFT, 
    	CENTER, 
    	RIGHT, 
    }
    Related Procedures With Parameters

    AlignVertical ¶

    AlignVertical :: enum int {
    	TOP, 
    	MIDDLE, 
    	BOTTOM, 
    	BASELINE, 
    }
    Related Procedures With Parameters

    AtlasNode ¶

    AtlasNode :: struct {
    	x:     i16,
    	y:     i16,
    	width: i16,
    }

    Font ¶

    Font :: struct {
    	name:           string,
    	// allocated
    	info:           stb_truetype.fontinfo,
    	loadedData:     []u8,
    	freeLoadedData: bool,
    	// in case you dont want loadedData to be removed
    	ascender:       f32,
    	descender:      f32,
    	lineHeight:     f32,
    	glyphs:         [dynamic]Glyph,
    	lut:            [256]int,
    	fallbacks:      [20]int,
    	nfallbacks:     int,
    }
    Related Procedures With Parameters

    FontContext ¶

    FontContext :: struct {
    	fonts:          [dynamic]Font,
    	// always assuming user wants to resize
    	nodes:          [dynamic]AtlasNode,
    	// actual pixels
    	textureData:    []u8,
    	// allocated using context.allocator
    	width:          int,
    	height:         int,
    	// 1 / texture_atlas_width, 1 / texture_atlas_height
    	itw:            f32,
    	ith:            f32,
    	// state 
    	states:         []State,
    	state_count:    int,
    	// used states
    	location:       QuadLocation,
    	// dirty rectangle of the texture region that was updated
    	dirtyRect:      [4]f32,
    	// callbacks with userData passed
    	userData:       rawptr,
    	// called when a texture is expanded and needs handling
    	callbackResize: proc(data: rawptr, w, h: int),
    	// called in state_end to update the texture region that changed
    	callbackUpdate: proc(data: rawptr, dirtyRect: [4]f32, textureData: rawptr),
    }
    Related Procedures With Parameters

    Glyph ¶

    Glyph :: struct {
    	codepoint: rune,
    	index:     i32,
    	next:      int,
    	isize:     i16,
    	blurSize:  i16,
    	x0:        i16,
    	y0:        i16,
    	x1:        i16,
    	y1:        i16,
    	xoff:      i16,
    	yoff:      i16,
    	xadvance:  i16,
    }

    Glyph_Index ¶

    Glyph_Index :: i32
     

    in case you want to change the handle for glyph indices

    Quad ¶

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

    quad that should be used to draw from the texture atlas

    Related Procedures With Parameters

    QuadLocation ¶

    QuadLocation :: enum int {
    	TOPLEFT, 
    	BOTTOMLEFT, 
    }
    Related Procedures With Parameters

    State ¶

    State :: struct {
    	font:    int,
    	size:    f32,
    	color:   [4]u8,
    	spacing: f32,
    	blur:    f32,
    	ah:      AlignHorizontal,
    	av:      AlignVertical,
    }
     

    state used to share font options

    TextIter ¶

    TextIter :: struct {
    	x:                  f32,
    	y:                  f32,
    	nextx:              f32,
    	nexty:              f32,
    	scale:              f32,
    	spacing:            f32,
    	isize:              i16,
    	iblur:              i16,
    	font:               ^Font,
    	previousGlyphIndex: i32,
    	// unicode iteration
    	utf8state:          rune,
    	// utf8
    	codepoint:          rune,
    	text:               string,
    	codepointCount:     int,
    	// byte indices
    	str:                int,
    	next:               int,
    	end:                int,
    }
     

    text iteration with custom settings

    Related Procedures With Parameters
    Related Procedures With Returns

    Vertex ¶

    Vertex :: struct #packed {
    	x:     f32,
    	y:     f32,
    	u:     f32,
    	v:     f32,
    	color: [4]u8,
    }

    Constants

    BLUR_APREC ¶

    BLUR_APREC :: 16

    BLUR_ZPREC ¶

    BLUR_ZPREC :: 7

    HASH_LUT_SIZE ¶

    HASH_LUT_SIZE :: 256

    INIT_ATLAS_NODES ¶

    INIT_ATLAS_NODES :: 256

    INIT_GLYPHS ¶

    INIT_GLYPHS :: 256

    INVALID ¶

    INVALID :: -1

    MAX_FALLBACKS ¶

    MAX_FALLBACKS :: 20

    MAX_STATES ¶

    MAX_STATES :: 20

    Variables

    This section is empty.

    Procedures

    AddFallbackFont ¶

    AddFallbackFont :: proc(ctx: ^FontContext, base, fallback: int) -> bool {…}

    AddFontMem ¶

    AddFontMem :: proc(ctx: ^FontContext, name: string, data: []u8, freeLoadedData: bool) -> int {…}
     

    push a font to the font stack optionally init with ascii characters at a wanted size

    AddFontPath ¶

    AddFontPath :: proc(ctx: ^FontContext, name: string, path: string) -> int {…}

    BeginState ¶

    BeginState :: proc(ctx: ^FontContext) {…}
     

    reset to single state

    ClearState ¶

    ClearState :: proc(ctx: ^FontContext) {…}
     

    clear current state

    CodepointWidth ¶

    CodepointWidth :: proc(font: ^Font, codepoint: rune, scale: f32) -> f32 {…}
     

    only useful for single glyphs where you quickly want the width

    Destroy ¶

    Destroy :: proc(ctx: ^FontContext) {…}

    EndState ¶

    EndState :: proc(ctx: ^FontContext) {…}
     

    checks for texture updates after potential __getGlyph calls

    ExpandAtlas ¶

    ExpandAtlas :: proc(ctx: ^FontContext, width, height: int, allocator := context.allocator) -> bool {…}

    GetFontByName ¶

    GetFontByName :: proc(ctx: ^FontContext, name: string) -> int {…}
     

    find font by name

    Init ¶

    Init :: proc(ctx: ^FontContext, w, h: int, loc: QuadLocation) {…}

    LineBounds ¶

    LineBounds :: proc(ctx: ^FontContext, y: f32) -> (miny, maxy: f32) {…}
     

    get top and bottom line boundary

    PopState ¶

    PopState :: proc(ctx: ^FontContext) {…}
     

    pop a state

    PushState ¶

    PushState :: proc(using ctx: ^FontContext, loc := #caller_location) {…}
     

    push a state, copies the current one over to the next one

    Reset ¶

    Reset :: proc(ctx: ^FontContext) {…}

    ResetAtlas ¶

    ResetAtlas :: proc(ctx: ^FontContext, width, height: int, allocator := context.allocator) -> bool {…}

    ResetFallbackFont ¶

    ResetFallbackFont :: proc(ctx: ^FontContext, base: int) {…}

    SetAlignHorizontal ¶

    SetAlignHorizontal :: proc(ctx: ^FontContext, ah: AlignHorizontal) {…}

    SetAlignVertical ¶

    SetAlignVertical :: proc(ctx: ^FontContext, av: AlignVertical) {…}

    SetBlur ¶

    SetBlur :: proc(ctx: ^FontContext, blur: f32) {…}

    SetColor ¶

    SetColor :: proc(ctx: ^FontContext, color: [4]u8) {…}

    SetFont ¶

    SetFont :: proc(ctx: ^FontContext, font: int) {…}

    SetSize ¶

    SetSize :: proc(ctx: ^FontContext, size: f32) {…}

    SetSpacing ¶

    SetSpacing :: proc(ctx: ^FontContext, spacing: f32) {…}

    TextBounds ¶

    TextBounds :: proc(ctx: ^FontContext, text: string, x: f32 = 0, y: f32 = 0, bounds: ^[4]f32 = nil) -> f32 {…}
     

    width of a text line, optionally the full rect

    TextIterInit ¶

    TextIterInit :: proc(ctx: ^FontContext, x: f32, y: f32, text: string) -> (res: TextIter) {…}
     

    init text iter struct with settings

    TextIterNext ¶

    TextIterNext :: proc(ctx: ^FontContext, iter: ^TextIter, quad: ^Quad) -> (ok: bool) {…}
     

    step through each codepoint

    ValidateTexture ¶

    ValidateTexture :: proc(using ctx: ^FontContext, dirty: ^[4]f32) -> bool {…}
     

    true when the dirty rectangle is valid and needs a texture update on the gpu

    VerticalMetrics ¶

    VerticalMetrics :: proc(ctx: ^FontContext) -> (ascender, descender, lineHeight: f32) {…}

    Procedure Groups

    Source Files

    Generation Information

    Generated with odin version dev-2024-11 (vendor "odin") Windows_amd64 @ 2024-11-20 21:11:52.062084700 +0000 UTC