Ejemplo n.º 1
0
// 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)
}
Ejemplo n.º 2
0
Archivo: ttf.go Proyecto: beoran/fungo
// 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
}
Ejemplo n.º 3
0
Archivo: ttf.go Proyecto: krig/Go-SDL2
// 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
}
Ejemplo n.º 4
0
Archivo: ttf.go Proyecto: willemvds/sdl
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
}
Ejemplo n.º 5
0
Archivo: ttf.go Proyecto: Zwobot/Go-SDL
// 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)
}
Ejemplo n.º 6
0
Archivo: ttf.go Proyecto: henkman/Go2D
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)
}