102 lines
1.7 KiB
D
102 lines
1.7 KiB
D
module dlib.externdecl;
|
|
|
|
import dlib.aliases;
|
|
|
|
enum stbtt_curvetype : u8
|
|
{
|
|
none,
|
|
vmove,
|
|
vline,
|
|
vcurve,
|
|
vcubic,
|
|
}
|
|
|
|
alias stbtt_vertex_type = short;
|
|
|
|
struct stbtt__buf
|
|
{
|
|
u8* data;
|
|
i32 cursor;
|
|
i32 size;
|
|
}
|
|
|
|
struct stbtt_vertex
|
|
{
|
|
stbtt_vertex_type x, y, cx, cy, cx1, cy1;
|
|
stbtt_curvetype type;
|
|
u8 padding;
|
|
}
|
|
|
|
struct stbtt_fontinfo
|
|
{
|
|
void* userdata;
|
|
u8* data;
|
|
i32 fontstart;
|
|
|
|
i32 numGlyphs;
|
|
|
|
i32 loca, head, glyf, hhea, hmtx, kern, gpos, svg;
|
|
i32 index_map;
|
|
i32 indexToLocFormat;
|
|
|
|
stbtt__buf cff;
|
|
stbtt__buf charstrings;
|
|
stbtt__buf gsubrs;
|
|
stbtt__buf subrs;
|
|
stbtt__buf fontdicts;
|
|
stbtt__buf fdselect;
|
|
}
|
|
|
|
extern(C):
|
|
|
|
// stb_truetype
|
|
|
|
i32
|
|
stbtt_FindGlyphIndex(const stbtt_fontinfo* info, i32 unicode_codepoint);
|
|
|
|
void
|
|
stbtt_GetGlyphHMetrics(const stbtt_fontinfo* info, i32 glyph_index, i32* advanceWidth, i32* leftSideBearing);
|
|
|
|
i32
|
|
stbtt_GetGlyphShape(const stbtt_fontinfo* info, i32 glyph_index, stbtt_vertex** pvertices);
|
|
|
|
void
|
|
stbtt_FreeShape(const stbtt_fontinfo* info, stbtt_vertex* v);
|
|
|
|
f32
|
|
stbtt_ScaleForPixelHeight(const stbtt_fontinfo* info, f32 height);
|
|
|
|
void
|
|
stbtt_GetFontVMetrics(const stbtt_fontinfo* info, i32* ascent, i32* descent, i32* lineGap);
|
|
|
|
i32
|
|
stbtt_InitFont(stbtt_fontinfo* info, const(u8*) data, i32 offset);
|
|
|
|
i32
|
|
stbtt_GetGlyphBox(const stbtt_fontinfo* info, i32 glyph_index, i32* x0, i32* y0, i32* x1, i32* y1);
|
|
|
|
i32
|
|
stbtt_GetFontOffsetForIndex(const(u8*) data, i32 index);
|
|
|
|
// tinyalloc
|
|
|
|
version(WebAssembly)
|
|
{
|
|
void
|
|
ta_init(const usize heap_blocks, const usize split_thresh, const usize alignment);
|
|
|
|
void*
|
|
malloc(usize size) nothrow @nogc;
|
|
|
|
void*
|
|
calloc(usize size, usize count);
|
|
|
|
void
|
|
free(void *ptr);
|
|
|
|
void*
|
|
realloc(void *ptr, usize size);
|
|
}
|
|
|
|
|