本文整理匯總了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)
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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)
}