Bläddra i källkod

Moved FTLibrary handle into FontManager

Ivan Safrin 12 år sedan
förälder
incheckning
c2963c38be

+ 2 - 4
Core/Contents/Include/PolyFont.h

@@ -33,7 +33,7 @@ namespace Polycode {
 
 
 	class _PolyExport Font : public PolyBase {
 	class _PolyExport Font : public PolyBase {
 		public:
 		public:
-			Font(const String& fileName);
+			Font(const String& fileName, FT_Library FTLibrary);
 			virtual ~Font();
 			virtual ~Font();
 			
 			
 			FT_Face getFace();
 			FT_Face getFace();
@@ -47,9 +47,7 @@ namespace Polycode {
 		protected:
 		protected:
 		
 		
 			String fileName;
 			String fileName;
-			String fontName;
-		
-            FT_Library FTLibrary;        
+			String fontName;		
 			unsigned char *buffer;
 			unsigned char *buffer;
 			bool valid;
 			bool valid;
 			FT_Face ftFace;
 			FT_Face ftFace;

+ 3 - 0
Core/Contents/Include/PolyFontManager.h

@@ -25,6 +25,8 @@ THE SOFTWARE.
 #include "PolyGlobals.h"
 #include "PolyGlobals.h"
 #include "PolyString.h"
 #include "PolyString.h"
 #include <vector>
 #include <vector>
+#include "ft2build.h"
+#include FT_FREETYPE_H
 
 
 namespace Polycode {
 namespace Polycode {
 
 
@@ -67,6 +69,7 @@ namespace Polycode {
 		
 		
 	private:
 	private:
 		
 		
+        FT_Library FTLibrary;        
 		std::vector <FontEntry> fonts;
 		std::vector <FontEntry> fonts;
 		
 		
 	};
 	};

+ 1 - 4
Core/Contents/Source/PolyFont.cpp

@@ -26,11 +26,9 @@
 
 
 using namespace Polycode;
 using namespace Polycode;
 
 
-Font::Font(const String& fileName) {
+Font::Font(const String& fileName, FT_Library FTLibrary) {
 
 
 	this->fileName = fileName;
 	this->fileName = fileName;
-
-	FT_Init_FreeType(&FTLibrary);
 	
 	
 	loaded = false;
 	loaded = false;
 	buffer = NULL;
 	buffer = NULL;
@@ -78,7 +76,6 @@ Font::~Font() {
 	if(buffer) {
 	if(buffer) {
 		free(buffer);
 		free(buffer);
 	}
 	}
-    FT_Done_FreeType(FTLibrary);
 }
 }
 
 
 FT_Face Font::getFace() {
 FT_Face Font::getFace() {

+ 3 - 2
Core/Contents/Source/PolyFontManager.cpp

@@ -26,7 +26,7 @@
 using namespace Polycode;
 using namespace Polycode;
 
 
 FontManager::FontManager() {
 FontManager::FontManager() {
-	
+    FT_Init_FreeType(&FTLibrary);	
 }
 }
 
 
 FontManager::~FontManager() {
 FontManager::~FontManager() {
@@ -35,6 +35,7 @@ FontManager::~FontManager() {
 		delete entry.font;
 		delete entry.font;
 	}
 	}
 	fonts.clear();
 	fonts.clear();
+    FT_Done_FreeType(FTLibrary);    
 }
 }
 
 
 unsigned int FontManager::getNumFonts() const {
 unsigned int FontManager::getNumFonts() const {
@@ -63,7 +64,7 @@ void FontManager::removeFontEntry(FontEntry *entry, bool deleteFont) {
 }
 }
 
 
 void FontManager::registerFont(const String& fontName, const String& fontPath) {
 void FontManager::registerFont(const String& fontName, const String& fontPath) {
-	Font *font = new Font(fontPath);
+	Font *font = new Font(fontPath, FTLibrary);
 	if(font->loaded) {
 	if(font->loaded) {
 		FontEntry newEntry;
 		FontEntry newEntry;
 		newEntry.font = font;
 		newEntry.font = font;