git clone ''

(ql:quickload :cl-sdl2-ttf)


This is a wrapper for the SDL2_TTF library used for loading fonts and creating text assets. The library, in it's current state, can load TTF and OTF fonts and render fonts with the three different rendering modes provided by the C library (solid, shaded, and blended). While Latin text, UTF8, UNICODE, and Glyph text rendering is available only Latin text has been tested (as shown in the examples). Functions dealing with font/text attributes (e.g. querying font size, font outline, font style) are not provided yet however, if you do need them leave an issue, or if you're feeling generous, feel free to help out and send a pull request.


Management Functions

Rendering functions.

How SDL TTF renders fonts

Text is rendered by calling one of 12 methods, each one specifying a type of text

as well as specfying one rendering method

For example, solid LATIN1 text is TTF_RenderText_Solid, while blended UTF8 text is TTF_RenderUTF8_Blended. This library follows a more traditional Lisp function name structure and omits the TTF before every function. So the above two functions are render-text-solid and render-utf8-blended respectively. Each method takes the font, created with open-font, the text should be rendered in, the text to be rendered, and the red, green blue and alpha components of the color to render in. More in-depth coverage about the rendering methods and the functions themselves are detailed here. Below is a list of functions provided by the wrapper

Usage with Open GL

Each of the rendering functions returns a surface, however the only one useful for rendering in Open GL are the blended methods, as they produce an ARGB surface. Solid and blended provide a rather strange RGB formatted surface that does something with the alpha you pass in during the rendering call, which does some calculation that my lead to unexpected behavior (if you find otherwise please, let me know). Once you have obtained a surface simply use surface-pixels to obtain the raw pixel data to texture your surface. Note in order for the colors to be correct please be sure to enable blending and chose an appropriate blending function.


There are two example one using sdl renderers while the other uses OpenGL. To run it load the sdl2-ttf-examples package and run (ttf-examples:basic-example) or (ttf-examples:gl-example)



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