[Scummvm-cvs-logs] CVS: scummvm/graphics font.cpp,1.1,1.2 font.h,1.1,1.2 newfont.cpp,1.1,1.2

Max Horn fingolfin at users.sourceforge.net
Sun Aug 15 07:06:09 CEST 2004


Update of /cvsroot/scummvm/scummvm/graphics
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23737

Modified Files:
	font.cpp font.h newfont.cpp 
Log Message:
Changed the way NewFonts are instantiated (will make it easier to add multiple fonts)

Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/font.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- font.cpp	21 Mar 2004 21:20:06 -0000	1.1
+++ font.cpp	15 Aug 2004 14:05:28 -0000	1.2
@@ -25,36 +25,36 @@
 
 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++) {

Index: font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/font.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- font.h	21 Mar 2004 21:20:06 -0000	1.1
+++ font.h	15 Aug 2004 14:05:28 -0000	1.2
@@ -76,8 +76,7 @@
 
 /* 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 @@
 	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;

Index: newfont.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/newfont.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- newfont.cpp	21 Mar 2004 21:20:06 -0000	1.1
+++ newfont.cpp	15 Aug 2004 14:05:28 -0000	1.2
@@ -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 @@
 };
 
 /* 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 @@
 	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





More information about the Scummvm-git-logs mailing list