-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi_renderer_font.odin
More file actions
46 lines (36 loc) · 1.2 KB
/
api_renderer_font.odin
File metadata and controls
46 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import "umka"
fonts: [dynamic]^RenFont
f_load :: proc "c" (params, result: ^umka.StackSlot) {
context = g_context
filename := cstring(umka.GetParam(params, 0).ptrVal)
size := f32(umka.GetParam(params, 1).realVal)
self := ren_load_font(filename, size)
if (self != nil) {
append(&fonts, self)
umka.GetResult(params, result).intVal = i64(len(fonts) - 1)
}
}
f_set_tab_width :: proc "c" (params, result: ^umka.StackSlot) {
context = g_context
self := fonts[umka.GetParam(params, 0).intVal]
n := umka.GetParam(params, 1).intVal
ren_set_font_tab_width(self, i32(n))
}
f_gc :: proc "c" (params, result: ^umka.StackSlot) {
self := fonts[umka.GetParam(params, 0).intVal]
context = g_context
if (self != nil) {rencache_free_font(self)}
}
f_get_width :: proc "c" (params, result: ^umka.StackSlot) {
self := fonts[umka.GetParam(params, 0).intVal]
text := cstring(umka.GetParam(params, 1).ptrVal)
context = g_context
w := ren_get_font_width(self, text)
umka.GetResult(params, result).intVal = i64(w)
}
f_get_height :: proc "c" (params, result: ^umka.StackSlot) {
self := fonts[umka.GetParam(params, 0).intVal]
h := ren_get_font_height(self)
umka.GetResult(params, result).intVal = i64(h)
}