Mercurial > hg > dmlib
annotate src/dmtext_ttf.c @ 1315:7687412f9aef
Fix jssmod sample conversion flags storing .. urgh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 20 Aug 2017 01:54:54 +0300 |
parents | e06abfde6c39 |
children | 3571d4670964 |
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 |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt) |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 if (text) |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 SDL_Rect rect; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 rect.x = xc; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 rect.y = yc; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 rect.w = text->w; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 rect.h = text->h; |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 SDL_BlitSurface(text, NULL, screen, &rect); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 SDL_FreeSurface(text); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 } |
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 void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, va_list ap) |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 { |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 char *tmp = dm_strdup_vprintf(fmt, ap); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 if (tmp != NULL) |
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 dmDrawTTFTextConst(screen, font, col, xc, yc, tmp); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 dmFree(tmp); |
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 } |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int xc, int yc, const char *fmt, ...) |
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 va_list ap; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
38 |
64
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 va_start(ap, fmt); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 dmDrawTTFTextVA(screen, font, col, xc, yc, fmt, ap); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 va_end(ap); |
ad1ef3f0d474
More work on the text subsystem.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 } |