Browse Source

Fixed anjo's freeing issues & hopefully padding works

Bart van Strien 15 years ago
parent
commit
b3799b52e6
2 changed files with 20 additions and 16 deletions
  1. 1 1
      platform/unix/debian
  2. 19 15
      src/modules/font/GlyphData.cpp

+ 1 - 1
platform/unix/debian

@@ -4,7 +4,7 @@ Section: games
 Priority: optional
 Priority: optional
 Architecture: %ARCHITECTURE%
 Architecture: %ARCHITECTURE%
 Essential: no
 Essential: no
-Depends: libdevil1c2, libfreetype6, libgl1-mesa-glx, liblua5.1-0, libphysfs-1.0-0, libsdl1.2debian, libopenal1, libogg0, libvorbis0a, libvorbisfile3, libmodplug0c2, libmpg123-0
+Depends: libdevil1c2, libfreetype6, libgl1-mesa-glx, liblua5.1-0, libphysfs1, libsdl1.2debian, libopenal1, libogg0, libvorbis0a, libvorbisfile3, libmodplug0c2, libmpg123-0
 Installed-Size: %INSTALLSIZE%
 Installed-Size: %INSTALLSIZE%
 Maintainer: Bart van Strien [[email protected]]
 Maintainer: Bart van Strien [[email protected]]
 Provides: love
 Provides: love

+ 19 - 15
src/modules/font/GlyphData.cpp

@@ -1,14 +1,14 @@
 /**
 /**
 * Copyright (c) 2006-2010 LOVE Development Team
 * Copyright (c) 2006-2010 LOVE Development Team
-* 
+*
 * This software is provided 'as-is', without any express or implied
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
 * arising from the use of this software.
-* 
+*
 * Permission is granted to anyone to use this software for any purpose,
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * freely, subject to the following restrictions:
-* 
+*
 * 1. The origin of this software must not be misrepresented; you must not
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    in a product, an acknowledgment in the product documentation would be
@@ -20,22 +20,24 @@
 
 
 #include "GlyphData.h"
 #include "GlyphData.h"
 
 
+#include <iostream>
+
 namespace love
 namespace love
 {
 {
 namespace font
 namespace font
 {
 {
 
 
 	GlyphData::GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, GlyphData::Format f)
 	GlyphData::GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, GlyphData::Format f)
-		: glyph(glyph), metrics(glyphMetrics), format(f), padded(false)
+		: glyph(glyph), metrics(glyphMetrics), format(f), padded(false), data(0)
 	{
 	{
-		if (getWidth() && getHeight()) {
+		if (metrics.width && metrics.height) {
 			switch (f) {
 			switch (f) {
 				case GlyphData::FORMAT_LUMINOSITY_ALPHA:
 				case GlyphData::FORMAT_LUMINOSITY_ALPHA:
-					data = new unsigned char[getWidth() * getHeight() * 2];
+					data = new unsigned char[metrics.width * metrics.height * 2];
 					break;
 					break;
 				case GlyphData::FORMAT_RGBA:
 				case GlyphData::FORMAT_RGBA:
 				default:
 				default:
-					data = new unsigned char[getWidth() * getHeight() * 4];
+					data = new unsigned char[metrics.width * metrics.height * 4];
 					break;
 					break;
 			}
 			}
 		}
 		}
@@ -62,7 +64,7 @@ namespace font
 				return getWidth() * getHeight() * 4;
 				return getWidth() * getHeight() * 4;
 				break;
 				break;
 		}
 		}
-		
+
 	}
 	}
 
 
 	int GlyphData::getHeight() const
 	int GlyphData::getHeight() const
@@ -74,7 +76,7 @@ namespace font
 	{
 	{
 		return (padded ? getPaddedWidth() : metrics.width);
 		return (padded ? getPaddedWidth() : metrics.width);
 	}
 	}
-	
+
 	int GlyphData::getAdvance() const
 	int GlyphData::getAdvance() const
 	{
 	{
 		return metrics.advance;
 		return metrics.advance;
@@ -109,14 +111,16 @@ namespace font
 	{
 	{
 		return this->getBearingY();
 		return this->getBearingY();
 	}
 	}
-	
+
 	GlyphData::Format GlyphData::getFormat() const
 	GlyphData::Format GlyphData::getFormat() const
 	{
 	{
 		return format;
 		return format;
 	}
 	}
-	
+
 	void GlyphData::pad()
 	void GlyphData::pad()
 	{
 	{
+		if (data == 0)
+			return;
 		int w = getWidth();
 		int w = getWidth();
 		int h = getHeight();
 		int h = getHeight();
 		int pw = next_p2(w);
 		int pw = next_p2(w);
@@ -155,22 +159,22 @@ namespace font
 		data = d;
 		data = d;
 		padded = true;
 		padded = true;
 	}
 	}
-	
+
 	bool GlyphData::isPadded() const
 	bool GlyphData::isPadded() const
 	{
 	{
 		return padded;
 		return padded;
 	}
 	}
-	
+
 	int GlyphData::getPaddedWidth() const
 	int GlyphData::getPaddedWidth() const
 	{
 	{
 		return next_p2(metrics.width);
 		return next_p2(metrics.width);
 	}
 	}
-	
+
 	int GlyphData::getPaddedHeight() const
 	int GlyphData::getPaddedHeight() const
 	{
 	{
 		return next_p2(metrics.height);
 		return next_p2(metrics.height);
 	}
 	}
-	
+
 	inline int GlyphData::next_p2(int num) const
 	inline int GlyphData::next_p2(int num) const
 	{
 	{
 		int powered = 2;
 		int powered = 2;