mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 14:51:40 +00:00
Changed the way NewFonts are instantiated (will make it easier to add multiple fonts)
svn-id: r14625
This commit is contained in:
parent
0f142572f7
commit
bfe9c26a3d
@ -25,36 +25,36 @@ namespace Graphics {
|
||||
|
||||
int NewFont::getCharWidth(byte chr) const {
|
||||
// If no width table is specified, return the maximum width
|
||||
if (!width)
|
||||
return maxwidth;
|
||||
if (!desc.width)
|
||||
return desc.maxwidth;
|
||||
// If this character is not included in the font, use the default char.
|
||||
if (chr < firstchar || firstchar + size < chr) {
|
||||
if (chr < desc.firstchar || desc.firstchar + desc.size < chr) {
|
||||
if (chr == ' ')
|
||||
return maxwidth / 2;
|
||||
chr = defaultchar;
|
||||
return desc.maxwidth / 2;
|
||||
chr = desc.defaultchar;
|
||||
}
|
||||
return width[chr - firstchar];
|
||||
return desc.width[chr - desc.firstchar];
|
||||
}
|
||||
|
||||
void NewFont::drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const {
|
||||
assert(dst != 0);
|
||||
byte *ptr = (byte *)dst->pixels + x * dst->bytesPerPixel + y * dst->pitch;
|
||||
|
||||
assert(bits != 0 && maxwidth <= 16);
|
||||
assert(desc.bits != 0 && desc.maxwidth <= 16);
|
||||
assert(dst->bytesPerPixel == 1 || dst->bytesPerPixel == 2);
|
||||
|
||||
// If this character is not included in the font, use the default char.
|
||||
if (chr < firstchar || chr >= firstchar + size) {
|
||||
if (chr < desc.firstchar || chr >= desc.firstchar + desc.size) {
|
||||
if (chr == ' ')
|
||||
return;
|
||||
chr = defaultchar;
|
||||
chr = desc.defaultchar;
|
||||
}
|
||||
|
||||
const int w = getCharWidth(chr);
|
||||
chr -= firstchar;
|
||||
const bitmap_t *tmp = bits + (offset ? offset[chr] : (chr * height));
|
||||
chr -= desc.firstchar;
|
||||
const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.height));
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
for (y = 0; y < desc.height; y++) {
|
||||
const bitmap_t buffer = *tmp++;
|
||||
bitmap_t mask = 0x8000;
|
||||
for (x = 0; x < w; x++) {
|
||||
|
@ -76,8 +76,7 @@ typedef unsigned short bitmap_t; /* bitmap image unit size*/
|
||||
|
||||
/* builtin C-based proportional/fixed font structure */
|
||||
/* based on The Microwindows Project http://microwindows.org */
|
||||
class NewFont : public Font {
|
||||
protected:
|
||||
struct FontDesc {
|
||||
const char * name; /* font name*/
|
||||
int maxwidth; /* max width in pixels*/
|
||||
int height; /* height in pixels*/
|
||||
@ -89,12 +88,17 @@ protected:
|
||||
const unsigned char* width; /* character widths or NULL if fixed*/
|
||||
int defaultchar; /* default char (not glyph index)*/
|
||||
long bits_size; /* # words of bitmap_t bits*/
|
||||
};
|
||||
|
||||
class NewFont : public Font {
|
||||
protected:
|
||||
FontDesc desc;
|
||||
|
||||
public:
|
||||
NewFont();
|
||||
NewFont(const FontDesc &d) : desc(d) {}
|
||||
|
||||
virtual int getFontHeight() const { return height; }
|
||||
virtual int getMaxCharWidth() const { return maxwidth; };
|
||||
virtual int getFontHeight() const { return desc.height; }
|
||||
virtual int getMaxCharWidth() const { return desc.maxwidth; };
|
||||
|
||||
virtual int getCharWidth(byte chr) const;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Generated by convbdf on Thu Nov 20 00:15:51 2003. */
|
||||
/* Generated by convbdf on Sun Aug 15 15:59:36 2004. */
|
||||
#include "common/stdafx.h"
|
||||
#include "graphics/font.h"
|
||||
|
||||
@ -2565,24 +2565,7 @@ static const unsigned char _sysfont_width[] = {
|
||||
};
|
||||
|
||||
/* Exported structure definition. */
|
||||
NewFont::NewFont() {
|
||||
name = "04b-16b-10";
|
||||
maxwidth = 9;
|
||||
height = 10;
|
||||
ascent = 8;
|
||||
firstchar = 33;
|
||||
size = 94;
|
||||
bits = _font_bits;
|
||||
offset = 0; /* no encode table*/
|
||||
width = _sysfont_width;
|
||||
defaultchar = 33;
|
||||
bits_size = sizeof(_font_bits)/sizeof(bitmap_t);
|
||||
}
|
||||
|
||||
const NewFont g_sysfont;
|
||||
|
||||
#if 0
|
||||
const Font g_sysfont = {
|
||||
static const FontDesc desc = {
|
||||
"04b-16b-10",
|
||||
9,
|
||||
10,
|
||||
@ -2593,8 +2576,9 @@ const Font g_sysfont = {
|
||||
0, /* no encode table*/
|
||||
_sysfont_width,
|
||||
33,
|
||||
sizeof(_font_bits)/sizeof(bitmap_t),
|
||||
sizeof(_font_bits)/sizeof(bitmap_t)
|
||||
};
|
||||
#endif
|
||||
|
||||
} // End of namespace Graphics
|
||||
const NewFont g_sysfont(desc);
|
||||
|
||||
} // End of namespace GUI
|
||||
|
Loading…
x
Reference in New Issue
Block a user