diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..be303db --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.fasl diff --git a/README.md b/README.md new file mode 100644 index 0000000..052bba9 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# CL-SDL2-TTF + +This is a wrapper for the SDL2_TTF library used for loading fonts and creating text assets. + +## Usage + +## Examples + +## Issues +if you cannot load `cl-sdl-ttf`, please ensure you have SDL_TTF 2.0 installed and not just 1.2. + +If you are sure all of this is correct, and it still will not load, please file an issue and specify +* Your platform and architecture +* Your Common Lisp implementation +* The absolute path to your installed .so, .dylib, .dll, or appropriate OSX framework \ No newline at end of file diff --git a/sdl2-ttf.asd b/sdl2-ttf.asd new file mode 100644 index 0000000..c9d6131 --- /dev/null +++ b/sdl2-ttf.asd @@ -0,0 +1,21 @@ +(defpackage :sdl2-ttf.asdf + (:use #:cl #:asdf)) + +(in-package :sdl2-mixer.asdf) + +(defsystem :sdl2-ttf + :description "Bindings for sdl2_ttf using autowrap" + :author "Bryan Baraoidan" + :license "MIT" + :version "1.0" + :depends-on (:alexandria :defpackage-plus :cl-autowrap :sdl2) + :pathname "src" + :serial t + :components ((:file "package") + (:file "library") + (:file "autowrap") + (:file "conditions") + (:file "general") + (:module autowrap-spec + :pathname "spec" + :components ((:static-file "SDL_ttf"))))) diff --git a/src/conditions.lisp b/src/conditions.lisp new file mode 100644 index 0000000..f6a9a52 --- /dev/null +++ b/src/conditions.lisp @@ -0,0 +1,34 @@ +;;; This file is adapted from almostly completely verbatim from cl-sdl2-mixer as I needed the same functionality for font loading +(in-package :sdl2-mixer) + +(define-condition sdl-mixer-error (sdl2::sdl-rc-error) ()) + +;;; Note, Mix_GetError doesn't exist, it's a #define for SDL_GetError + +(defmacro check-rc (form) + (with-gensyms (rc) + `(let ((,rc ,form)) + (when (< ,rc 0) + (error 'sdl-ttf-error :rc ,rc :string (sdl-get-error))) + ,rc))) + +(defmacro check-non-zero (form) + (with-gensyms (rc) + `(let ((,rc ,form)) + (unless (/= ,rc 0) + (error 'sdl-ttf-error :rc ,rc :string (sdl-get-error))) + ,rc))) + +(defmacro check-true (form) + (with-gensyms (rc) + `(let ((,rc ,form)) + (unless (sdl-true-p ,rc) + (error 'sdl-ttf-error :rc ,rc :string (sdl-get-error))) + ,rc))) + +(defmacro check-null (form) + (with-gensyms (wrapper) + `(let ((,wrapper ,form)) + (if (cffi:null-pointer-p (autowrap:ptr ,wrapper)) + (error 'sdl-ttf-error :rc ,wrapper :string (sdl-get-error)) + ,wrapper)))) diff --git a/src/general.lisp b/src/general.lisp new file mode 100644 index 0000000..c29a932 --- /dev/null +++ b/src/general.lisp @@ -0,0 +1 @@ +(in-package :sdl2-ttf) diff --git a/src/library.lisp b/src/library.lisp new file mode 100644 index 0000000..86f521d --- /dev/null +++ b/src/library.lisp @@ -0,0 +1,4 @@ +(in-package :sdl2-mixer) + +(cffi:define-foreign-library libsdl2-ttf + (:unix (:or "libSDL2_ttf-2.0.so.0" "libSDL2_ttf"))) diff --git a/src/package.lisp b/src/package.lisp new file mode 100644 index 0000000..4156687 --- /dev/null +++ b/src/package.lisp @@ -0,0 +1,8 @@ +(in-package :cl-user) +(defpackage :sdl2-mixer + (:use #:cl + #:cffi + #:alexandria + #:autowrap.minimal + #:plus-c + #:sdl2-ffi.functions)) diff --git a/src/spec/SDL_ttf.h b/src/spec/SDL_ttf.h new file mode 100644 index 0000000..c30e28e --- /dev/null +++ b/src/spec/SDL_ttf.h @@ -0,0 +1 @@ +#include