Add FromMemory functions

This commit is contained in:
Milan Nikolic 2021-05-26 12:01:51 +02:00
parent ad07f2586d
commit 3908769a21
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
3 changed files with 48 additions and 1 deletions

View file

@ -55,6 +55,20 @@ func LoadFontFromImage(image Image, key Color, firstChar int32) Font {
return v
}
// LoadFontFromMemory - Load font from memory buffer, fileType refers to extension: i.e. ".ttf"
func LoadFontFromMemory(fileType string, fileData []byte, dataSize int32, fontSize int32, fontChars *int32, charsCount int32) Font {
cfileType := C.CString(fileType)
defer C.free(unsafe.Pointer(cfileType))
cfileData := (*C.uchar)(unsafe.Pointer(&fileData[0]))
cdataSize := (C.int)(dataSize)
cfontSize := (C.int)(fontSize)
cfontChars := (*C.int)(unsafe.Pointer(fontChars))
ccharsCount := (C.int)(charsCount)
ret := C.LoadFontFromMemory(cfileType, cfileData, cdataSize, cfontSize, cfontChars, ccharsCount)
v := newFontFromPointer(unsafe.Pointer(&ret))
return v
}
// LoadFontData - Load font data for further use
func LoadFontData(fileData []byte, dataSize int32, fontSize int32, fontChars *int32, charsCount, typ int32) *CharInfo {
cfileData := (*C.uchar)(unsafe.Pointer(&fileData[0]))