Add high-resolution font for textscreen.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2543
This commit is contained in:
Simon Howard 2012-11-18 21:56:18 +00:00
parent a854a3a5e0
commit 9f1a64f856
4 changed files with 2646 additions and 17 deletions

View file

@ -27,6 +27,7 @@ libtextscreen_a_SOURCES = \
txt_separator.c txt_separator.h \
txt_spinctrl.c txt_spinctrl.h \
txt_sdl.c txt_sdl.h \
txt_largefont.h \
txt_smallfont.h \
txt_strut.c txt_strut.h \
txt_table.c txt_table.h \

View file

@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//---------------------------------------------------------------------------
//
// Copyright(C) 2005,2006 Simon Howard
// Copyright (C) 2005,2006 Simon Howard
// Copyright (C) 2002-2004 The DOSBox Team
//
// This program is free software; you can redistribute it and/or modify

2599
textscreen/txt_largefont.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -50,6 +50,7 @@ typedef struct
// Fonts:
#include "txt_font.h"
#include "txt_largefont.h"
#include "txt_smallfont.h"
// Time between character blinks in ms
@ -131,6 +132,10 @@ static txt_font_t *FontForName(char *name)
{
return &main_font;
}
else if (!strcmp(name, "large"))
{
return &large_font;
}
else
{
return NULL;
@ -171,27 +176,35 @@ 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
font = &small_font;
#else
font = &main_font;
#endif
return;
}
for (i=0; modes[i] != NULL; ++i)
{
if (modes[i]->w >= 640 && modes[i]->h >= 480)
{
return;
}
}
// No large mode found.
// Scan through the list of modes. If we find no modes that are at
// least 640x480 in side, default to the small font. If we find one
// mode that is at least 1920x1080, this is a modern high-resolution
// display, and we can use the large font.
font = &small_font;
for (i=0; modes[i] != NULL; ++i)
{
if (modes[i]->w >= 1920 && modes[i]->h >= 1080)
{
font = &large_font;
break;
}
else if (modes[i]->w >= 640 && modes[i]->h >= 480)
{
font = &main_font;
}
}
}
//
@ -249,6 +262,7 @@ static inline void UpdateCharacter(int x, int y)
unsigned char character;
unsigned char *p;
unsigned char *s, *s1;
unsigned int bit, bytes;
int bg, fg;
unsigned int x1, y1;
@ -270,18 +284,22 @@ static inline void UpdateCharacter(int x, int y)
}
}
p = &font->data[character * font->h];
// How many bytes per line?
bytes = (font->w + 7) / 8;
p = &font->data[character * font->h * bytes];
s = ((unsigned char *) screen->pixels)
+ (y * font->h * screen->pitch) + (x * font->w);
s = ((unsigned char *) screen->pixels)
+ (y * font->h * screen->pitch)
+ (x * font->w);
for (y1=0; y1<font->h; ++y1)
{
s1 = s;
bit = 0;
for (x1=0; x1<font->w; ++x1)
{
if (*p & (1 << (7-x1)))
if (*p & (1 << (7-bit)))
{
*s1++ = fg;
}
@ -289,9 +307,20 @@ static inline void UpdateCharacter(int x, int y)
{
*s1++ = bg;
}
++bit;
if (bit == 8)
{
++p;
bit = 0;
}
}
if (bit != 0)
{
++p;
}
++p;
s += screen->pitch;
}
}