Skip to content

Commit 8cadac2

Browse files
committed
Add new text functions
1 parent f75cc39 commit 8cadac2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

raylib/rtext.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,22 @@ func IsFontReady(font Font) bool {
8686
}
8787

8888
// LoadFontData - Load font data for further use
89-
func LoadFontData(fileData []byte, dataSize int32, fontSize int32, fontChars *int32, charsCount, typ int32) *GlyphInfo {
89+
func LoadFontData(fileData []byte, fontSize int32, codePoints []int32, typ int32) []GlyphInfo {
9090
cfileData := (*C.uchar)(unsafe.Pointer(&fileData[0]))
91-
cdataSize := (C.int)(dataSize)
91+
cdataSize := (C.int)(len(fileData))
9292
cfontSize := (C.int)(fontSize)
93-
cfontChars := (*C.int)(unsafe.Pointer(fontChars))
94-
ccharsCount := (C.int)(charsCount)
93+
ccodePoints := (*C.int)(unsafe.Pointer(&codePoints[0]))
94+
ccodePointCount := (C.int)(len(codePoints))
9595
ctype := (C.int)(typ)
96-
ret := C.LoadFontData(cfileData, cdataSize, cfontSize, cfontChars, ccharsCount, ctype)
97-
v := newGlyphInfoFromPointer(unsafe.Pointer(&ret))
98-
return &v
96+
ret := C.LoadFontData(cfileData, cdataSize, cfontSize, ccodePoints, ccodePointCount, ctype)
97+
v := unsafe.Slice((*GlyphInfo)(unsafe.Pointer(ret)), ccodePointCount)
98+
return v
99+
}
100+
101+
// UnloadFontData - Unload font chars info data (RAM)
102+
func UnloadFontData(glyphs []GlyphInfo) {
103+
cglyphs := (*C.GlyphInfo)(unsafe.Pointer(&glyphs[0]))
104+
C.UnloadFontData(cglyphs, C.int(len(glyphs)))
99105
}
100106

101107
// UnloadFont - Unload Font from GPU memory (VRAM)

0 commit comments

Comments
 (0)