diff options
author | Max Horn | 2004-08-15 14:05:28 +0000 |
---|---|---|
committer | Max Horn | 2004-08-15 14:05:28 +0000 |
commit | bfe9c26a3d838d17c28eceac00c0e35cd5c6138e (patch) | |
tree | ed9247d6b9b3d3ebdb50b76eea352a146ad30811 | |
parent | 0f142572f7e4ee643a462d22654a4f9dd9b2ee7a (diff) | |
download | scummvm-rg350-bfe9c26a3d838d17c28eceac00c0e35cd5c6138e.tar.gz scummvm-rg350-bfe9c26a3d838d17c28eceac00c0e35cd5c6138e.tar.bz2 scummvm-rg350-bfe9c26a3d838d17c28eceac00c0e35cd5c6138e.zip |
Changed the way NewFonts are instantiated (will make it easier to add multiple fonts)
svn-id: r14625
-rw-r--r-- | graphics/font.cpp | 24 | ||||
-rw-r--r-- | graphics/font.h | 14 | ||||
-rw-r--r-- | graphics/newfont.cpp | 28 |
3 files changed, 27 insertions, 39 deletions
diff --git a/graphics/font.cpp b/graphics/font.cpp index e57cb3aae1..20a604eb73 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -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++) { diff --git a/graphics/font.h b/graphics/font.h index 2d5d6c9bd4..416c3719d9 100644 --- a/graphics/font.h +++ b/graphics/font.h @@ -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; diff --git a/graphics/newfont.cpp b/graphics/newfont.cpp index a308bb6656..f87b2fa3d1 100644 --- a/graphics/newfont.cpp +++ b/graphics/newfont.cpp @@ -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 |