2
* Copyright 1994-2012 Olivier Girondel
4
* This file is part of lebiniou.
6
* lebiniou is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 2 of the License, or
9
* (at your option) any later version.
11
* lebiniou is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
23
static SDL_Color white = { 0xFF, 0xFF, 0xFF, 0 };
24
static SDL_Color black = { 0, 0, 0, 0 };
25
static SDL_Color red = { 0xFF, 0, 0, 0 };
27
static TTF_Font *font = NULL;
32
extern u_short out_width, out_height;
34
#define out_width WIDTH
35
#define out_height HEIGHT
42
/* Initialize the TTF library */
45
xerror("Couldn't initialize TTF: %s\n", SDL_GetError());
47
/* Open the font file with the requested point size */
48
font = TTF_OpenFont(OSD_FONT, OSD_PTSIZE);
50
printf("[!] %s, OSD is disabled.\n", SDL_GetError());
53
TTF_SetFontStyle(font, TTF_STYLE_NORMAL);
54
/* TTF_SetFontStyle(font, TTF_STYLE_BOLD); */
57
fontlineskip = TTF_FontLineSkip(font);
71
osd_print(const u_short x, u_short y,
72
const u_char rev_x, const u_char rev_y,
73
const u_char mode, const int disabled, const char *fmt, ...)
75
char str[OSD_BUFFLEN+1];
77
SDL_Surface *text = NULL;
81
memset((void *)str, '\0', OSD_BUFFLEN*sizeof(char));
84
vsprintf(str, fmt, ap); /* TODO vsnprintf */
87
fg_color = (disabled) ? red : white;
89
text = ((mode == 1) || (mode == 2)) ? TTF_RenderText_Blended(font, str, black)
90
: TTF_RenderText_Shaded(font, str, fg_color, black);
94
dstrect.x = (rev_x) ? (out_width - x - text->w) : x;
95
dstrect.y = (rev_y) ? (out_height - y - text->h) : y;
98
SDL_BlitSurface(text, NULL, drv.sc, &dstrect);
99
SDL_FreeSurface(text);
105
for (dx = -2; dx <= 2; dx ++) {
106
for (dy = -2; dy <= 2; dy ++) {
107
dstrect.x = (rev_x) ? (out_width - x - text->w) : x;
108
dstrect.y = (rev_y) ? (out_height - y - text->h) : y;
111
SDL_BlitSurface(text, NULL, drv.sc, &dstrect);
114
SDL_FreeSurface(text);
116
text = TTF_RenderText_Blended(font, str, fg_color);
117
dstrect.x = (rev_x) ? (out_width - x - text->w) : x;
118
dstrect.y = (rev_y) ? (out_height - y - text->h) : y;
119
SDL_BlitSurface(text, NULL, drv.sc, &dstrect);
120
SDL_FreeSurface(text);
122
y += TTF_FontLineSkip(font) - 1; /* FIXME why -1 ?? --oliv3 */