| Software | Version | Source | Description |
|---|---|---|---|
| SDL_ttf-2.0.10-win32.zip | 2.0.10 | http://www.libsdl.org/projects/SDL_ttf/ | This is the corresponding dynamic link library file. |
| Function | Transparency | Antialiasing | Colour depth and format | Quality | Speed |
|---|---|---|---|---|---|
| TTF_RENDERTEXT_... in general creates surfaces with the given text (of type pChar) in ISO 8859-1 (Latin1) format; analogous you can use TTF_RENDERUTF8_... to get the the text in the corresponding UNICODE Transformation Format 8. | |||||
| TTF_RENDERTEXT_SOLID(font, text, colour); | yes (colorkey, 0 pixel) | no | 8-bit palettized (RGB) | low | very fast |
| TTF_RENDERTEXT_SHADED(font, text, colour1, colour2); | no (0 pixel is background colour) | yes | 8-bit palettized (RGB) | high | fast |
| TTF_RENDERTEXT_BLENDED(font, text, colour); | yes (alpha channel) | yes | 32-bit unpalettized (RGBA) | very high | slow |
| TTF_RENDERGLYPH_... in general creates surfaces with the corresponding UNICODE glyph letter (of type WORD); analogous you can use TTF_RENDERUNICODE_... to get the corresponding UNICODE letter but attention: you have to give the letter's number as pointer, so number is of type ^WORD. | |||||
| TTF_RENDERGLYPH_SOLID(font, number, colour); | yes (colorkey) | no | 8-bit palettized (RGB) | low | very fast |
| TTF_RENDERGLYPH_SHADED(font, number, colour1, colour2); | no (0 pixel is background colour) | yes | 8-bit palettized (RGB) | high | fast |
| TTF_RENDERGLYPH_BLENDED(font, number, colour); | yes (alpha channel) | yes | 32-bit unpalettized (RGBA) | very high | slow |
PROGRAM chap5;
USES SDL, SDL_TTF;
VAR
screen, fontface:pSDL_SURFACE;
loaded_font:pointer;
colour_font, colour_font2:pSDL_COLOR;
i:BYTE;
BEGIN
SDL_INIT(SDL_INIT_VIDEO);
screen:=SDL_SETVIDEOMODE(400,200,32,SDL_SWSURFACE);
IF screen=NIL THEN HALT;
IF TTF_INIT=-1 THEN HALT;
loaded_font:=TTF_OPENFONT('C:\WINDOWS\fonts\arial.ttf',40);
NEW(colour_font);
NEW(colour_font2);
colour_font^.r:=255; colour_font^.g:=0; colour_font^.b:=0;
colour_font2^.r:=0; colour_font2^.g:=255; colour_font2^.b:=255;
fontface:=TTF_RENDERTEXT_SHADED(loaded_font,'HELLO WORLD!',colour_font^,colour_font2^);
SDL_BLITSURFACE(fontface,NIL,screen,NIL);
SDL_FLIP(screen);
READLN;
DISPOSE(colour_font);
DISPOSE(colour_font2);
SDL_FREESURFACE(screen);
SDL_FREESURFACE(fontface);
TTF_CLOSEFONT(loaded_font);
TTF_QUIT;
SDL_QUIT;
END.
|
PROGRAM chap5; USES SDL, SDL_TTF; VAR screen, fontface:pSDL_SURFACE; loaded_font:pointer; colour_font, colour_font2:pSDL_COLOR; i:BYTE; |
BEGIN
SDL_INIT(SDL_INIT_VIDEO);
screen:=SDL_SETVIDEOMODE(400,200,32,SDL_SWSURFACE);
IF screen=NIL THEN HALT;
IF TTF_INIT=-1 THEN HALT;
loaded_font:=TTF_OPENFONT('C:\WINDOWS\fonts\arial.ttf',40);
|
NEW(colour_font); NEW(colour_font2); colour_font^.r:=255; colour_font^.g:=0; colour_font^.b:=0; colour_font2^.r:=0; colour_font2^.g:=255; colour_font2^.b:=255; |
fontface:=TTF_RENDERTEXT_SHADED(loaded_font,'HELLO WORLD!',colour_font^,colour_font2^); |
SDL_BLITSURFACE(fontface,NIL,screen,NIL); SDL_FLIP(screen); READLN; DISPOSE(colour_font); DISPOSE(colour_font2); SDL_FREESURFACE(screen); SDL_FREESURFACE(fontface); TTF_CLOSEFONT(loaded_font); TTF_QUIT; SDL_QUIT; END. |
![]() |
The final result should look and behave like this: The text "Hello World!" is displayed having red letters on cyan background. |