The sdl2-ttf Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The sdl2-ttf Reference Manual

This is the sdl2-ttf Reference Manual, version 1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 04:02:08 2022 GMT+0.

Table of Contents


1 Introduction

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.

Usage

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.

Examples

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)

##Credits

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


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 sdl2-ttf

Bindings for sdl2_ttf using autowrap

Author

Bryan Baraoidan

License

MIT

Version

1.0

Dependencies
  • alexandria (system).
  • defpackage-plus (system).
  • cl-autowrap (system).
  • sdl2 (system).
  • cffi-libffi (system).
  • trivial-garbage (system).
Source

sdl2-ttf.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 sdl2-ttf/autowrap-spec

Dependency

style.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Child Component

sdl2_ttf.h (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Next: , Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

4.1.1 sdl2-ttf/sdl2-ttf.asd

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

ASDF Systems

sdl2-ttf.

Packages

sdl2-ttf.asdf.


4.1.2 sdl2-ttf/package.lisp

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Packages

sdl2-ttf.


4.1.3 sdl2-ttf/library.lisp

Dependency

package.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).


4.1.4 sdl2-ttf/autowrap.lisp

Dependency

library.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).


4.1.5 sdl2-ttf/helpers.lisp

Dependency

autowrap.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Internals

4.1.6 sdl2-ttf/conditions.lisp

Dependency

helpers.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Internals

4.1.7 sdl2-ttf/render.lisp

Dependency

conditions.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Public Interface
Internals

4.1.8 sdl2-ttf/size.lisp

Dependency

render.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Public Interface
Internals

4.1.9 sdl2-ttf/general.lisp

Dependency

size.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Public Interface
Internals

*fonts* (special variable).


Previous: , Up: Lisp   [Contents][Index]

4.1.10 sdl2-ttf/style.lisp

Dependency

general.lisp (file).

Source

sdl2-ttf.asd.

Parent Component

sdl2-ttf (system).

Public Interface
Internals

Previous: , Up: Files   [Contents][Index]

4.2 Static


Previous: , Up: Static   [Contents][Index]

4.2.1 sdl2-ttf/autowrap-spec/SDL2_ttf.h

Source

sdl2-ttf.asd.

Parent Component

autowrap-spec (module).


5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 sdl2-ttf

Source

package.lisp.

Use List
  • alexandria.
  • autowrap.minimal.
  • common-lisp.
  • plus-c.
  • sdl2-ffi.functions.
Public Interface
Internals

Previous: , Up: Packages   [Contents][Index]

5.2 sdl2-ttf.asdf

Source

sdl2-ttf.asd.

Use List
  • asdf/interface.
  • common-lisp.

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


6.1.1 Setf expanders

Setf Expander: (setf font-outline) (font)
Package

sdl2-ttf.

Source

style.lisp.

Reader

font-outline (function).

Writer

set-font-outline (function).

Setf Expander: (setf font-style) (font)
Package

sdl2-ttf.

Source

style.lisp.

Reader

font-style (function).

Writer

set-font-style (function).


6.1.2 Ordinary functions

Function: close-font (ttf-font-struct)

Frees the memory used by the ttf-font-struct

Package

sdl2-ttf.

Source

general.lisp.

Function: font-outline (font)
Package

sdl2-ttf.

Source

style.lisp.

Setf expander for this function

(setf font-outline).

Function: font-style (font)
Package

sdl2-ttf.

Source

style.lisp.

Setf expander for this function

(setf font-style).

Function: init ()

Initialize the sdl trutype font API. Does not require a call to sdl-init prior to calling this function. Returns 0 if succesful -1 otherwise

Package

sdl2-ttf.

Source

general.lisp.

Function: linked-version ()

Returns the linked version Major Minor and Patch. Useful for debugging

Package

sdl2-ttf.

Source

general.lisp.

Function: open-font (path-to-font point-size)

Open a font specified by the path specifier path-to-font sized to integer point-size (based on 72DPI). Returns a ttf-font struct and null on errors

Package

sdl2-ttf.

Source

general.lisp.

Function: quit ()
Package

sdl2-ttf.

Source

general.lisp.

Function: render-glyph-blended (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-glyph-shaded (font text fg-red fg-green fg-blue fg-alpha bg-red bg-green bg-blue bg-alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-glyph-solid (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-text-blended (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-text-shaded (font text fg-red fg-green fg-blue fg-alpha bg-red bg-green bg-blue bg-alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-text-solid (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-unicode-blended (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-unicode-shaded (font text fg-red fg-green fg-blue fg-alpha bg-red bg-green bg-blue bg-alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-unicode-solid (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-utf8-blended (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-utf8-shaded (font text fg-red fg-green fg-blue fg-alpha bg-red bg-green bg-blue bg-alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: render-utf8-solid (font text red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: set-font-outline (font style)
Package

sdl2-ttf.

Source

style.lisp.

Setf expanders to this function

(setf font-outline).

Function: set-font-style (font style)
Package

sdl2-ttf.

Source

style.lisp.

Setf expanders to this function

(setf font-style).

Function: size-text (font text)

Calculate the resulting surface size, returns (values width height).

Package

sdl2-ttf.

Source

size.lisp.

Function: size-unicode (font text)

Calculate the resulting surface size, returns (values width height).

Package

sdl2-ttf.

Source

size.lisp.

Function: size-utf8 (font text)

Calculate the resulting surface size, returns (values width height).

Package

sdl2-ttf.

Source

size.lisp.

Function: was-init ()

Returns 1 if initialized zero otherwise.

Package

sdl2-ttf.

Source

general.lisp.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Constants

Constant: +style-bold+
Package

sdl2-ttf.

Source

style.lisp.

Constant: +style-italic+
Package

sdl2-ttf.

Source

style.lisp.

Constant: +style-strike-through+
Package

sdl2-ttf.

Source

style.lisp.

Constant: +style-underline+
Package

sdl2-ttf.

Source

style.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.2 Special variables

Special Variable: *fonts*

List of weak refs to fonts.

Package

sdl2-ttf.

Source

general.lisp.


6.2.3 Macros

Macro: check-non-zero (form)
Package

sdl2-ttf.

Source

conditions.lisp.

Macro: check-null (form)
Package

sdl2-ttf.

Source

conditions.lisp.

Macro: check-rc (form)
Package

sdl2-ttf.

Source

conditions.lisp.

Macro: check-true (form)
Package

sdl2-ttf.

Source

conditions.lisp.

Macro: define-function (foreign-name wrapper-name low-level-name cffi-return cffi-arguments lisp-arguments &body body)
Package

sdl2-ttf.

Source

helpers.lisp.

Macro: define-function-get-style (foreign-name wrapper-name low-level-name)
Package

sdl2-ttf.

Source

style.lisp.

Macro: define-function-set-style (foreign-name wrapper-name low-level-name)
Package

sdl2-ttf.

Source

style.lisp.

Macro: define-render-function (style encoding)
Package

sdl2-ttf.

Source

render.lisp.

Macro: define-shaded-render-function (encoding)
Package

sdl2-ttf.

Source

render.lisp.

Macro: define-size-function (encoding)
Package

sdl2-ttf.

Source

size.lisp.

Macro: pack-to-bitwise (packed &body pairs)
Package

sdl2-ttf.

Source

helpers.lisp.

Macro: unpack-bitwise (bitwise &body pairs)
Package

sdl2-ttf.

Source

helpers.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.4 Ordinary functions

Function: %sdl-render-glyph-blended (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-glyph-shaded (font text fg bg)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-glyph-solid (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-text-blended (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-text-shaded (font text fg bg)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-text-solid (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-unicode-blended (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-unicode-shaded (font text fg bg)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-unicode-solid (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-utf8-blended (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-utf8-shaded (font text fg bg)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-render-utf8-solid (font text color)
Package

sdl2-ttf.

Source

render.lisp.

Function: %sdl-size-text (font text x y)
Package

sdl2-ttf.

Source

size.lisp.

Function: %sdl-size-unicode (font text x y)
Package

sdl2-ttf.

Source

size.lisp.

Function: %sdl-size-utf8 (font text x y)
Package

sdl2-ttf.

Source

size.lisp.

Function: %sdl2-ttf-get-font-outline (font)
Package

sdl2-ttf.

Source

style.lisp.

Function: %sdl2-ttf-get-font-style (font)
Package

sdl2-ttf.

Source

style.lisp.

Function: %sdl2-ttf-set-font (font style)
Package

sdl2-ttf.

Source

style.lisp.

Function: %sdl2-ttf-set-font-outline (font style)
Package

sdl2-ttf.

Source

style.lisp.

Function: create-sdl-color-list (red green blue alpha)
Package

sdl2-ttf.

Source

render.lisp.

Function: function-symbol (&rest strings)
Package

sdl2-ttf.

Source

helpers.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.5 Conditions

Condition: sdl-ttf-error
Package

sdl2-ttf.

Source

conditions.lisp.

Direct superclasses

sdl-rc-error.


Previous: , Up: Internals   [Contents][Index]

6.2.6 Classes

Class: sdl-color-tclass
Package

sdl2-ttf.

Source

render.lisp.

Direct superclasses
  • foreign-struct-type.
  • translatable-foreign-type.

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
C   D   F   I   L   M   O   P   Q   R   S   U   W  
Index Entry  Section

%
%sdl-render-glyph-blended: Private ordinary functions
%sdl-render-glyph-shaded: Private ordinary functions
%sdl-render-glyph-solid: Private ordinary functions
%sdl-render-text-blended: Private ordinary functions
%sdl-render-text-shaded: Private ordinary functions
%sdl-render-text-solid: Private ordinary functions
%sdl-render-unicode-blended: Private ordinary functions
%sdl-render-unicode-shaded: Private ordinary functions
%sdl-render-unicode-solid: Private ordinary functions
%sdl-render-utf8-blended: Private ordinary functions
%sdl-render-utf8-shaded: Private ordinary functions
%sdl-render-utf8-solid: Private ordinary functions
%sdl-size-text: Private ordinary functions
%sdl-size-unicode: Private ordinary functions
%sdl-size-utf8: Private ordinary functions
%sdl2-ttf-get-font-outline: Private ordinary functions
%sdl2-ttf-get-font-style: Private ordinary functions
%sdl2-ttf-set-font: Private ordinary functions
%sdl2-ttf-set-font-outline: Private ordinary functions

(
(setf font-outline): Public setf expanders
(setf font-style): Public setf expanders

C
check-non-zero: Private macros
check-null: Private macros
check-rc: Private macros
check-true: Private macros
close-font: Public ordinary functions
create-sdl-color-list: Private ordinary functions

D
define-function: Private macros
define-function-get-style: Private macros
define-function-set-style: Private macros
define-render-function: Private macros
define-shaded-render-function: Private macros
define-size-function: Private macros

F
font-outline: Public ordinary functions
font-style: Public ordinary functions
Function, %sdl-render-glyph-blended: Private ordinary functions
Function, %sdl-render-glyph-shaded: Private ordinary functions
Function, %sdl-render-glyph-solid: Private ordinary functions
Function, %sdl-render-text-blended: Private ordinary functions
Function, %sdl-render-text-shaded: Private ordinary functions
Function, %sdl-render-text-solid: Private ordinary functions
Function, %sdl-render-unicode-blended: Private ordinary functions
Function, %sdl-render-unicode-shaded: Private ordinary functions
Function, %sdl-render-unicode-solid: Private ordinary functions
Function, %sdl-render-utf8-blended: Private ordinary functions
Function, %sdl-render-utf8-shaded: Private ordinary functions
Function, %sdl-render-utf8-solid: Private ordinary functions
Function, %sdl-size-text: Private ordinary functions
Function, %sdl-size-unicode: Private ordinary functions
Function, %sdl-size-utf8: Private ordinary functions
Function, %sdl2-ttf-get-font-outline: Private ordinary functions
Function, %sdl2-ttf-get-font-style: Private ordinary functions
Function, %sdl2-ttf-set-font: Private ordinary functions
Function, %sdl2-ttf-set-font-outline: Private ordinary functions
Function, close-font: Public ordinary functions
Function, create-sdl-color-list: Private ordinary functions
Function, font-outline: Public ordinary functions
Function, font-style: Public ordinary functions
Function, function-symbol: Private ordinary functions
Function, init: Public ordinary functions
Function, linked-version: Public ordinary functions
Function, open-font: Public ordinary functions
Function, quit: Public ordinary functions
Function, render-glyph-blended: Public ordinary functions
Function, render-glyph-shaded: Public ordinary functions
Function, render-glyph-solid: Public ordinary functions
Function, render-text-blended: Public ordinary functions
Function, render-text-shaded: Public ordinary functions
Function, render-text-solid: Public ordinary functions
Function, render-unicode-blended: Public ordinary functions
Function, render-unicode-shaded: Public ordinary functions
Function, render-unicode-solid: Public ordinary functions
Function, render-utf8-blended: Public ordinary functions
Function, render-utf8-shaded: Public ordinary functions
Function, render-utf8-solid: Public ordinary functions
Function, set-font-outline: Public ordinary functions
Function, set-font-style: Public ordinary functions
Function, size-text: Public ordinary functions
Function, size-unicode: Public ordinary functions
Function, size-utf8: Public ordinary functions
Function, was-init: Public ordinary functions
function-symbol: Private ordinary functions

I
init: Public ordinary functions

L
linked-version: Public ordinary functions

M
Macro, check-non-zero: Private macros
Macro, check-null: Private macros
Macro, check-rc: Private macros
Macro, check-true: Private macros
Macro, define-function: Private macros
Macro, define-function-get-style: Private macros
Macro, define-function-set-style: Private macros
Macro, define-render-function: Private macros
Macro, define-shaded-render-function: Private macros
Macro, define-size-function: Private macros
Macro, pack-to-bitwise: Private macros
Macro, unpack-bitwise: Private macros

O
open-font: Public ordinary functions

P
pack-to-bitwise: Private macros

Q
quit: Public ordinary functions

R
render-glyph-blended: Public ordinary functions
render-glyph-shaded: Public ordinary functions
render-glyph-solid: Public ordinary functions
render-text-blended: Public ordinary functions
render-text-shaded: Public ordinary functions
render-text-solid: Public ordinary functions
render-unicode-blended: Public ordinary functions
render-unicode-shaded: Public ordinary functions
render-unicode-solid: Public ordinary functions
render-utf8-blended: Public ordinary functions
render-utf8-shaded: Public ordinary functions
render-utf8-solid: Public ordinary functions

S
set-font-outline: Public ordinary functions
set-font-style: Public ordinary functions
Setf Expander, (setf font-outline): Public setf expanders
Setf Expander, (setf font-style): Public setf expanders
size-text: Public ordinary functions
size-unicode: Public ordinary functions
size-utf8: Public ordinary functions

U
unpack-bitwise: Private macros

W
was-init: Public ordinary functions

Jump to:   %   (  
C   D   F   I   L   M   O   P   Q   R   S   U   W  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   F   G   H   L   M   P   R   S  
Index Entry  Section

A
autowrap-spec: The sdl2-ttf/autowrap-spec module
autowrap.lisp: The sdl2-ttf/autowrap․lisp file

C
Class, sdl-color-tclass: Private classes
Condition, sdl-ttf-error: Private conditions
conditions.lisp: The sdl2-ttf/conditions․lisp file

F
File, autowrap.lisp: The sdl2-ttf/autowrap․lisp file
File, conditions.lisp: The sdl2-ttf/conditions․lisp file
File, general.lisp: The sdl2-ttf/general․lisp file
File, helpers.lisp: The sdl2-ttf/helpers․lisp file
File, library.lisp: The sdl2-ttf/library․lisp file
File, package.lisp: The sdl2-ttf/package․lisp file
File, render.lisp: The sdl2-ttf/render․lisp file
File, sdl2-ttf.asd: The sdl2-ttf/sdl2-ttf․asd file
File, sdl2_ttf.h: The sdl2-ttf/autowrap-spec/sdl2_ttf․h file
File, size.lisp: The sdl2-ttf/size․lisp file
File, style.lisp: The sdl2-ttf/style․lisp file

G
general.lisp: The sdl2-ttf/general․lisp file

H
helpers.lisp: The sdl2-ttf/helpers․lisp file

L
library.lisp: The sdl2-ttf/library․lisp file

M
Module, autowrap-spec: The sdl2-ttf/autowrap-spec module

P
Package, sdl2-ttf: The sdl2-ttf package
Package, sdl2-ttf.asdf: The sdl2-ttf․asdf package
package.lisp: The sdl2-ttf/package․lisp file

R
render.lisp: The sdl2-ttf/render․lisp file

S
sdl-color-tclass: Private classes
sdl-ttf-error: Private conditions
sdl2-ttf: The sdl2-ttf system
sdl2-ttf: The sdl2-ttf package
sdl2-ttf.asd: The sdl2-ttf/sdl2-ttf․asd file
sdl2-ttf.asdf: The sdl2-ttf․asdf package
sdl2_ttf.h: The sdl2-ttf/autowrap-spec/sdl2_ttf․h file
size.lisp: The sdl2-ttf/size․lisp file
style.lisp: The sdl2-ttf/style․lisp file
System, sdl2-ttf: The sdl2-ttf system

Jump to:   A   C   F   G   H   L   M   P   R   S