[Scummvm-cvs-logs] scummvm master -> a79f529f4ca2d027fb9355ad481a28fd6752b2b3

lordhoto lordhoto at gmail.com
Fri Jul 1 21:58:52 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
fa5f8dc703 GRAPHICS: Rename NewFont to BdfFont.
a79f529f4c GRAPHICS: Fix possible memory leak in BdfFont code.


Commit: fa5f8dc7031fb8d96a0faaafa817403a46634096
    https://github.com/scummvm/scummvm/commit/fa5f8dc7031fb8d96a0faaafa817403a46634096
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-07-01T12:53:01-07:00

Commit Message:
GRAPHICS: Rename NewFont to BdfFont.

Changed paths:
    devtools/convbdf.c
    graphics/fonts/bdf.cpp
    graphics/fonts/bdf.h
    graphics/fonts/consolefont.cpp
    graphics/fonts/newfont.cpp
    graphics/fonts/newfont_big.cpp
    gui/ThemeEngine.cpp



diff --git a/devtools/convbdf.c b/devtools/convbdf.c
index 5484823..e465b77 100644
--- a/devtools/convbdf.c
+++ b/devtools/convbdf.c
@@ -890,7 +890,7 @@ int gen_c_source(struct font* pf, char *path) {
 
 	fprintf(ofp,
 			"/* Exported structure definition. */\n"
-			"static const FontDesc desc = {\n"
+			"static const BdfFontDesc desc = {\n"
 			"\t" "\"%s\",\n"
 			"\t" "%d,\n"
 			"\t" "%d,\n"
@@ -917,7 +917,7 @@ int gen_c_source(struct font* pf, char *path) {
 			pf->defaultchar);
 
 	fprintf(ofp, "\n" "#if !(defined(__GP32__))\n");
-	fprintf(ofp, "extern const NewFont g_sysfont(desc);\n");
+	fprintf(ofp, "extern const BdfFont g_sysfont(desc);\n");
 	fprintf(ofp, "#else\n");
 	fprintf(ofp, "DEFINE_FONT(g_sysfont)\n");
 	fprintf(ofp, "#endif\n");
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index ae1a7cc..0e396e4 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -29,23 +29,23 @@
 
 namespace Graphics {
 
-void free_font(NewFontData *pf);
+void free_font(BdfFontData *pf);
 
-NewFont::~NewFont() {
+BdfFont::~BdfFont() {
 	if (_font) {
 		free_font(_font);
 	}
 }
 
-int NewFont::getFontHeight() const {
+int BdfFont::getFontHeight() const {
 	return _desc.height;
 }
 
-int NewFont::getMaxCharWidth() const {
+int BdfFont::getMaxCharWidth() const {
 	return _desc.maxwidth;
 }
 
-int NewFont::getCharWidth(byte chr) const {
+int BdfFont::getCharWidth(byte chr) const {
 	// If no width table is specified, return the maximum width
 	if (!_desc.width)
 		return _desc.maxwidth;
@@ -78,7 +78,7 @@ void drawCharIntern(byte *ptr, uint pitch, const bitmap_t *src, int h, int minX,
 	}
 }
 
-void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const {
+void BdfFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const uint32 color) const {
 	assert(dst != 0);
 
 	assert(_desc.bits != 0 && _desc.maxwidth <= 16);
@@ -135,7 +135,7 @@ void NewFont::drawChar(Surface *dst, byte chr, const int tx, const int ty, const
 
 /* builtin C-based proportional/fixed font structure */
 /* based on The Microwindows Project http://microwindows.org */
-struct NewFontData {
+struct BdfFontData {
 	char          *name;       /* font name */
 	int           maxwidth;    /* max width in pixels */
 	int           height;      /* height in pixels */
@@ -166,13 +166,13 @@ struct NewFontData {
 int start_char = 0;
 int limit_char = 255;
 
-NewFontData *bdf_read_font(Common::SeekableReadStream &fp);
-int bdf_read_header(Common::SeekableReadStream &fp, NewFontData *pf);
-int bdf_read_bitmaps(Common::SeekableReadStream &fp, NewFontData *pf);
+BdfFontData *bdf_read_font(Common::SeekableReadStream &fp);
+int bdf_read_header(Common::SeekableReadStream &fp, BdfFontData *pf);
+int bdf_read_bitmaps(Common::SeekableReadStream &fp, BdfFontData *pf);
 char *bdf_getline(Common::SeekableReadStream &fp, char *buf, int len);
 bitmap_t bdf_hexval(unsigned char *buf);
 
-void free_font(NewFontData *pf) {
+void free_font(BdfFontData *pf) {
 	if (!pf)
 		return;
 	free(pf->name);
@@ -185,11 +185,11 @@ void free_font(NewFontData *pf) {
 }
 
 /* build incore structure from .bdf file*/
-NewFontData *bdf_read_font(Common::SeekableReadStream &fp) {
-	NewFontData *pf;
+BdfFontData *bdf_read_font(Common::SeekableReadStream &fp) {
+	BdfFontData *pf;
 	uint32 pos = fp.pos();
 
-	pf = (NewFontData *)calloc(1, sizeof(NewFontData));
+	pf = (BdfFontData *)calloc(1, sizeof(BdfFontData));
 	if (!pf)
 		goto errout;
 
@@ -213,7 +213,7 @@ errout:
 }
 
 /* read bdf font header information, return 0 on error*/
-int bdf_read_header(Common::SeekableReadStream &fp, NewFontData *pf) {
+int bdf_read_header(Common::SeekableReadStream &fp, BdfFontData *pf) {
 	int encoding = 0;
 	int nchars = 0, maxwidth, maxheight;
 	int firstchar = 65535;
@@ -358,7 +358,7 @@ int bdf_read_header(Common::SeekableReadStream &fp, NewFontData *pf) {
 }
 
 /* read bdf font bitmaps, return 0 on error*/
-int bdf_read_bitmaps(Common::SeekableReadStream &fp, NewFontData *pf) {
+int bdf_read_bitmaps(Common::SeekableReadStream &fp, BdfFontData *pf) {
 	long ofs = 0;
 	int maxwidth = 0;
 	int i, k, encoding = 0, width = 0;
@@ -590,14 +590,14 @@ bitmap_t bdf_hexval(unsigned char *buf) {
 	return val;
 }
 
-NewFont *NewFont::loadFont(Common::SeekableReadStream &stream) {
-	NewFontData *data = bdf_read_font(stream);
+BdfFont *BdfFont::loadFont(Common::SeekableReadStream &stream) {
+	BdfFontData *data = bdf_read_font(stream);
 	if (!data || stream.err()) {
 		free_font(data);
 		return 0;
 	}
 
-	FontDesc desc;
+	BdfFontDesc desc;
 	desc.name = data->name;
 	desc.maxwidth = data->maxwidth;
 	desc.height = data->height;
@@ -615,10 +615,10 @@ NewFont *NewFont::loadFont(Common::SeekableReadStream &stream) {
 	desc.defaultchar = data->defaultchar;
 	desc.bits_size = data->bits_size;
 
-	return new NewFont(desc, data);
+	return new BdfFont(desc, data);
 }
 
-bool NewFont::cacheFontData(const NewFont &font, const Common::String &filename) {
+bool BdfFont::cacheFontData(const BdfFont &font, const Common::String &filename) {
 	Common::DumpFile cacheFile;
 	if (!cacheFile.open(filename)) {
 		warning("Couldn't open file '%s' for writing", filename.c_str());
@@ -674,14 +674,14 @@ bool NewFont::cacheFontData(const NewFont &font, const Common::String &filename)
 	return !cacheFile.err();
 }
 
-NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
-	NewFont *font = 0;
+BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) {
+	BdfFont *font = 0;
 
-	NewFontData *data = (NewFontData *)malloc(sizeof(NewFontData));
+	BdfFontData *data = (BdfFontData *)malloc(sizeof(BdfFontData));
 	if (!data)
 		return 0;
 
-	memset(data, 0, sizeof(NewFontData));
+	memset(data, 0, sizeof(BdfFontData));
 
 	data->maxwidth = stream.readUint16BE();
 	data->height = stream.readUint16BE();
@@ -761,7 +761,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
 		return 0;
 	}
 
-	FontDesc desc;
+	BdfFontDesc desc;
 	desc.name = data->name;
 	desc.maxwidth = data->maxwidth;
 	desc.height = data->height;
@@ -779,7 +779,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
 	desc.defaultchar = data->defaultchar;
 	desc.bits_size = data->bits_size;
 
-	font = new NewFont(desc, data);
+	font = new BdfFont(desc, data);
 	if (!font) {
 		free(data->bits);
 		free(data->offset);
diff --git a/graphics/fonts/bdf.h b/graphics/fonts/bdf.h
index db2c746..31c009e 100644
--- a/graphics/fonts/bdf.h
+++ b/graphics/fonts/bdf.h
@@ -43,7 +43,7 @@ struct BBX {
 
 /* builtin C-based proportional/fixed font structure */
 /* based on The Microwindows Project http://microwindows.org */
-struct FontDesc {
+struct BdfFontDesc {
 	const char          *name;                  /* font name */
 	int                 maxwidth;               /* max width in pixels */
 	int                 height;                 /* height in pixels */
@@ -59,16 +59,16 @@ struct FontDesc {
 	long                bits_size;              /* # words of bitmap_t bits */
 };
 
-struct NewFontData;
+struct BdfFontData;
 
-class NewFont : public Font {
+class BdfFont : public Font {
 protected:
-	FontDesc _desc;
-	NewFontData *_font;
+	BdfFontDesc _desc;
+	BdfFontData *_font;
 
 public:
-	NewFont(const FontDesc &desc, NewFontData *font = 0) : _desc(desc), _font(font) {}
-	~NewFont();
+	BdfFont(const BdfFontDesc &desc, BdfFontData *font = 0) : _desc(desc), _font(font) {}
+	~BdfFont();
 
 	virtual int getFontHeight() const;
 	virtual int getMaxCharWidth() const;
@@ -76,19 +76,19 @@ public:
 	virtual int getCharWidth(byte chr) const;
 	virtual void drawChar(Surface *dst, byte chr, int x, int y, uint32 color) const;
 
-	static NewFont *loadFont(Common::SeekableReadStream &stream);
-	static bool cacheFontData(const NewFont &font, const Common::String &filename);
-	static NewFont *loadFromCache(Common::SeekableReadStream &stream);
+	static BdfFont *loadFont(Common::SeekableReadStream &stream);
+	static bool cacheFontData(const BdfFont &font, const Common::String &filename);
+	static BdfFont *loadFromCache(Common::SeekableReadStream &stream);
 };
 
 #define DEFINE_FONT(n) \
-	const NewFont *n = 0;   \
+	const BdfFont *n = 0;   \
 	void create_##n() { \
-		n = new NewFont(desc);  \
+		n = new BdfFont(desc);  \
 	}
 
 #define FORWARD_DECLARE_FONT(n) \
-	extern const NewFont *n; \
+	extern const BdfFont *n; \
 	extern void create_##n()
 
 #define INIT_FONT(n) \
diff --git a/graphics/fonts/consolefont.cpp b/graphics/fonts/consolefont.cpp
index 817cdb4..5b47683 100644
--- a/graphics/fonts/consolefont.cpp
+++ b/graphics/fonts/consolefont.cpp
@@ -5635,7 +5635,7 @@ static const unsigned long _sysfont_offset[] = {
 };
 
 /* Exported structure definition. */
-static const FontDesc desc = {
+static const BdfFontDesc desc = {
 	"5x8-L1",
 	5,
 	8,
diff --git a/graphics/fonts/newfont.cpp b/graphics/fonts/newfont.cpp
index 5a68617..f02baba 100644
--- a/graphics/fonts/newfont.cpp
+++ b/graphics/fonts/newfont.cpp
@@ -7419,7 +7419,7 @@ static const unsigned long _sysfont_offset[] = {
 };
 
 /* Exported structure definition. */
-static const FontDesc desc = {
+static const BdfFontDesc desc = {
 	"clR6x12-L1",
 	6,
 	12,
diff --git a/graphics/fonts/newfont_big.cpp b/graphics/fonts/newfont_big.cpp
index a37eaf7..59c54a4 100644
--- a/graphics/fonts/newfont_big.cpp
+++ b/graphics/fonts/newfont_big.cpp
@@ -5523,7 +5523,7 @@ static const BBX _sysfont_bbx[] = {
 };
 
 /* Exported structure definition. */
-static const FontDesc desc = {
+static const BdfFontDesc desc = {
 	"helvB12-L1",
 	13,
 	14,
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 3f2e127..4a2e0a7 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1395,7 +1395,7 @@ const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &fil
 	if (_themeArchive)
 		stream = _themeArchive->createReadStreamForMember(filename);
 	if (stream) {
-		font = Graphics::NewFont::loadFont(*stream);
+		font = Graphics::BdfFont::loadFont(*stream);
 		delete stream;
 	}
 
@@ -1409,7 +1409,7 @@ const Graphics::Font *ThemeEngine::loadCachedFontFromArchive(const Common::Strin
 	if (_themeArchive)
 		stream = _themeArchive->createReadStreamForMember(filename);
 	if (stream) {
-		font = Graphics::NewFont::loadFromCache(*stream);
+		font = Graphics::BdfFont::loadFromCache(*stream);
 		delete stream;
 	}
 
@@ -1423,7 +1423,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
 
 	if (!cacheFilename.empty()) {
 		if (fontFile.open(cacheFilename)) {
-			font = Graphics::NewFont::loadFromCache(fontFile);
+			font = Graphics::BdfFont::loadFromCache(fontFile);
 		}
 
 		if (font)
@@ -1435,7 +1435,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
 
 	// normal open
 	if (fontFile.open(filename)) {
-		font = Graphics::NewFont::loadFont(fontFile);
+		font = Graphics::BdfFont::loadFont(fontFile);
 	}
 
 	if (!font) {
@@ -1444,7 +1444,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
 
 	if (font) {
 		if (!cacheFilename.empty()) {
-			if (!Graphics::NewFont::cacheFontData(*(const Graphics::NewFont *)font, cacheFilename)) {
+			if (!Graphics::BdfFont::cacheFontData(*(const Graphics::BdfFont *)font, cacheFilename)) {
 				warning("Couldn't create cache file for font '%s'", filename.c_str());
 			}
 		}


Commit: a79f529f4ca2d027fb9355ad481a28fd6752b2b3
    https://github.com/scummvm/scummvm/commit/a79f529f4ca2d027fb9355ad481a28fd6752b2b3
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-07-01T12:55:21-07:00

Commit Message:
GRAPHICS: Fix possible memory leak in BdfFont code.

Changed paths:
    graphics/fonts/bdf.cpp



diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp
index 0e396e4..b7d0f77 100644
--- a/graphics/fonts/bdf.cpp
+++ b/graphics/fonts/bdf.cpp
@@ -177,6 +177,7 @@ void free_font(BdfFontData *pf) {
 		return;
 	free(pf->name);
 	free(pf->facename);
+	free(pf->copyright);
 	free(pf->bits);
 	free(pf->offset);
 	free(pf->width);






More information about the Scummvm-git-logs mailing list