update LoadFontData: codePoints can now be nil, codepointCount defaults to 95 (like C raylib does)
This commit is contained in:
parent
893dfa5f85
commit
735af12e7f
2 changed files with 12 additions and 5 deletions
|
@ -2900,9 +2900,12 @@ func IsFontReady(font Font) bool {
|
|||
}
|
||||
|
||||
// LoadFontData - Load font data for further use
|
||||
func LoadFontData(fileData []byte, fontSize int32, codepoints []rune, typ int32) []GlyphInfo {
|
||||
func LoadFontData(fileData []byte, fontSize int32, codepoints []rune, codepointCount, typ int32) []GlyphInfo {
|
||||
dataSize := int32(len(fileData))
|
||||
codepointCount := int32(len(codepoints))
|
||||
// In case no chars count provided, default to 95
|
||||
if codepointCount <= 0 {
|
||||
codepointCount = 95
|
||||
}
|
||||
ret := loadFontData(fileData, dataSize, fontSize, codepoints, codepointCount, typ)
|
||||
return unsafe.Slice(ret, codepointCount)
|
||||
}
|
||||
|
|
|
@ -101,12 +101,16 @@ func IsFontReady(font Font) bool {
|
|||
}
|
||||
|
||||
// LoadFontData - Load font data for further use
|
||||
func LoadFontData(fileData []byte, fontSize int32, codePoints []int32, typ int32) []GlyphInfo {
|
||||
func LoadFontData(fileData []byte, fontSize int32, codePoints []rune, codepointCount, typ int32) []GlyphInfo {
|
||||
cfileData := (*C.uchar)(unsafe.Pointer(&fileData[0]))
|
||||
cdataSize := (C.int)(len(fileData))
|
||||
cfontSize := (C.int)(fontSize)
|
||||
ccodePoints := (*C.int)(unsafe.Pointer(&codePoints[0]))
|
||||
ccodePointCount := (C.int)(len(codePoints))
|
||||
ccodePoints := (*C.int)(unsafe.SliceData(codePoints))
|
||||
// In case no chars count provided, default to 95
|
||||
if codepointCount <= 0 {
|
||||
codepointCount = 95
|
||||
}
|
||||
ccodePointCount := (C.int)(codepointCount)
|
||||
ctype := (C.int)(typ)
|
||||
ret := C.LoadFontData(cfileData, cdataSize, cfontSize, ccodePoints, ccodePointCount, ctype)
|
||||
v := unsafe.Slice((*GlyphInfo)(unsafe.Pointer(ret)), ccodePointCount)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue