Change LoadFontEx to accept []rune, fixes #136

This commit is contained in:
Milan Nikolic 2022-08-27 17:37:54 +02:00
parent f59ebefc8a
commit 6e090424c5
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
2 changed files with 17 additions and 11 deletions

View file

@ -37,12 +37,17 @@ func LoadFont(fileName string) Font {
}
// LoadFontEx - Load Font from file with extended parameters
func LoadFontEx(fileName string, fontSize int32, fontChars *int32, charsCount int32) Font {
func LoadFontEx(fileName string, fontSize int32, fontChars []rune) Font {
var cfontChars *C.int
var ccharsCount C.int
cfileName := C.CString(fileName)
defer C.free(unsafe.Pointer(cfileName))
cfontSize := (C.int)(fontSize)
cfontChars := (*C.int)(unsafe.Pointer(fontChars))
ccharsCount := (C.int)(charsCount)
if fontChars != nil {
cfontChars = (*C.int)(unsafe.Pointer(&fontChars[0]))
ccharsCount = (C.int)(len(fontChars))
}
ret := C.LoadFontEx(cfileName, cfontSize, cfontChars, ccharsCount)
v := newFontFromPointer(unsafe.Pointer(&ret))
return v