mirror of
https://git.checksum.fail/alec/neinterm.git
synced 2025-12-13 06:29:53 +02:00
Add files to repository
This commit is contained in:
80
System/Utilities/TrueType.HC
Normal file
80
System/Utilities/TrueType.HC
Normal file
@@ -0,0 +1,80 @@
|
||||
Silent(1); // This is needed to suppress "Function should return val" warnings for wrappers to non-HolyC functions
|
||||
|
||||
class stbtt__buf {
|
||||
U8* data;
|
||||
I32 cursor;
|
||||
I32 size;
|
||||
};
|
||||
|
||||
class stbtt_fontinfo {
|
||||
U8* userdata;
|
||||
U8* data; // pointer to .ttf file
|
||||
I32 fontstart; // offset of start of font
|
||||
I32 numGlyphs; // number of glyphs, needed for range checking
|
||||
I32 loca, head, glyf, hhea, hmtx, kern, gpos, svg; // table locations as offset from start of .ttf
|
||||
I32 index_map; // a cmap mapping for our chosen character encoding
|
||||
I32 indexToLocFormat; // format needed to map from glyph index to glyph
|
||||
|
||||
stbtt__buf cff; // cff font data
|
||||
stbtt__buf charstrings; // the charstring index
|
||||
stbtt__buf gsubrs; // global charstring subroutines index
|
||||
stbtt__buf subrs; // private charstring subroutines index
|
||||
stbtt__buf fontdicts; // array of font dicts
|
||||
stbtt__buf fdselect; // map from glyph to fontdict
|
||||
};
|
||||
|
||||
I32 @stbtt_InitFont(stbtt_fontinfo* info, U8* data, I32 offset)
|
||||
{
|
||||
U64 reg RDI rdi = info;
|
||||
U64 reg RSI rsi = data;
|
||||
U64 reg RDX rdx = offset;
|
||||
no_warn rdi, rsi, rdx;
|
||||
asm {
|
||||
MOV RAX, STBTT_INITFONT
|
||||
CALL RAX
|
||||
}
|
||||
}
|
||||
|
||||
U8* @stbtt_RenderText(stbtt_fontinfo* info, I32 b_w, I32 b_h, I32 l_h, I32* word, I32* advance = NULL)
|
||||
{
|
||||
U64 reg RDI rdi = info;
|
||||
U64 reg RSI rsi = b_w;
|
||||
U64 reg RDX rdx = b_h;
|
||||
U64 reg RCX rcx = l_h;
|
||||
U64 reg R8 r8 = word;
|
||||
U64 reg R9 r9 = advance;
|
||||
no_warn rdi, rsi, rdx, rcx, r8, r9;
|
||||
stbtt_pos = 0;
|
||||
asm {
|
||||
MOV RAX, STBTT_RENDERTEXT
|
||||
CALL RAX
|
||||
}
|
||||
}
|
||||
|
||||
I32 @stbtt_GetTextWidth(stbtt_fontinfo* info, I32 l_h, I32* word, I32* advance = NULL)
|
||||
{
|
||||
U64 reg RDI rdi = info;
|
||||
U64 reg RSI rsi = l_h;
|
||||
U64 reg RDX rdx = word;
|
||||
U64 reg RCX rcx = advance;
|
||||
no_warn rdi, rsi, rdx, rcx;
|
||||
asm {
|
||||
MOV RAX, STBTT_GETTEXTWIDTH
|
||||
CALL RAX
|
||||
}
|
||||
}
|
||||
|
||||
U8* @stbtt_GetFontNameDefault(stbtt_fontinfo* font, I32* length)
|
||||
{
|
||||
U64 reg RDI rdi = font;
|
||||
U64 reg RSI rsi = length;
|
||||
no_warn rdi, rsi;
|
||||
asm {
|
||||
MOV RAX, STBTT_GETFONTNAMEDEFAULT
|
||||
CALL RAX
|
||||
}
|
||||
}
|
||||
|
||||
Silent(0);
|
||||
|
||||
"truetype ";
|
||||
Reference in New Issue
Block a user