summaryrefslogtreecommitdiff
path: root/textscreen/txt_sdl.c
diff options
context:
space:
mode:
authorSimon Howard2010-12-05 14:42:09 +0000
committerSimon Howard2010-12-05 14:42:09 +0000
commit2a786cc67e1cfb7472b117f05e1f9962d7d3da39 (patch)
tree32cc11561757ea0652f9e3e75473cc85f9a31ce2 /textscreen/txt_sdl.c
parentd3c8d42bc4edf892557875a83c3f5ae65880e074 (diff)
downloadchocolate-doom-2a786cc67e1cfb7472b117f05e1f9962d7d3da39.tar.gz
chocolate-doom-2a786cc67e1cfb7472b117f05e1f9962d7d3da39.tar.bz2
chocolate-doom-2a786cc67e1cfb7472b117f05e1f9962d7d3da39.zip
Allow textscreen font to be overridden using the TEXTSCREEN_FONT command
line variable. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2195
Diffstat (limited to 'textscreen/txt_sdl.c')
-rw-r--r--textscreen/txt_sdl.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c
index 0df9fc93..315d2762 100644
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -119,6 +119,22 @@ static SDL_Color ega_colors[] =
#endif
+static txt_font_t *FontForName(char *name)
+{
+ if (!strcmp(name, "small"))
+ {
+ return &small_font;
+ }
+ else if (!strcmp(name, "normal"))
+ {
+ return &main_font;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
//
// Select the font to use, based on screen resolution
//
@@ -129,9 +145,22 @@ static SDL_Color ega_colors[] =
static void ChooseFont(void)
{
SDL_Rect **modes;
+ char *env;
int i;
- font = &main_font;
+ // Allow normal selection to be overridden from an environment variable:
+
+ env = getenv("TEXTSCREEN_FONT");
+
+ if (env != NULL)
+ {
+ font = FontForName(env);
+
+ if (font != NULL)
+ {
+ return;
+ }
+ }
// Check all modes
@@ -140,6 +169,8 @@ static void ChooseFont(void)
// If in doubt and we can't get a list, always prefer to
// fall back to the normal font:
+ font = &main_font;
+
if (modes == NULL || modes == (SDL_Rect **) -1 || *modes == NULL)
{
#ifdef _WIN32_WCE