Mercurial > hg > dmlib
comparison dmtext_ttf.c @ 64:ad1ef3f0d474
More work on the text subsystem.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 11:03:10 +0300 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
63:3d9da937db69 | 64:ad1ef3f0d474 |
---|---|
1 /* | |
2 * DMLib | |
3 * -- Bitmap and TTF text & font support | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
5 * (C) Copyright 2012 Tecnic Software productions (TNSP) | |
6 */ | |
7 #include "dmtext.h" | |
8 | |
9 | |
10 void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt) | |
11 { | |
12 SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col); | |
13 if (text) | |
14 { | |
15 SDL_Rect rect; | |
16 rect.x = xc; | |
17 rect.y = yc; | |
18 rect.w = text->w; | |
19 rect.h = text->h; | |
20 SDL_BlitSurface(text, NULL, screen, &rect); | |
21 SDL_FreeSurface(text); | |
22 } | |
23 } | |
24 | |
25 void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, va_list ap) | |
26 { | |
27 char *tmp = dm_strdup_vprintf(fmt, ap); | |
28 if (tmp != NULL) | |
29 { | |
30 dmDrawTTFTextConst(screen, font, col, xc, yc, tmp); | |
31 dmFree(tmp); | |
32 } | |
33 } | |
34 | |
35 void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, ...) | |
36 { | |
37 va_list ap; | |
38 | |
39 va_start(ap, fmt); | |
40 dmDrawTTFTextVA(screen, font, col, xc, yc, fmt, ap); | |
41 va_end(ap); | |
42 } |