ref: 2a786cc67e1cfb7472b117f05e1f9962d7d3da39
parent: d3c8d42bc4edf892557875a83c3f5ae65880e074
author: Simon Howard <[email protected]>
date: Sun Dec 5 09:42:09 EST 2010
Allow textscreen font to be overridden using the TEXTSCREEN_FONT command line variable. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2195
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -119,6 +119,22 @@
#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,10 +145,23 @@
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
modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
@@ -139,6 +168,8 @@
// 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)
{