本文整理匯總了Golang中C.TTF_SizeUTF8函數的典型用法代碼示例。如果您正苦於以下問題:Golang TTF_SizeUTF8函數的具體用法?Golang TTF_SizeUTF8怎麽用?Golang TTF_SizeUTF8使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了TTF_SizeUTF8函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SizeUTF8
// Return the width and height of the rendered UTF-8 text.
//
// Return values are (width, height, err) where err is 0 for success, -1 on any error.
func (f *Font) SizeUTF8(text string) (int, int, int) {
w := C.int(0)
h := C.int(0)
s := C.CString(text)
err := C.TTF_SizeUTF8(f.cfont, s, &w, &h)
return int(w), int(h), int(err)
}
示例2: TTFTextSize
// Get the dimensions of a rendered string of text. Works for UTF-8 encoded text.
// returns w and h in that order
func TTFTextSize(font *C.TTF_Font, text string) (int, int) {
var w, h int
ctext := cstr(text)
defer ctext.free()
pw := cintptr(&w)
ph := cintptr(&h)
C.TTF_SizeUTF8(font, ctext, pw, ph)
return w, h
}
示例3: SizeUTF8
// Return the width and height of the rendered UTF-8 text.
//
// Return values are (width, height, err)
func (f *Font) SizeUTF8(text string) (int, int, error) {
w := C.int(0)
h := C.int(0)
s := C.CString(text)
err := C.TTF_SizeUTF8(f.cfont, s, &w, &h)
if int(err) != 0 {
return int(w), int(h), sdl.NewSDLError()
}
return int(w), int(h), nil
}
示例4: SizeUTF8
// SizeUTF8 (https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf_40.html#SEC40)
func (f *Font) SizeUTF8(text string) (int, int, error) {
_text := C.CString(text)
defer C.free(unsafe.Pointer(_text))
var w C.int
var h C.int
result := C.TTF_SizeUTF8(f.f, _text, &w, &h)
if result == 0 {
return int(w), int(h), nil
}
return int(w), int(h), GetError()
}
示例5: SizeUTF8
func (f *Font) SizeUTF8(text string) (int, int, error) {
w := C.int(0)
h := C.int(0)
ctext := C.CString(text)
res := C.TTF_SizeUTF8(f.c, ctext, &w, &h)
var err error
if res != 0 {
err = getError()
}
return int(w), int(h), err
}
示例6: SizeUTF8
// Return the width and height of the rendered UTF-8 text.
//
// Return values are (width, height, err) where err is 0 for success, -1 on any error.
func (f *Font) SizeUTF8(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 caches
w := C.int(0)
h := C.int(0)
s := C.CString(text)
err := C.TTF_SizeUTF8(f.cfont, s, &w, &h)
sdl.GlobalMutex.Unlock()
f.mutex.Unlock()
return int(w), int(h), int(err)
}