Mercurial > hg > dmlib
annotate src/dmtext_ttf.c @ 2255:92385f9b7384
More cross-build fixing ..
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 15 Jun 2019 21:54:14 +0300 |
parents | b91d54a37b6b |
children |
rev | line source |
---|---|
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * DMLib |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * -- Bitmap and TTF text & font support |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * Programmed and designed by Matti 'ccr' Hamalainen |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * (C) Copyright 2012 Tecnic Software productions (TNSP) |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 */ |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #include "dmtext.h" |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
1952 | 10 void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, |
11 SDL_Color col, const int xc, const int yc, const char *fmt) | |
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col); |
1611 | 14 if (text != NULL) |
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 SDL_Rect rect; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 rect.x = xc; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 rect.y = yc; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 rect.w = text->w; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 rect.h = text->h; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 SDL_BlitSurface(text, NULL, screen, &rect); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 SDL_FreeSurface(text); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 } |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 } |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 |
1952 | 26 |
27 void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, | |
28 SDL_Color col, const int xc, const int yc, const char *fmt, va_list ap) | |
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 char *tmp = dm_strdup_vprintf(fmt, ap); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 if (tmp != NULL) |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 dmDrawTTFTextConst(screen, font, col, xc, yc, tmp); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 dmFree(tmp); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 } |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 } |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 |
1952 | 38 |
39 void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, | |
40 SDL_Color col, const int xc, const int yc, const char *fmt, ...) | |
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 va_list ap; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
43 |
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 va_start(ap, fmt); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 dmDrawTTFTextVA(screen, font, col, xc, yc, fmt, ap); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 va_end(ap); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 } |