// Return the width and height of the rendered Latin-1 text. // // Return values are (width, height, err) where err is 0 for success, -1 on any error. func (f *Font) SizeText(text string) (int, int, int) { w := C.int(0) h := C.int(0) s := C.CString(text) err := C.TTF_SizeText(f.cfont, s, &w, &h) return int(w), int(h), int(err) }
// Return the width and height of the rendered Latin-1 text. // // Return values are (width, height, err) func (f *Font) SizeText(text string) (int, int, error) { w := C.int(0) h := C.int(0) s := C.CString(text) err := C.TTF_SizeText(f.cfont, s, &w, &h) if int(err) != 0 { return int(w), int(h), sdl.NewSDLError() } return int(w), int(h), nil }
func (f *Font) SizeText(text string) (int, int, error) { w := C.int(0) h := C.int(0) ctext := C.CString(text) res := C.TTF_SizeText(f.c, ctext, &w, &h) var err error if res != 0 { err = getError() } return int(w), int(h), err }
// Return the width and height of the rendered Latin-1 text. // // Return values are (width, height, err) where err is 0 for success, -1 on any error. func (f *Font) SizeText(text string) (int, int, int) { sdl.GlobalMutex.Lock() // Because the underlying C code is fairly complex f.mutex.Lock() // Use a write lock, because 'C.TTF_Size*' may update font's internal cache w := C.int(0) h := C.int(0) s := C.CString(text) err := C.TTF_SizeText(f.cfont, s, &w, &h) sdl.GlobalMutex.Unlock() f.mutex.Unlock() return int(w), int(h), int(err) }