From bfe9c26a3d838d17c28eceac00c0e35cd5c6138e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Aug 2004 14:05:28 +0000 Subject: Changed the way NewFonts are instantiated (will make it easier to add multiple fonts) svn-id: r14625 --- graphics/font.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'graphics/font.cpp') 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++) { -- cgit v1.2.3