| 1 |
<html lang="en"> |
|---|
| 2 |
<head> |
|---|
| 3 |
<title>DerelictSDLttf</title> |
|---|
| 4 |
<link rel="stylesheet" type="text/css" href="styles.css"> |
|---|
| 5 |
</head> |
|---|
| 6 |
<body> |
|---|
| 7 |
<h2>DerelictSDLttf</h2> |
|---|
| 8 |
DerelictSDLttf is a D binding to Sam Lantinga's |
|---|
| 9 |
<a href="http://www.libsdl.org/projects/SDL_ttf/">SDL_ttf</a>, a cross-platform library |
|---|
| 10 |
that allows you to use TrueType fonts with <a href="http://www.libsdl.org/">SDL</a>. |
|---|
| 11 |
|
|---|
| 12 |
<p> |
|---|
| 13 |
The current version of DerelictSDLttf requires <tt>SDL_ttf 2.0.7</tt> or later. |
|---|
| 14 |
</p> |
|---|
| 15 |
|
|---|
| 16 |
<h3>Building</h3> |
|---|
| 17 |
To compile DerelictSDLttf, add the <tt>DerelictSDLttf</tt> make target to the command line when |
|---|
| 18 |
compiling Derelict. For example, to build DerelictSDLttf on Windows with DMD, you would execute the following: |
|---|
| 19 |
<pre><code> |
|---|
| 20 |
make -fwin32.mak DerelictSDLttf DC=DMD |
|---|
| 21 |
</code></pre> |
|---|
| 22 |
For more information on compiling Derelict libraries, see <a href="build.html">Building the |
|---|
| 23 |
Derelict Bindings</a>. |
|---|
| 24 |
|
|---|
| 25 |
<h3>Using</h3> |
|---|
| 26 |
<ol> |
|---|
| 27 |
<li>Always make sure the DerelictSDLttf source modules are available on your import |
|---|
| 28 |
path.</li> |
|---|
| 29 |
<li>In modules that make use of DerelictSDLttf, you will need to import the |
|---|
| 30 |
<tt>derelict.sdl.ttf</tt> and <tt>derelict.sdl.sdl</tt> modules.</li> |
|---|
| 31 |
<li>You must link your application with the DerelictSDL, DerelictSDLttf and DerelictUtil libraries.</li> |
|---|
| 32 |
<li>Before calling any SDL_ttf functions, you need to make a call to <tt>DerelictSDLttf.load()</tt>. |
|---|
| 33 |
This will load the shared library.</li> |
|---|
| 34 |
</ol> |
|---|
| 35 |
|
|---|
| 36 |
<p> |
|---|
| 37 |
The following is a complete program that loads DerelictSDLttf: |
|---|
| 38 |
</p> |
|---|
| 39 |
|
|---|
| 40 |
<pre><code> |
|---|
| 41 |
import derelict.sdl.ttf; |
|---|
| 42 |
|
|---|
| 43 |
void main() |
|---|
| 44 |
{ |
|---|
| 45 |
DerelictSDLttf.load(); |
|---|
| 46 |
|
|---|
| 47 |
// now you can call SDL_ttf functions |
|---|
| 48 |
} |
|---|
| 49 |
</code></pre> |
|---|
| 50 |
<p> |
|---|
| 51 |
As with other Derelict bindings, DerelictSDLttf will throw an exception if an error |
|---|
| 52 |
occurs while loading the shared library. For more information on Derelict |
|---|
| 53 |
exceptions, see the documentation for <a href="use.html#Exceptions">Using the Derelict Bindings</a></a>. |
|---|
| 54 |
</p> |
|---|
| 55 |
|
|---|
| 56 |
<p> |
|---|
| 57 |
Finally, the method <tt>DerelictSDLttf.unload()</tt> is provided for convenience. In normal |
|---|
| 58 |
practice you do not need to call this function, as Derelict will unload the library |
|---|
| 59 |
automatically when the app exits. You generally should only use this function if |
|---|
| 60 |
you need to unload DerelictSDLttf while the application is running or if you disable the |
|---|
| 61 |
automatic unloading of shared libraries (as per <a href="util.html#Loader">the documentation for the loader module</a>). |
|---|
| 62 |
</p> |
|---|
| 63 |
|
|---|
| 64 |
</body> |
|---|
| 65 |
</html> |
|---|