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


Golang C.TTF_GlyphMetrics函數代碼示例

本文整理匯總了Golang中C.TTF_GlyphMetrics函數的典型用法代碼示例。如果您正苦於以下問題:Golang TTF_GlyphMetrics函數的具體用法?Golang TTF_GlyphMetrics怎麽用?Golang TTF_GlyphMetrics使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了TTF_GlyphMetrics函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GlyphMetrics

// Returns the metrics (dimensions) of a glyph.
//
// Return values are:
//   minx, maxx, miny, maxy, advance, err
//
// The last return value (err) is 0 for success, -1 for any error (for example
// if the glyph is not available in this font).
//
// For more information on glyph metrics, visit
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, int) {
	minx := C.int(0)
	maxx := C.int(0)
	miny := C.int(0)
	maxy := C.int(0)
	advance := C.int(0)
	err := C.TTF_GlyphMetrics(f.cfont, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
	return int(minx), int(maxx), int(miny), int(maxy), int(advance), int(err)
}
開發者ID:jgastal,項目名稱:Go-SDL,代碼行數:19,代碼來源:ttf.go

示例2: TTFGlyphMetrics

// Get the metrics (dimensions) of a glyph
// To understand what these metrics mean, here is a useful link:
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
// retuns minx, maxx, miny, maxy, advance
func TTFGlyphMetrics(font *C.TTF_Font, ch uint16) (int, int, int, int, int) {
	var minx, maxx, miny, maxy, advance int
	pminx := cintptr(&minx)
	pmaxx := cintptr(&maxx)
	pminy := cintptr(&miny)
	pmaxy := cintptr(&maxy)
	padv := cintptr(&advance)
	C.TTF_GlyphMetrics(font, C.Uint16(ch), pminx, pmaxx, pminy, pmaxy, padv)
	return minx, maxx, miny, maxy, advance
}
開發者ID:beoran,項目名稱:fungo,代碼行數:14,代碼來源:ttf.go

示例3: GlyphMetrics

// Returns the metrics (dimensions) of a glyph.
//
// Return values are:
//   minx, maxx, miny, maxy, advance, err
//
// For more information on glyph metrics, visit
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, error) {
	minx := C.int(0)
	maxx := C.int(0)
	miny := C.int(0)
	maxy := C.int(0)
	advance := C.int(0)
	err := C.TTF_GlyphMetrics(f.cfont, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
	if int(err) != 0 {
		return int(minx), int(maxx), int(miny), int(maxy), int(advance), sdl.NewSDLError()
	}
	return int(minx), int(maxx), int(miny), int(maxy), int(advance), nil
}
開發者ID:krig,項目名稱:Go-SDL2,代碼行數:19,代碼來源:ttf.go

示例4: GlyphMetrics

func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, error) {
	minx := C.int(0)
	maxx := C.int(0)
	miny := C.int(0)
	maxy := C.int(0)
	advance := C.int(0)
	res := C.TTF_GlyphMetrics(f.c, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)
	var err error
	if res != 0 {
		err = getError()
	}
	return int(minx), int(maxx), int(miny), int(maxy), int(advance), err
}
開發者ID:willemvds,項目名稱:sdl,代碼行數:13,代碼來源:ttf.go

示例5: GlyphMetrics

// Returns the metrics (dimensions) of a glyph.
//
// Return values are:
//   minx, maxx, miny, maxy, advance, err
//
// The last return value (err) is 0 for success, -1 for any error (for example
// if the glyph is not available in this font).
//
// For more information on glyph metrics, visit
// http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (f *Font) GlyphMetrics(ch uint16) (int, int, int, int, int, int) {
	sdl.GlobalMutex.Lock() // Because the underlying C code is fairly complex
	f.mutex.Lock()         // Use a write lock, because 'C.TTF_GlyphMetrics' may update font's internal caches

	minx := C.int(0)
	maxx := C.int(0)
	miny := C.int(0)
	maxy := C.int(0)
	advance := C.int(0)
	err := C.TTF_GlyphMetrics(f.cfont, C.Uint16(ch), &minx, &maxx, &miny, &maxy, &advance)

	sdl.GlobalMutex.Unlock()
	f.mutex.Unlock()

	return int(minx), int(maxx), int(miny), int(maxy), int(advance), int(err)
}
開發者ID:Zwobot,項目名稱:Go-SDL,代碼行數:26,代碼來源:ttf.go

示例6: GetMetrics

func (f *Font) GetMetrics(_ch uint16) (int, int, int, int, int) {
	var minx, maxx, miny, maxy, advance C.int
	C.TTF_GlyphMetrics(f.Get(), C.Uint16(_ch), (*C.int)(cast(&minx)), (*C.int)(cast(&maxx)), (*C.int)(cast(&miny)), (*C.int)(cast(&maxy)), (*C.int)(cast(&advance)))
	return int(minx), int(maxx), int(miny), int(maxy), int(advance)
}
開發者ID:henkman,項目名稱:Go2D,代碼行數:5,代碼來源:ttf.go


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