forked from inkyblackness/imgui-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Font.go
45 lines (34 loc) · 1.18 KB
/
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
45
package imgui
// #include "wrapper/Font.h"
// #include "wrapper/Types.h"
import "C"
// Font describes one loaded font in an atlas.
type Font uintptr
// DefaultFont can be used to refer to the default font of the current font atlas without
// having the actual font reference.
const DefaultFont Font = 0
// PushFont adds the given font on the stack. Use DefaultFont to refer to the default font.
func PushFont(font Font) {
C.iggPushFont(font.handle())
}
// PopFont removes the previously pushed font from the stack.
func PopFont() {
C.iggPopFont()
}
// FontSize returns the current font size (= height in pixels) of the current font with the current scale applied.
func FontSize() float32 {
return float32(C.iggGetFontSize())
}
// CalcTextSize calculates the size of the text.
func CalcTextSize(text string, hideTextAfterDoubleHash bool, wrapWidth float32) Vec2 {
CString := newStringBuffer(text)
defer CString.free()
var vec2 Vec2
valueArg, returnFunc := vec2.wrapped()
C.iggCalcTextSize((*C.char)(CString.ptr), C.int(CString.size)-1, castBool(hideTextAfterDoubleHash), C.float(wrapWidth), valueArg)
returnFunc()
return vec2
}
func (font Font) handle() C.IggFont {
return C.IggFont(font)
}