// GetStyle (https://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf_21.html#SEC21) func (f *Font) GetStyle() int { return int(C.TTF_GetFontStyle(f.f)) }
// Returns the rendering style of the font. func (f *Font) GetStyle() int { f.mutex.RLock() result := int(C.TTF_GetFontStyle(f.cfont)) f.mutex.RUnlock() return result }
// Get the style of the font func TTFGetFontStyle(font *C.TTF_Font) int { return int(C.TTF_GetFontStyle(font)) }
package ttf // #cgo CFLAGS: -Iinclude/ // #cgo darwin LDFLAGS: -lSDL_ttf // #cgo windows LDFLAGS: -Llib/windows/amd64 -lSDL_ttf // #include <SDL/SDL_ttf.h> import "C" import ( "unsafe" "github.com/badgerodon/go/sdl" ) type ( Font struct { Ptr unsafe.Pointer } FontStyle int32 Hinting int32 ) const ( Normal FontStyle = C.TTF_STYLE_NORMAL Bold FontStyle = C.TTF_STYLE_BOLD Italic FontStyle = C.TTF_STYLE_ITALIC Underline FontStyle = C.TTF_STYLE_UNDERLINE StrikeThrough FontStyle = C.TTF_STYLE_STRIKETHROUGH NormalHinting Hinting = C.TTF_HINTING_NORMAL LightHinting Hinting = C.TTF_HINTING_LIGHT MonoHinting Hinting = C.TTF_HINTING_MONO NoHinting Hinting = C.TTF_HINTING_NONE ) func ByteSwappedUnicode(isSwapped bool) { c_swapped := C.int(0) if isSwapped { c_swapped = C.int(1) } C.TTF_ByteSwappedUNICODE(c_swapped) } func Init() error { ret := C.TTF_Init() if ret == 0 { return nil } return sdl.GetError() } func WasInit() bool { ret := C.TTF_WasInit() if ret == 1 { return true } return false } func Quit() { C.TTF_Quit() } func OpenFont(file string, ptsize int) (Font, error) { c_file := C.CString(file) defer C.free(unsafe.Pointer(c_file)) c_ptsize := C.int(ptsize) ret := C.TTF_OpenFont(c_file, c_ptsize) if ret == nil { return Font{}, sdl.GetError() } return Font{unsafe.Pointer(ret)}, nil } 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 } /* func OpenFontRW(src sdl.RWops, freesrc int, ptsize int) Font { } func OpenFontIndexRW(src sdl.RWops, freesrc int, ptsize int, index int64) Font { } */ func (this Font) GetStyle() FontStyle { c_font := (*C.TTF_Font)(this.Ptr) ret := C.TTF_GetFontStyle(c_font) return FontStyle(ret) }
// Returns the rendering style of the font. func (f *Font) GetStyle() int { result := int(C.TTF_GetFontStyle(f.cfont)) return result }