當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.TTF_SizeUTF8函數代碼示例

本文整理匯總了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)
}
開發者ID:jgastal,項目名稱:Go-SDL,代碼行數:10,代碼來源:ttf.go

示例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
}
開發者ID:beoran,項目名稱:fungo,代碼行數:11,代碼來源:ttf.go

示例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
}
開發者ID:krig,項目名稱:Go-SDL2,代碼行數:13,代碼來源:ttf.go

示例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()
}
開發者ID:veandco,項目名稱:go-sdl2,代碼行數:12,代碼來源:sdl_ttf.go

示例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
}
開發者ID:willemvds,項目名稱:sdl,代碼行數:11,代碼來源:ttf.go

示例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)
}
開發者ID:Zwobot,項目名稱:Go-SDL,代碼行數:17,代碼來源:ttf.go


注:本文中的C.TTF_SizeUTF8函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。