Skip to content

Commit 9337336

Browse files
Initial Commit for sdl2-ttf
0 parents  commit 9337336

File tree

8 files changed

+85
-0
lines changed

8 files changed

+85
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.fasl

Diff for: README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# CL-SDL2-TTF
2+
3+
This is a wrapper for the SDL2_TTF library used for loading fonts and creating text assets.
4+
5+
## Usage
6+
7+
## Examples
8+
9+
## Issues
10+
if you cannot load `cl-sdl-ttf`, please ensure you have SDL_TTF 2.0 installed and not just 1.2.
11+
12+
If you are sure all of this is correct, and it still will not load, please file an issue and specify
13+
* Your platform and architecture
14+
* Your Common Lisp implementation
15+
* The absolute path to your installed .so, .dylib, .dll, or appropriate OSX framework

Diff for: sdl2-ttf.asd

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(defpackage :sdl2-ttf.asdf
2+
(:use #:cl #:asdf))
3+
4+
(in-package :sdl2-mixer.asdf)
5+
6+
(defsystem :sdl2-ttf
7+
:description "Bindings for sdl2_ttf using autowrap"
8+
:author "Bryan Baraoidan"
9+
:license "MIT"
10+
:version "1.0"
11+
:depends-on (:alexandria :defpackage-plus :cl-autowrap :sdl2)
12+
:pathname "src"
13+
:serial t
14+
:components ((:file "package")
15+
(:file "library")
16+
(:file "autowrap")
17+
(:file "conditions")
18+
(:file "general")
19+
(:module autowrap-spec
20+
:pathname "spec"
21+
:components ((:static-file "SDL_ttf")))))

Diff for: src/conditions.lisp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
;;; This file is adapted from almostly completely verbatim from cl-sdl2-mixer as I needed the same functionality for font loading
2+
(in-package :sdl2-mixer)
3+
4+
(define-condition sdl-mixer-error (sdl2::sdl-rc-error) ())
5+
6+
;;; Note, Mix_GetError doesn't exist, it's a #define for SDL_GetError
7+
8+
(defmacro check-rc (form)
9+
(with-gensyms (rc)
10+
`(let ((,rc ,form))
11+
(when (< ,rc 0)
12+
(error 'sdl-ttf-error :rc ,rc :string (sdl-get-error)))
13+
,rc)))
14+
15+
(defmacro check-non-zero (form)
16+
(with-gensyms (rc)
17+
`(let ((,rc ,form))
18+
(unless (/= ,rc 0)
19+
(error 'sdl-ttf-error :rc ,rc :string (sdl-get-error)))
20+
,rc)))
21+
22+
(defmacro check-true (form)
23+
(with-gensyms (rc)
24+
`(let ((,rc ,form))
25+
(unless (sdl-true-p ,rc)
26+
(error 'sdl-ttf-error :rc ,rc :string (sdl-get-error)))
27+
,rc)))
28+
29+
(defmacro check-null (form)
30+
(with-gensyms (wrapper)
31+
`(let ((,wrapper ,form))
32+
(if (cffi:null-pointer-p (autowrap:ptr ,wrapper))
33+
(error 'sdl-ttf-error :rc ,wrapper :string (sdl-get-error))
34+
,wrapper))))

Diff for: src/general.lisp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(in-package :sdl2-ttf)

Diff for: src/library.lisp

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(in-package :sdl2-mixer)
2+
3+
(cffi:define-foreign-library libsdl2-ttf
4+
(:unix (:or "libSDL2_ttf-2.0.so.0" "libSDL2_ttf")))

Diff for: src/package.lisp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(in-package :cl-user)
2+
(defpackage :sdl2-mixer
3+
(:use #:cl
4+
#:cffi
5+
#:alexandria
6+
#:autowrap.minimal
7+
#:plus-c
8+
#:sdl2-ffi.functions))

Diff for: src/spec/SDL_ttf.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <SDL2/SDL_ttf.h>

0 commit comments

Comments
 (0)