vendors.stb_truetype

Native Chic font parsing, glyph metrics, outlines, rasterization, and atlas packing based on stb_truetype.

21 structs · 58 functions · Public API

Structs

stbtt_bakedchar

struct
stbtt_bakedchar : struct {
    x0 : u16
    y0 : u16
    x1 : u16
    y1 : u16
    xoff : f32
    yoff : f32
    xadvance : f32
}
Ported from stb_truetype 1.26 by Sean Barrett and contributors.
See LICENSE. This is native Chic source; no stb C archive is used.

stbtt_aligned_quad

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

stbtt_packedchar

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

stbtt_pack_range

struct
stbtt_pack_range : struct {
    font_size : f32
    first_unicode_codepoint_in_range : i32
    array_of_unicode_codepoints : ^i32
    num_chars : i32
    chardata_for_range : ^stbtt_packedchar
    h_oversample : u8
    v_oversample : u8
}

stbtt_pack_context

struct
stbtt_pack_context : struct {
    user_allocator_context : ^void
    pack_info : ^void
    width : i32
    height : i32
    stride_in_bytes : i32
    padding : i32
    skip_missing : i32
    h_oversample : u32
    v_oversample : u32
    pixels : ^u8
    nodes : ^void
}

stbrp_context

struct
stbrp_context : struct {
    width : i32
    height : i32
    x : i32
    y : i32
    bottom_y : i32
}

stbrp_node

struct
stbrp_node : struct {
    x : u8
}

stbrp_rect

struct
stbrp_rect : struct {
    x : i32
    y : i32
    id : i32
    w : i32
    h : i32
    was_packed : i32
}

StbTrueTypeFaceMetrics

struct
StbTrueTypeFaceMetrics : struct {
    units_per_em : i32
    ascent : i32
    descent : i32
    line_gap : i32
    max_advance : i32
    glyph_count : i32
}
Public entry points used by core.imgui. Input bytes remain caller-owned.
Font data must be trusted, as with the original stb parser.

StbTrueTypeGlyphMetrics

struct
StbTrueTypeGlyphMetrics : struct {
    glyph_index : i32
    has_glyph : i32
    advance_width : i32
    left_side_bearing : i32
    bitmap_width : i32
    bitmap_height : i32
    bitmap_x_offset : i32
    bitmap_y_offset : i32
}

stbtt_fontinfo

struct
stbtt_fontinfo : struct {
    userdata : ^void
    data : ^u8
    fontstart : i32
    numGlyphs : i32
    loca : i32
    head : i32
    glyf : i32
    hhea : i32
    hmtx : i32
    kern : i32
    gpos : i32
    svg : i32
    index_map : i32
    indexToLocFormat : i32
    cff : stbtt__buf
    charstrings : stbtt__buf
    gsubrs : stbtt__buf
    subrs : stbtt__buf
    fontdicts : stbtt__buf
    fdselect : stbtt__buf
}
Ported from stb_truetype 1.26 by Sean Barrett and contributors.
See LICENSE. This is native Chic source; no stb C archive is used.

stbtt__hheap

struct
stbtt__hheap : struct {
    head : ^stbtt__hheap_chunk
    first_free : ^void
    num_remaining_in_head_chunk : i32
}

stbtt__edge

struct
stbtt__edge : struct {
    x0 : f32
    y0 : f32
    x1 : f32
    y1 : f32
    invert : i32
}

stbtt__active_edge

struct
stbtt__active_edge : struct {
    next : ^stbtt__active_edge
    fx : f32
    fdx : f32
    fdy : f32
    direction : f32
    sy : f32
    ey : f32
}

stbtt__buf

struct
stbtt__buf : struct {
    data : ^u8
    cursor : i32
    size : i32
}

stbtt_vertex

struct
stbtt_vertex : struct {
    x : i16
    y : i16
    cx : i16
    cy : i16
    cx1 : i16
    cy1 : i16
    c_type : u8
    padding : u8
}

stbtt__bitmap

struct
stbtt__bitmap : struct {
    w : i32
    h : i32
    stride : i32
    pixels : ^u8
}

stbtt__csctx

struct
stbtt__csctx : struct {
    bounds : i32
    started : i32
    first_x : f32
    first_y : f32
    x : f32
    y : f32
    min_x : i32
    max_x : i32
    min_y : i32
    max_y : i32
    pvertices : ^stbtt_vertex
    num_vertices : i32
}

stbtt__point

struct
stbtt__point : struct {
    x : f32
    y : f32
}

stbtt_kerningentry

struct
stbtt_kerningentry : struct {
    glyph1 : i32
    glyph2 : i32
    advance : i32
}

Functions

stbtt_GetCodepointShape

func
stbtt_GetCodepointShape : func(info : ^stbtt_fontinfo, unicode_codepoint : i32, vertices : ^^stbtt_vertex) -> i32

stbtt_GetCodepointBox

func
stbtt_GetCodepointBox : func(info : ^stbtt_fontinfo, codepoint : i32, x0 : ^i32, y0 : ^i32, x1 : ^i32, y1 : ^i32) -> i32

stbtt_IsGlyphEmpty

func
stbtt_IsGlyphEmpty : func(info : ^stbtt_fontinfo, glyph_index : i32) -> i32

stbtt_GetKerningTable

func
stbtt_GetKerningTable : func(info : ^stbtt_fontinfo, table : ^stbtt_kerningentry, table_length : i32) -> i32

stbtt_GetCodepointHMetrics

func
stbtt_GetCodepointHMetrics : func(info : ^stbtt_fontinfo, codepoint : i32, advanceWidth : ^i32, leftSideBearing : ^i32)

stbtt_GetFontVMetricsOS2

func
stbtt_GetFontVMetricsOS2 : func(info : ^stbtt_fontinfo, typoAscent : ^i32, typoDescent : ^i32, typoLineGap : ^i32) -> i32

stbtt_GetFontBoundingBox

func
stbtt_GetFontBoundingBox : func(info : ^stbtt_fontinfo, x0 : ^i32, y0 : ^i32, x1 : ^i32, y1 : ^i32)

stbtt_FreeShape

func
stbtt_FreeShape : func(info : ^stbtt_fontinfo, v : ^stbtt_vertex)

stbtt_GetCodepointBitmapBoxSubpixel

func
stbtt_GetCodepointBitmapBoxSubpixel : func(font : ^stbtt_fontinfo, codepoint : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, ix0 : ^i32, iy0 : ^i32, ix1 : ^i32, iy1 : ^i32)

stbtt_GetCodepointBitmapBox

func
stbtt_GetCodepointBitmapBox : func(font : ^stbtt_fontinfo, codepoint : i32, scale_x : f32, scale_y : f32, ix0 : ^i32, iy0 : ^i32, ix1 : ^i32, iy1 : ^i32)

stbtt_GetGlyphBitmapSubpixel

func
stbtt_GetGlyphBitmapSubpixel : func(info : ^stbtt_fontinfo, scale_x_arg : f32, scale_y_arg : f32, shift_x : f32, shift_y : f32, glyph : i32, width : ^i32, height : ^i32, xoff : ^i32, yoff : ^i32) -> ^u8

stbtt_GetGlyphBitmap

func
stbtt_GetGlyphBitmap : func(info : ^stbtt_fontinfo, scale_x : f32, scale_y : f32, glyph : i32, width : ^i32, height : ^i32, xoff : ^i32, yoff : ^i32) -> ^u8

stbtt_GetCodepointBitmapSubpixel

func
stbtt_GetCodepointBitmapSubpixel : func(info : ^stbtt_fontinfo, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, codepoint : i32, width : ^i32, height : ^i32, xoff : ^i32, yoff : ^i32) -> ^u8

stbtt_MakeCodepointBitmapSubpixel

func
stbtt_MakeCodepointBitmapSubpixel : func(info : ^stbtt_fontinfo, output : ^u8, out_w : i32, out_h : i32, out_stride : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, codepoint : i32)

stbtt_GetCodepointBitmap

func
stbtt_GetCodepointBitmap : func(info : ^stbtt_fontinfo, scale_x : f32, scale_y : f32, codepoint : i32, width : ^i32, height : ^i32, xoff : ^i32, yoff : ^i32) -> ^u8

stbtt_MakeCodepointBitmap

func
stbtt_MakeCodepointBitmap : func(info : ^stbtt_fontinfo, output : ^u8, out_w : i32, out_h : i32, out_stride : i32, scale_x : f32, scale_y : f32, codepoint : i32)

stbtt_GetScaledFontVMetrics

func
stbtt_GetScaledFontVMetrics : func(fontdata : ^u8, index : i32, size : f32, ascent : ^f32, descent : ^f32, lineGap : ^f32)

stbtt_FindGlyphIndex

func
stbtt_FindGlyphIndex : func(info : ^stbtt_fontinfo, unicode_codepoint : i32) -> i32

stbtt_GetGlyphBox

func
stbtt_GetGlyphBox : func(info : ^stbtt_fontinfo, glyph_index : i32, x0 : ^i32, y0 : ^i32, x1 : ^i32, y1 : ^i32) -> i32

stbtt_GetGlyphHMetrics

func
stbtt_GetGlyphHMetrics : func(info : ^stbtt_fontinfo, glyph_index : i32, advanceWidth : ^i32, leftSideBearing : ^i32)

stbtt_GetFontVMetrics

func
stbtt_GetFontVMetrics : func(info : ^stbtt_fontinfo, ascent : ^i32, descent : ^i32, lineGap : ^i32)

stbtt_GetGlyphBitmapBoxSubpixel

func
stbtt_GetGlyphBitmapBoxSubpixel : func(font : ^stbtt_fontinfo, glyph : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, ix0 : ^i32, iy0 : ^i32, ix1 : ^i32, iy1 : ^i32)

stbtt_GetGlyphBitmapBox

func
stbtt_GetGlyphBitmapBox : func(font : ^stbtt_fontinfo, glyph : i32, scale_x : f32, scale_y : f32, ix0 : ^i32, iy0 : ^i32, ix1 : ^i32, iy1 : ^i32)

stbtt_InitFont

func
stbtt_InitFont : func(info : ^stbtt_fontinfo, data : ^u8, offset : i32) -> i32

stbtt_GetFontNameString

func
stbtt_GetFontNameString : func(font : ^stbtt_fontinfo, length : ^i32, platformID : i32, encodingID : i32, languageID : i32, nameID : i32) -> ^u8

stbtt_GetGlyphShape

func
stbtt_GetGlyphShape : func(info : ^stbtt_fontinfo, glyph_index : i32, pvertices : ^^stbtt_vertex) -> i32

stbtt_GetBakedQuad

func
stbtt_GetBakedQuad : func(chardata : ^stbtt_bakedchar, pw : i32, ph : i32, char_index : i32, xpos : ^f32, ypos : ^f32, q : ^stbtt_aligned_quad, opengl_fillrule : i32)

stbtt_PackBegin

func
stbtt_PackBegin : func(spc : ^stbtt_pack_context, pixels : ^u8, pw : i32, ph : i32, stride_in_bytes : i32, padding : i32, alloc_context : ^void) -> i32

stbtt_PackEnd

func
stbtt_PackEnd : func(spc : ^stbtt_pack_context)

stbtt_PackSetOversampling

func
stbtt_PackSetOversampling : func(spc : ^stbtt_pack_context, h_oversample : u32, v_oversample : u32)

stbtt_PackFontRangesGatherRects

func
stbtt_PackFontRangesGatherRects : func(spc : ^stbtt_pack_context, info : ^stbtt_fontinfo, ranges : ^stbtt_pack_range, num_ranges : i32, rects : ^stbrp_rect) -> i32

stbtt_PackFontRangesRenderIntoRects

func
stbtt_PackFontRangesRenderIntoRects : func(spc : ^stbtt_pack_context, info : ^stbtt_fontinfo, ranges : ^stbtt_pack_range, num_ranges : i32, rects : ^stbrp_rect) -> i32

stbtt_PackFontRanges

func
stbtt_PackFontRanges : func(spc : ^stbtt_pack_context, fontdata : ^u8, font_index : i32, ranges : ^stbtt_pack_range, num_ranges : i32) -> i32

stbtt_PackFontRange

func
stbtt_PackFontRange : func(spc : ^stbtt_pack_context, fontdata : ^u8, font_index : i32, font_size : f32, first_unicode_codepoint_in_range : i32, num_chars_in_range : i32, chardata_for_range : ^stbtt_packedchar) -> i32

stbtt_GetPackedQuad

func
stbtt_GetPackedQuad : func(chardata : ^stbtt_packedchar, pw : i32, ph : i32, char_index : i32, xpos : ^f32, ypos : ^f32, q : ^stbtt_aligned_quad, align_to_integer : i32)

stbtt_BakeFontBitmap

func
stbtt_BakeFontBitmap : func(data : ^u8, offset : i32, pixel_height : f32, pixels : ^u8, pw : i32, ph : i32, first_char : i32, num_chars : i32, chardata : ^stbtt_bakedchar) -> i32

stbtt_MakeCodepointBitmapSubpixelPrefilter

func
stbtt_MakeCodepointBitmapSubpixelPrefilter : func(info : ^stbtt_fontinfo, output : ^u8, out_w : i32, out_h : i32, out_stride : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, oversample_x : i32, oversample_y : i32, sub_x : ^f32, sub_y : ^f32, codepoint : i32)

stbtt_MakeGlyphBitmapSubpixelPrefilter

func
stbtt_MakeGlyphBitmapSubpixelPrefilter : func(info : ^stbtt_fontinfo, output : ^u8, out_w : i32, out_h : i32, out_stride : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, prefilter_x : i32, prefilter_y : i32, sub_x : ^f32, sub_y : ^f32, glyph : i32)

stbtt_Rasterize

func
stbtt_Rasterize : func(result : ^stbtt__bitmap, flatness_in_pixels : f32, vertices : ^stbtt_vertex, num_verts : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, x_off : i32, y_off : i32, invert : i32, userdata : ^void)

stbtt_MakeGlyphBitmapSubpixel

func
stbtt_MakeGlyphBitmapSubpixel : func(info : ^stbtt_fontinfo, output : ^u8, out_w : i32, out_h : i32, out_stride : i32, scale_x : f32, scale_y : f32, shift_x : f32, shift_y : f32, glyph : i32)

stbtt_MakeGlyphBitmap

func
stbtt_MakeGlyphBitmap : func(info : ^stbtt_fontinfo, output : ^u8, out_w : i32, out_h : i32, out_stride : i32, scale_x : f32, scale_y : f32, glyph : i32)

chic_stbtt_get_face_metrics

func
chic_stbtt_get_face_metrics : func(data : ^u8, data_size : i64, metrics : ^StbTrueTypeFaceMetrics) -> i32
Read unscaled face metrics. Returns 1 on success, 0 on failure.

chic_stbtt_get_glyph_metrics

func
chic_stbtt_get_glyph_metrics : func(data : ^u8, data_size : i64, codepoint : u32, scale : f32, metrics : ^StbTrueTypeGlyphMetrics) -> i32
Resolve a Unicode scalar and its scaled bitmap bounds.
A positive bounded range also rejects NaN with Chic's ordered comparisons.

chic_stbtt_get_glyph_kerning

func
chic_stbtt_get_glyph_kerning : func(data : ^u8, data_size : i64, left_glyph_index : i32, right_glyph_index : i32, advance_adjustment : ^i32) -> i32
Return unscaled horizontal pair adjustment from GPOS or the kern table.

chic_stbtt_rasterize_glyph

func
chic_stbtt_rasterize_glyph : func(data : ^u8, data_size : i64, glyph_index : i32, scale : f32, output : ^u8, output_size : i64, width : i32, height : i32, stride : i32) -> i32
Write grayscale coverage into the caller's buffer; preserve stride padding.