variadic parameter for runesNumber in LoadFontEx
This commit is contained in:
parent
a490f10c86
commit
a870a09894
2 changed files with 10 additions and 14 deletions
|
@ -2829,9 +2829,12 @@ func LoadFont(fileName string) Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadFontEx - Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont
|
// LoadFontEx - Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont
|
||||||
func LoadFontEx(fileName string, fontSize int32, codepoints []rune) Font {
|
func LoadFontEx(fileName string, fontSize int32, codepoints []rune, runesNumber ...int32) Font {
|
||||||
var font Font
|
var font Font
|
||||||
codepointCount := int32(len(codepoints))
|
codepointCount := int32(len(codepoints))
|
||||||
|
if len(runesNumber) > 0 {
|
||||||
|
codepointCount = int32(runesNumber[0])
|
||||||
|
}
|
||||||
loadFontEx(uintptr(unsafe.Pointer(&font)), fileName, fontSize, codepoints, codepointCount)
|
loadFontEx(uintptr(unsafe.Pointer(&font)), fileName, fontSize, codepoints, codepointCount)
|
||||||
return font
|
return font
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func LoadFont(fileName string) Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadFontEx - Load Font from file with extended parameters
|
// LoadFontEx - Load Font from file with extended parameters
|
||||||
func LoadFontEx(fileName string, fontSize int32, fontChars []rune) Font {
|
func LoadFontEx(fileName string, fontSize int32, fontChars []rune, runesNumber ...int32) Font {
|
||||||
var cfontChars *C.int
|
var cfontChars *C.int
|
||||||
var ccharsCount C.int
|
var ccharsCount C.int
|
||||||
|
|
||||||
|
@ -58,19 +58,12 @@ func LoadFontEx(fileName string, fontSize int32, fontChars []rune) Font {
|
||||||
cfontChars = (*C.int)(unsafe.Pointer(&fontChars[0]))
|
cfontChars = (*C.int)(unsafe.Pointer(&fontChars[0]))
|
||||||
ccharsCount = (C.int)(len(fontChars))
|
ccharsCount = (C.int)(len(fontChars))
|
||||||
}
|
}
|
||||||
ret := C.LoadFontEx(cfileName, cfontSize, cfontChars, ccharsCount)
|
if fontChars == nil {
|
||||||
v := newFontFromPointer(unsafe.Pointer(&ret))
|
if len(runesNumber) > 0 {
|
||||||
return v
|
ccharsCount = (C.int)(runesNumber[0])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// LoadFontEx - Load Font from file with extended parameter - number of runes to load
|
ret := C.LoadFontEx(cfileName, cfontSize, cfontChars, ccharsCount)
|
||||||
func LoadFontExByRunesNumber(fileName string, fontSize int32, runesNumber int32) Font {
|
|
||||||
ccharsCount := (C.int)(runesNumber)
|
|
||||||
cfileName := C.CString(fileName)
|
|
||||||
defer C.free(unsafe.Pointer(cfileName))
|
|
||||||
cfontSize := (C.int)(fontSize)
|
|
||||||
|
|
||||||
ret := C.LoadFontEx(cfileName, cfontSize, nil, ccharsCount)
|
|
||||||
v := newFontFromPointer(unsafe.Pointer(&ret))
|
v := newFontFromPointer(unsafe.Pointer(&ret))
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue