forked from AllenDang/gimu
/
font.go
44 lines (35 loc) · 916 Bytes
/
font.go
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
package nk
/*
#include "nuklear.h"
*/
import "C"
import "unsafe"
func NkFontAtlasAddFromBytes(atlas *FontAtlas, data []byte, height float32, config *FontConfig) *Font {
dataPtr := unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&data)).Data)
return NkFontAtlasAddFromMemory(atlas, dataPtr, Size(len(data)), height, config)
}
func (fc *FontConfig) SetPixelSnap(b bool) {
var i int
if b {
i = 1
} else {
i = 0
}
fc.pixel_snap = (C.uchar)(i)
}
func (fc *FontConfig) SetOversample(v, h int) {
fc.oversample_v = (C.uchar)(v)
fc.oversample_h = (C.uchar)(h)
}
func (fc *FontConfig) SetRange(r *Rune) {
fc._range = (*C.nk_rune)(r)
}
func (fc *FontConfig) SetRangeGoRune(r []rune) {
fc._range = (*C.nk_rune)(unsafe.Pointer(&r[0]))
}
func (atlas *FontAtlas) DefaultFont() *Font {
return (*Font)(atlas.default_font)
}
func (f Font) Handle() *UserFont {
return NewUserFontRef(unsafe.Pointer(&f.handle))
}