stb_truetype integrated
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 13 Dec 2021 23:48:36 +0000 (17:48 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 13 Dec 2021 23:48:36 +0000 (17:48 -0600)
lib/stb_truetype.c
lib/stb_truetype.onyx [new file with mode: 0644]
run_tree/lib/stb_truetype.dll [new file with mode: 0644]
src/build.onyx

index 4781d4a976ba3ad437fa33ddd302a25bd3c3c8ed..0fb24f4ad799f8020793ea563b5268f50d39616b 100644 (file)
@@ -37,6 +37,7 @@ static void __onyx_heap_free_wrapper(void *ptr, void* userdata) {
 #define STBTT_free   __onyx_heap_free_wrapper
 
 #define STB_TRUETYPE_IMPLEMENTATION
+#define STB_RECT_PACK_IMPLEMENTATION
 #include "stb_rect_pack.h"
 #include "stb_truetype.h"
 
diff --git a/lib/stb_truetype.onyx b/lib/stb_truetype.onyx
new file mode 100644 (file)
index 0000000..3e5aa73
--- /dev/null
@@ -0,0 +1,26 @@
+package stb_truetype
+
+#library "stb_truetype"
+
+stbtt_pack_context :: struct #size 64 {}
+
+stbtt_packedchar :: struct #size 28 {
+    x0, y0, x1, y1: u16;
+    xoff, yoff, xadvance: f32;
+    xoff2, yoff2: f32;
+}
+
+#foreign "stb_truetype" {
+    stbtt_PackBegin           :: (ctx: ^stbtt_pack_context, pixels: ^u8, width, height, stride_in_bytes, padding: i32) -> i32 ---
+    stbtt_PackEnd             :: (ctx: ^stbtt_pack_context) -> void ---
+    stbtt_PackFontRange       :: (ctx: ^stbtt_pack_context, fontdata: ^u8, font_index: i32, font_size: f32, first_unicode_char_in_range: i32, num_chars_in_range: i32, chardata_for_range: ^stbtt_packedchar) -> i32 ---
+    stbtt_PackSetOversampling :: (ctx: ^stbtt_pack_context, h_oversample, v_oversample: i32) -> void ---
+}
+
+#export "stbtt_heap_alloc" (size: i32) -> rawptr {
+    return calloc(size);
+}
+
+#export "stbtt_heap_free" (ptr: rawptr) {
+    cfree(ptr);
+}
\ No newline at end of file
diff --git a/run_tree/lib/stb_truetype.dll b/run_tree/lib/stb_truetype.dll
new file mode 100644 (file)
index 0000000..04a6a9e
Binary files /dev/null and b/run_tree/lib/stb_truetype.dll differ
index e98d2f8a98c61f5c7b7fcf632e75d32f85db25b1..4e10af622717316fabc70a606c06c41ebeeed47d 100644 (file)
@@ -9,4 +9,6 @@
 
 #library_path "./lib"
 #load "glfw3/module"
-#load "opengles/module"
\ No newline at end of file
+#load "opengles/module"
+
+#load "./../lib/stb_truetype"
\ No newline at end of file