ttf.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // TTF extension
  2. package al
  3. /*
  4. #cgo pkg-config: allegro_ttf-5
  5. #cgo CFLAGS: -I/usr/local/include
  6. #cgo linux LDFLAGS: -lc_nonshared
  7. #include <stdlib.h>
  8. #include <allegro5/allegro.h>
  9. #include <allegro5/allegro_ttf.h>
  10. #include "helpers.h"
  11. */
  12. import "C"
  13. // import "runtime"
  14. // import "unsafe"
  15. const (
  16. TTF_NO_KERNING = C.ALLEGRO_TTF_NO_KERNING
  17. TTF_MONOCHROME = C.ALLEGRO_TTF_MONOCHROME
  18. TTF_NO_AUTOHINT= C.ALLEGRO_TTF_NO_AUTOHINT
  19. )
  20. func LoadTTFFont(filename string, size, flags int) * Font {
  21. cfilename := cstr(filename); defer cstrFree(cfilename)
  22. return wrapFont(C.al_load_ttf_font(cfilename, C.int(size), C.int(flags)))
  23. }
  24. func (file * File) LoadTTFFont(size, flags int) * Font {
  25. return wrapFont(C.al_load_ttf_font_f(file.toC(), nil, C.int(size), C.int(flags)))
  26. }
  27. func LoadTTFFontStretch(filename string, w, h, flags int) * Font {
  28. cfilename := cstr(filename); defer cstrFree(cfilename)
  29. return wrapFont(C.al_load_ttf_font_stretch(cfilename, C.int(w), C.int(h), C.int(flags)))
  30. }
  31. func (file * File) LoadTTFFontStretch(w, h, flags int) * Font {
  32. return wrapFont(C.al_load_ttf_font_stretch_f(file.toC(), nil, C.int(w), C.int(h), C.int(flags)))
  33. }
  34. func InitTTFAddon() bool {
  35. return bool(C.al_init_ttf_addon())
  36. }
  37. func ShutdownTTFAddon() {
  38. C.al_shutdown_ttf_addon()
  39. }
  40. func TTFVersion() uint32 {
  41. return uint32(C.al_get_allegro_ttf_version())
  42. }