Skip to content

Commit

Permalink
Merge pull request #452 from JupiterRider/DrawTextCodepoint
Browse files Browse the repository at this point in the history
DrawTextCodepoint(s) functions added to cgo version
  • Loading branch information
gen2brain authored Nov 8, 2024
2 parents 5100377 + e171bb3 commit 7a92d50
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions raylib/rtext.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,25 @@ func GenImageFontAtlas(glyphs []GlyphInfo, glyphRecs []*Rectangle, fontSize int3
v := newImageFromPointer(unsafe.Pointer(&ret))
return *v
}

// DrawTextCodepoint - Draw one character (codepoint)
func DrawTextCodepoint(font Font, codepoint rune, position Vector2, fontSize float32, tint color.RGBA) {
cfont := font.cptr()
ccodepoint := (C.int)(codepoint)
cposition := position.cptr()
cfontSize := (C.float)(fontSize)
ctint := colorCptr(tint)
C.DrawTextCodepoint(*cfont, ccodepoint, *cposition, cfontSize, *ctint)
}

// DrawTextCodepoints - Draw multiple character (codepoint)
func DrawTextCodepoints(font Font, codepoints []rune, position Vector2, fontSize float32, spacing float32, tint color.RGBA) {
cfont := font.cptr()
ccodepoints := (*C.int)(unsafe.SliceData(codepoints))
ccodepointCount := C.int(len(codepoints))
cposition := position.cptr()
cfontSize := (C.float)(fontSize)
cspacing := (C.float)(spacing)
ctint := colorCptr(tint)
C.DrawTextCodepoints(*cfont, ccodepoints, ccodepointCount, *cposition, cfontSize, cspacing, *ctint)
}

0 comments on commit 7a92d50

Please sign in to comment.