Add new functions

This commit is contained in:
Milan Nikolic 2021-11-11 18:34:45 +01:00
parent ec25c4ec9e
commit 914ca1ffdc
No known key found for this signature in database
GPG key ID: 9229D0EAA3AA4E75
3 changed files with 62 additions and 4 deletions

View file

@ -133,15 +133,33 @@ func MeasureTextEx(font Font, text string, fontSize float32, spacing float32) Ve
return v
}
// GetGlyphIndex - Returns index position for a unicode character on spritefont
func GetGlyphIndex(font Font, character int32) int32 {
// GetGlyphIndex - Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
func GetGlyphIndex(font Font, codepoint int32) int32 {
cfont := font.cptr()
ccharacter := (C.int)(character)
ret := C.GetGlyphIndex(*cfont, ccharacter)
ccodepoint := (C.int)(codepoint)
ret := C.GetGlyphIndex(*cfont, ccodepoint)
v := (int32)(ret)
return v
}
// GetGlyphInfo - Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
func GetGlyphInfo(font Font, codepoint int32) GlyphInfo {
cfont := font.cptr()
ccodepoint := (C.int)(codepoint)
ret := C.GetGlyphInfo(*cfont, ccodepoint)
v := newGlyphInfoFromPointer(unsafe.Pointer(&ret))
return v
}
// GetGlyphAtlasRec - Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
func GetGlyphAtlasRec(font Font, codepoint int32) Rectangle {
cfont := font.cptr()
ccodepoint := (C.int)(codepoint)
ret := C.GetGlyphAtlasRec(*cfont, ccodepoint)
v := newRectangleFromPointer(unsafe.Pointer(&ret))
return v
}
// DrawFPS - Shows current FPS
func DrawFPS(posX int32, posY int32) {
cposX := (C.int)(posX)