Example #1
0
File: ttf.go Project: willemvds/sdl
func OpenFontIndex(file string, ptsize int, index int64) (*Font, error) {
	cfile := C.CString(file)
	defer C.free(unsafe.Pointer(cfile))
	font := C.TTF_OpenFontIndex(cfile, C.int(ptsize), C.long(index))
	if font == nil {
		return nil, getError()
	}
	return &Font{c: font}, nil
}
Example #2
0
File: ttf.go Project: badgerodon/go
func OpenFontIndex(file string, ptsize int, index int64) (Font, error) {
	c_file := C.CString(file)
	defer C.free(unsafe.Pointer(c_file))
	c_ptsize := C.int(ptsize)
	c_index := C.long(index)
	ret := C.TTF_OpenFontIndex(c_file, c_ptsize, c_index)
	if ret == nil {
		return Font{}, sdl.GetError()
	}
	return Font{unsafe.Pointer(ret)}, nil
} /*
Example #3
0
func OpenFontIndex(file string, size int, index int) (*Font, error) {
	_file := (C.CString)(file)
	_size := (C.int)(size)
	_index := (C.long)(index)
	f := (*C.TTF_Font)(C.TTF_OpenFontIndex(_file, _size, _index))
	C.free(unsafe.Pointer(_file))
	if f == nil {
		return nil, GetError()
	}
	return &Font{f}, nil
}
Example #4
0
// Loads a font from a file containing multiple font faces at the specified
// point size.
func OpenFontIndex(file string, ptsize, index int) *Font {
	cfile := C.CString(file)
	cfont := C.TTF_OpenFontIndex(cfile, C.int(ptsize), C.long(index))
	C.free(unsafe.Pointer(cfile))

	if cfont == nil {
		return nil
	}

	return &Font{cfont}
}
Example #5
0
// Loads a font from a file containing multiple font faces at the specified
// point size.
func OpenFontIndex(file string, ptsize, index int) (*Font, error) {
	sdl.GlobalMutex.Lock()

	cfile := C.CString(file)
	cfont := C.TTF_OpenFontIndex(cfile, C.int(ptsize), C.long(index))
	C.free(unsafe.Pointer(cfile))

	sdl.GlobalMutex.Unlock()

	if cfont == nil {
		return nil, errors.New("Unable to load font")
	}

	return &Font{cfont: cfont}, nil
}
Example #6
0
File: ttf.go Project: beoran/fungo
func TTFOpenFontIndex(file string, ptsize int, index int32) *C.TTF_Font {
	cfile := cstr(file)
	defer cfile.free()
	return C.TTF_OpenFontIndex(cfile, C.int(ptsize), C.long(index))
}