From a490f10c86ada59b1fbd55cb008ff6358d674f39 Mon Sep 17 00:00:00 2001 From: Oleksandr Kryvonos Date: Sat, 24 Feb 2024 20:39:33 +0100 Subject: [PATCH 1/2] copied only changes --- raylib/rtext.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/raylib/rtext.go b/raylib/rtext.go index 35deef8..6a78bf8 100644 --- a/raylib/rtext.go +++ b/raylib/rtext.go @@ -63,6 +63,18 @@ func LoadFontEx(fileName string, fontSize int32, fontChars []rune) Font { return v } +// LoadFontEx - Load Font from file with extended parameter - number of runes to load +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)) + return v +} + // LoadFontFromImage - Loads an Image font file (XNA style) func LoadFontFromImage(image Image, key color.RGBA, firstChar int32) Font { cimage := image.cptr() From a870a098947c2724d4d8570edd8cfed55078aa43 Mon Sep 17 00:00:00 2001 From: Oleksandr Kryvonos Date: Sun, 25 Feb 2024 12:18:39 +0100 Subject: [PATCH 2/2] variadic parameter for runesNumber in LoadFontEx --- raylib/raylib_purego.go | 5 ++++- raylib/rtext.go | 19 ++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/raylib/raylib_purego.go b/raylib/raylib_purego.go index f70512e..6651673 100644 --- a/raylib/raylib_purego.go +++ b/raylib/raylib_purego.go @@ -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 -func LoadFontEx(fileName string, fontSize int32, codepoints []rune) Font { +func LoadFontEx(fileName string, fontSize int32, codepoints []rune, runesNumber ...int32) Font { var font Font codepointCount := int32(len(codepoints)) + if len(runesNumber) > 0 { + codepointCount = int32(runesNumber[0]) + } loadFontEx(uintptr(unsafe.Pointer(&font)), fileName, fontSize, codepoints, codepointCount) return font } diff --git a/raylib/rtext.go b/raylib/rtext.go index 6a78bf8..684c690 100644 --- a/raylib/rtext.go +++ b/raylib/rtext.go @@ -47,7 +47,7 @@ func LoadFont(fileName string) Font { } // 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 ccharsCount C.int @@ -58,23 +58,16 @@ func LoadFontEx(fileName string, fontSize int32, fontChars []rune) Font { cfontChars = (*C.int)(unsafe.Pointer(&fontChars[0])) ccharsCount = (C.int)(len(fontChars)) } + if fontChars == nil { + if len(runesNumber) > 0 { + ccharsCount = (C.int)(runesNumber[0]) + } + } ret := C.LoadFontEx(cfileName, cfontSize, cfontChars, ccharsCount) v := newFontFromPointer(unsafe.Pointer(&ret)) return v } -// LoadFontEx - Load Font from file with extended parameter - number of runes to load -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)) - return v -} - // LoadFontFromImage - Loads an Image font file (XNA style) func LoadFontFromImage(image Image, key color.RGBA, firstChar int32) Font { cimage := image.cptr()