[Scummvm-cvs-logs] CVS: scummvm/graphics fontman.cpp,NONE,1.1 fontman.h,NONE,1.1 font.cpp,1.5,1.6 font.h,1.4,1.5 module.mk,1.2,1.3 newfont.cpp,1.3,1.4 scummfont.cpp,1.5,1.6

Max Horn fingolfin at users.sourceforge.net
Thu Jan 6 13:17:43 CET 2005


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

Modified Files:
	font.cpp font.h module.mk newfont.cpp scummfont.cpp 
Added Files:
	fontman.cpp fontman.h 
Log Message:
Added a font manager (work in progress)

--- NEW FILE: fontman.cpp ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/graphics/fontman.cpp,v 1.1 2005/01/06 21:15:51 fingolfin Exp $
 */

#include "graphics/fontman.h"
//#include "gui/consolefont.h"

namespace GUI {
	extern const Graphics::NewFont g_consolefont;
};

namespace Graphics {

const ScummFont g_scummfont;
extern const NewFont g_sysfont;


DECLARE_SINGLETON(FontManager);

FontManager::FontManager() {
}

//const Font *FontManager::getFontByName(const Common::String &name) const {
//}

const Font *FontManager::getFontByUsage(FontUsage usage) const {
	switch (usage) {
	case kOSDFont:
		return &g_scummfont;
	case kConsoleFont:
		return &GUI::g_consolefont;
	case kGUIFont:
		return &g_sysfont;
	}
	return 0;
}

} // End of namespace Graphics

--- NEW FILE: fontman.h ---
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header: /cvsroot/scummvm/scummvm/graphics/fontman.h,v 1.1 2005/01/06 21:15:51 fingolfin Exp $
 */

#ifndef FONTMAN_H
#define FONTMAN_H

#include "stdafx.h"
#include "common/scummsys.h"
#include "common/singleton.h"
#include "common/str.h"
#include "graphics/font.h"


namespace Graphics {

class FontManager : public Common::Singleton<FontManager> {
public:
	enum FontUsage {
		kOSDFont,
		kConsoleFont,
		kGUIFont
	};

	/**
	 * Retrieve a font object based on its 'name'.
	 *
	 * @param name	the name of the font to be retrieved.
	 * @return a pointer to a font, or 0 if no suitable font was found.
	 */
	//const Font *getFontByName(const Common::String &name) const;

	/**
	 * Retrieve a font object based on what it is supposed
	 * to be used for
	 *
	 * @param usage	a FontUsage enum value indicating what the font will be used for.
	 * @return a pointer to a font, or 0 if no suitable font was found.
	 */
	const Font *getFontByUsage(FontUsage usage) const;
	
	//const Font *getFontBySize(int size???) const;
	

private:
	friend class Common::Singleton<SingletonBaseType>;
	FontManager();
};


} // End of namespace Graphics

/** Shortcut for accessing the font manager. */
#define FontMan		(Graphics::FontManager::instance())

#endif

Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/font.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- font.cpp	6 Jan 2005 19:09:33 -0000	1.5
+++ font.cpp	6 Jan 2005 21:15:51 -0000	1.6
@@ -20,7 +20,6 @@
 
 #include "common/stdafx.h"
 #include "graphics/font.h"
-#include "gui/newgui.h"
 
 namespace Graphics {
 
@@ -37,9 +36,8 @@
 	return desc.width[chr - desc.firstchar];
 }
 
-void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, bool scale) const {
+void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, int scaleFactor) const {
 	assert(dst != 0);
-	const int scaleFactor = scale ? g_gui.getScaleFactor() : 1;
 	tx *= scaleFactor; ty *= scaleFactor;
 
 	byte *ptr = (byte *)dst->getBasePtr(tx, ty);
@@ -103,7 +101,7 @@
 	return space;
 }
 
-void Font::drawString(const Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis, bool scale) const {
+void Font::drawString(const Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis, int scaleFactor) const {
 	assert(dst != 0);
 	const int leftX = x, rightX = x + w;
 	uint i;
@@ -168,7 +166,7 @@
 		if (x+w > rightX)
 			break;
 		if (x >= leftX)
-			drawChar(dst, str[i], x, y, color, scale);
+			drawChar(dst, str[i], x, y, color, scaleFactor);
 		x += w;
 	}
 }

Index: font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/font.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- font.h	6 Jan 2005 19:09:33 -0000	1.4
+++ font.h	6 Jan 2005 21:15:51 -0000	1.5
@@ -52,9 +52,9 @@
 	virtual int getMaxCharWidth() const = 0;
 
 	virtual int getCharWidth(byte chr) const = 0;
-	virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, bool scale = false) const = 0;
+	virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, int scaleFactor = 1) const = 0;
 
-	void drawString(const Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true, bool scale = false) const;
+	void drawString(const Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true, int scaleFactor = 1) const;
 	int getStringWidth(const Common::String &str) const;
 };
 
@@ -65,11 +65,9 @@
 	virtual int getMaxCharWidth() const { return 8; };
 
 	virtual int getCharWidth(byte chr) const;
-	virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, bool scale) const;
+	virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, int scaleFactor) const;
 };
 
-extern const ScummFont g_scummfont;
-
 
 
 typedef unsigned short bitmap_t; /* bitmap image unit size*/
@@ -101,11 +99,9 @@
 	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, bool scale) const;
+	virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, int scaleFactor) const;
 };
 
-extern const NewFont g_sysfont;
-
 } // End of namespace Graphics
 
 #endif

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/module.mk,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- module.mk	25 Nov 2004 23:33:20 -0000	1.2
+++ module.mk	6 Jan 2005 21:15:51 -0000	1.3
@@ -2,9 +2,10 @@
 
 MODULE_OBJS := \
 	graphics/animation.o \
+	graphics/scummfont.o \
 	graphics/font.o \
+	graphics/fontman.o \
 	graphics/newfont.o \
-	graphics/scummfont.o \
 	graphics/surface.o
 
 MODULE_DIRS += \

Index: newfont.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/newfont.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- newfont.cpp	15 Aug 2004 14:13:31 -0000	1.3
+++ newfont.cpp	6 Jan 2005 21:15:51 -0000	1.4
@@ -2579,6 +2579,6 @@
 	sizeof(_font_bits)/sizeof(bitmap_t)
 };
 
-const NewFont g_sysfont(desc);
+extern const NewFont g_sysfont(desc);
 
 } // End of namespace Graphics

Index: scummfont.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/graphics/scummfont.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- scummfont.cpp	6 Jan 2005 19:09:33 -0000	1.5
+++ scummfont.cpp	6 Jan 2005 21:15:51 -0000	1.6
@@ -63,9 +63,8 @@
 }
 
 //void ScummFont::drawChar(byte chr, int xx, int yy, OverlayColor color) {
-void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, bool scale) const {
+void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, int scaleFactor) const {
 	assert(dst != 0);
-	const int scaleFactor = scale ? g_gui.getScaleFactor() : 1;
 	tx *= scaleFactor; ty *= scaleFactor;
 
 	byte *ptr = (byte *)dst->getBasePtr(tx, ty);
@@ -85,7 +84,7 @@
 
 			if (tx + x < 0 || tx + x >= dst->w)
 				continue;
-			unsigned char c;
+			
 
 			if (mask == 0) {
 				if(scaleFactor != 1 && !(y % 2))
@@ -95,7 +94,7 @@
 
 				mask = 0x80;
 			}
-			c = ((buffer & mask) != 0);
+			const byte c = ((buffer & mask) != 0);
 			if (c) {
 				if (dst->bytesPerPixel == 1)
 					ptr[x] = color;
@@ -107,8 +106,6 @@
 	}
 }
 
-const ScummFont g_scummfont;
-
 } // End of namespace Graphics
 
 #ifdef __PALM_OS__





More information about the Scummvm-git-logs mailing list