2
0
Эх сурвалжийг харах

Removed font manager, fonts now managed by ResourceManager

Ivan Safrin 9 жил өмнө
parent
commit
6c95519d53

+ 0 - 8
build/osx/PolycodeCore/PolycodeCore.xcodeproj/project.pbxproj

@@ -29,7 +29,6 @@
 		8A8652431B72865C009F94DD /* PolyEventHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651F81B72865C009F94DD /* PolyEventHandler.h */; };
 		8A8652441B72865C009F94DD /* PolyFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651F91B72865C009F94DD /* PolyFont.h */; };
 		8A8652451B72865C009F94DD /* PolyFontGlyphSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651FA1B72865C009F94DD /* PolyFontGlyphSheet.h */; };
-		8A8652461B72865C009F94DD /* PolyFontManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651FB1B72865C009F94DD /* PolyFontManager.h */; };
 		8A8652471B72865C009F94DD /* PolyGlobals.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651FC1B72865C009F94DD /* PolyGlobals.h */; };
 		8A8652481B72865C009F94DD /* PolyGPUDrawBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651FD1B72865C009F94DD /* PolyGPUDrawBuffer.h */; };
 		8A8652491B72865C009F94DD /* PolyImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A8651FE1B72865C009F94DD /* PolyImage.h */; };
@@ -106,7 +105,6 @@
 		8A8652E51B72867F009F94DD /* PolyEventHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86529A1B72867E009F94DD /* PolyEventHandler.cpp */; };
 		8A8652E61B72867F009F94DD /* PolyFont.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86529B1B72867E009F94DD /* PolyFont.cpp */; };
 		8A8652E71B72867F009F94DD /* PolyFontGlyphSheet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86529C1B72867E009F94DD /* PolyFontGlyphSheet.cpp */; };
-		8A8652E81B72867F009F94DD /* PolyFontManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86529D1B72867E009F94DD /* PolyFontManager.cpp */; };
 		8A8652E91B72867F009F94DD /* PolyGPUDrawBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86529E1B72867E009F94DD /* PolyGPUDrawBuffer.cpp */; };
 		8A8652EA1B72867F009F94DD /* PolyImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A86529F1B72867E009F94DD /* PolyImage.cpp */; };
 		8A8652EB1B72867F009F94DD /* PolyInputEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A8652A01B72867E009F94DD /* PolyInputEvent.cpp */; };
@@ -193,7 +191,6 @@
 		8A8651F81B72865C009F94DD /* PolyEventHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyEventHandler.h; path = ../../../include/polycode/core/PolyEventHandler.h; sourceTree = "<group>"; };
 		8A8651F91B72865C009F94DD /* PolyFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyFont.h; path = ../../../include/polycode/core/PolyFont.h; sourceTree = "<group>"; };
 		8A8651FA1B72865C009F94DD /* PolyFontGlyphSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyFontGlyphSheet.h; path = ../../../include/polycode/core/PolyFontGlyphSheet.h; sourceTree = "<group>"; };
-		8A8651FB1B72865C009F94DD /* PolyFontManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyFontManager.h; path = ../../../include/polycode/core/PolyFontManager.h; sourceTree = "<group>"; };
 		8A8651FC1B72865C009F94DD /* PolyGlobals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyGlobals.h; path = ../../../include/polycode/core/PolyGlobals.h; sourceTree = "<group>"; };
 		8A8651FD1B72865C009F94DD /* PolyGPUDrawBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyGPUDrawBuffer.h; path = ../../../include/polycode/core/PolyGPUDrawBuffer.h; sourceTree = "<group>"; };
 		8A8651FE1B72865C009F94DD /* PolyImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyImage.h; path = ../../../include/polycode/core/PolyImage.h; sourceTree = "<group>"; };
@@ -270,7 +267,6 @@
 		8A86529A1B72867E009F94DD /* PolyEventHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyEventHandler.cpp; path = ../../../src/core/PolyEventHandler.cpp; sourceTree = "<group>"; };
 		8A86529B1B72867E009F94DD /* PolyFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyFont.cpp; path = ../../../src/core/PolyFont.cpp; sourceTree = "<group>"; };
 		8A86529C1B72867E009F94DD /* PolyFontGlyphSheet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyFontGlyphSheet.cpp; path = ../../../src/core/PolyFontGlyphSheet.cpp; sourceTree = "<group>"; };
-		8A86529D1B72867E009F94DD /* PolyFontManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyFontManager.cpp; path = ../../../src/core/PolyFontManager.cpp; sourceTree = "<group>"; };
 		8A86529E1B72867E009F94DD /* PolyGPUDrawBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyGPUDrawBuffer.cpp; path = ../../../src/core/PolyGPUDrawBuffer.cpp; sourceTree = "<group>"; };
 		8A86529F1B72867E009F94DD /* PolyImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyImage.cpp; path = ../../../src/core/PolyImage.cpp; sourceTree = "<group>"; };
 		8A8652A01B72867E009F94DD /* PolyInputEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyInputEvent.cpp; path = ../../../src/core/PolyInputEvent.cpp; sourceTree = "<group>"; };
@@ -380,7 +376,6 @@
 				8A86529A1B72867E009F94DD /* PolyEventHandler.cpp */,
 				8A86529B1B72867E009F94DD /* PolyFont.cpp */,
 				8A86529C1B72867E009F94DD /* PolyFontGlyphSheet.cpp */,
-				8A86529D1B72867E009F94DD /* PolyFontManager.cpp */,
 				8A86529E1B72867E009F94DD /* PolyGPUDrawBuffer.cpp */,
 				8A86529F1B72867E009F94DD /* PolyImage.cpp */,
 				8A8652A01B72867E009F94DD /* PolyInputEvent.cpp */,
@@ -472,7 +467,6 @@
 				8A8651F81B72865C009F94DD /* PolyEventHandler.h */,
 				8A8651F91B72865C009F94DD /* PolyFont.h */,
 				8A8651FA1B72865C009F94DD /* PolyFontGlyphSheet.h */,
-				8A8651FB1B72865C009F94DD /* PolyFontManager.h */,
 				8A8651FC1B72865C009F94DD /* PolyGlobals.h */,
 				8A8651FD1B72865C009F94DD /* PolyGPUDrawBuffer.h */,
 				8A8651FE1B72865C009F94DD /* PolyImage.h */,
@@ -545,7 +539,6 @@
 				8A86526D1B72865C009F94DD /* PolyServerWorld.h in Headers */,
 				8A825F231B829BA70039E823 /* PolyPAAudioInterface.h in Headers */,
 				8A86524F1B72865C009F94DD /* PolyMaterialManager.h in Headers */,
-				8A8652461B72865C009F94DD /* PolyFontManager.h in Headers */,
 				8A8652891B72866C009F94DD /* tinyxml.h in Headers */,
 				8A8652351B72865C009F94DD /* PolyCamera.h in Headers */,
 				8A86524E1B72865C009F94DD /* PolyMaterial.h in Headers */,
@@ -772,7 +765,6 @@
 				8A8653051B72867F009F94DD /* PolySceneManager.cpp in Sources */,
 				8A8652FD1B72867F009F94DD /* PolyResource.cpp in Sources */,
 				8A8653111B72867F009F94DD /* PolyString.cpp in Sources */,
-				8A8652E81B72867F009F94DD /* PolyFontManager.cpp in Sources */,
 				8A8652D91B72867F009F94DD /* PolyClient.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

+ 0 - 1
include/Polycode.h

@@ -54,7 +54,6 @@
 #include "polycode/core/PolyLabel.h"
 #include "polycode/core/PolyFont.h"
 #include "polycode/core/PolyFontGlyphSheet.h"
-#include "polycode/core/PolyFontManager.h"
 #include "polycode/core/PolyTexture.h"
 #include "polycode/core/PolyMaterial.h"
 #include "polycode/core/PolyMesh.h"

+ 0 - 9
include/polycode/core/PolyCoreServices.h

@@ -32,7 +32,6 @@ namespace Polycode {
 	class PolycodeModule;
 	class Renderer;
 	class Config;
-	class FontManager;
 	class SceneManager;
 	class TimerManager;
 	class TweenManager;
@@ -131,13 +130,6 @@ namespace Polycode {
 			* @see SoundManager
 			*/																								
 			SoundManager *getSoundManager();
-			
-			/**
-			* Returns the font manager. The font manager is responsible for loading and managing fonts.
-			* @return Font Manager
-			* @see FontManager
-			*/																											
-			FontManager *getFontManager();
 
 			/**
 			* Returns the logger. It can log messages and broadcast them to listeners.
@@ -175,7 +167,6 @@ namespace Polycode {
 			TweenManager *tweenManager;
 			ResourceManager *resourceManager;
 			SoundManager *soundManager;
-			FontManager *fontManager;
 			Renderer *renderer;
 	};
     

+ 2 - 1
include/polycode/core/PolyFont.h

@@ -27,12 +27,13 @@ THE SOFTWARE.
 #include FT_FREETYPE_H
 #undef generic
 #include "polycode/core/PolyString.h"
+#include "polycode/core/PolyResource.h"
 
 namespace Polycode {
 	
 	class String;
 
-	class _PolyExport Font : public PolyBase {
+	class _PolyExport Font : public Resource {
 		public:
 			Font(const String& fileName, FT_Library FTLibrary);
 			virtual ~Font();

+ 0 - 94
include/polycode/core/PolyFontManager.h

@@ -1,94 +0,0 @@
-/*
-Copyright (C) 2011 by Ivan Safrin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#pragma once
-#include "polycode/core/PolyGlobals.h"
-#include "polycode/core/PolyString.h"
-#include <vector>
-#define generic GenericFreetypeLibrary
-#include "ft2build.h"
-#include FT_FREETYPE_H
-#undef generic
-
-namespace Polycode {
-
-	class Font;
-
-	class FontEntry {
-	public:
-		String fontName;
-		Font *font;
-	};
-	
-	/**
-	* Manages fonts. The font manager shoudl only be accessed via the CoreServices singleton.
-	*/
-	class _PolyExport FontManager : public PolyBase {
-	public:
-		FontManager();
-		~FontManager();
-
-		/**
-		* Loads and registers a new font for use.
-		* @param fontName Name to register the font as.
-		* @param fontPath Filename of the font to load.
-		*/
-		void registerFont(const String& fontName, const String& fontPath);
-		
-		/**
-		* Retuns a font based on the registerd font name.
-		* @param fontName Name of registered font name.
-		* @return The font instance associated with the font name or NULL if one doesn't exist.
-		*/		
-		Font *getFontByName(const String& fontName);
-		
-        /**
-         * Returns number of registered fonts.
-         */
-		unsigned int getNumFonts() const;
-        
-        /**
-         * Returns the font entry by specified index or NULL if index is invalid.
-         */
-		FontEntry *getFontEntryByIndex(const unsigned int index);
-
-        /**
-         * Returns the font entry based on the font path or NULL if no fonts are registered with the specified path.
-         */
-		FontEntry *getFontEntryByFontPath(const String &fontPath);
-		
-        /**
-         * Removes the font entry from manager and optionally delets the associated Font.
-         * @param entry FontEntry to remove.
-
-         */
-		void removeFontEntry(FontEntry *entry, bool deleteFont);
-		
-	private:
-		
-        FT_Library FTLibrary;        
-		std::vector <FontEntry> fonts;
-		
-	};
-	
-}

+ 2 - 1
include/polycode/core/PolyMesh.h

@@ -27,6 +27,7 @@ THE SOFTWARE.
 #include "polycode/core/PolyVector3.h"
 #include "polycode/core/PolyVector2.h"
 #include "polycode/core/PolyCore.h"
+#include "polycode/core/PolyResource.h"
 #include <vector>
 
 class CoreFile;
@@ -57,7 +58,7 @@ namespace Polycode {
 	/**
 	*  A mesh comprised of vertices. When data in the mesh changes, arrayDirtyMap must be set to true for the appropriate array types (color, position, normal, etc). Available types are defined in RenderDataArray.
 	*/
-	class _PolyExport Mesh : public PolyBase {
+	class _PolyExport Mesh : public Resource {
 		public:
 		
 			

+ 2 - 1
include/polycode/core/PolyResource.h

@@ -59,7 +59,8 @@ namespace Polycode {
 			static const int RESOURCE_CUBEMAP = 6;
 			static const int RESOURCE_SPRITE = 7;
 			static const int RESOURCE_ENTITY_INSTANCE = 8;
-			
+            static const int RESOURCE_FONT = 9;
+        
 			bool reloadOnFileModify;
         
             static bool defaultReloadOnFileModify;

+ 11 - 0
include/polycode/core/PolyResourceManager.h

@@ -26,6 +26,11 @@ THE SOFTWARE.
 #include "polycode/core/PolyEventDispatcher.h"
 #include <vector>
 
+#define generic GenericFreetypeLibrary
+#include "ft2build.h"
+#include FT_FREETYPE_H
+#include FT_LCD_FILTER_H
+
 #define RESOURCE_CHECK_INTERVAL	2000
 
 namespace Polycode {
@@ -48,6 +53,9 @@ namespace Polycode {
         
             void loadResourcesFromFolder(const String &folder, bool recursive);
         
+            Resource *loadResource(const String &path);
+            Resource *loadResourceWithName(const String &path, const String &name);
+        
 			Resource *getResource(int resourceType, const String& resourceName) const;
             String getName();
             void setName(const String &name);
@@ -107,7 +115,10 @@ namespace Polycode {
     class _PolyExport FontResourceLoader : public ResourceLoader {
     public:
         FontResourceLoader();
+        ~FontResourceLoader();
         Resource *loadResource(const String &path, ResourcePool *targetPool);
+    private:
+        FT_Library FTLibrary;
     };
     
 	/**

+ 0 - 1
include/polycode/modules/ui/PolyUITextInput.h

@@ -24,7 +24,6 @@
 #include "polycode/core/PolyGlobals.h"
 #include "polycode/core/PolySceneLabel.h"
 #include "polycode/core/PolyScenePrimitive.h"
-#include "polycode/core/PolyFontManager.h"
 #include "polycode/core/PolyFont.h"
 #include "polycode/core/PolyEntity.h"
 #include "polycode/modules/ui/PolyUIEvent.h"

+ 1 - 1
lib

@@ -1 +1 @@
-Subproject commit 9b32b7c3003aa94145a3bfa2e819f8205d3d1469
+Subproject commit cd559f0ccaef1d97e5b8555eef20b0724a54e71b

+ 0 - 6
src/core/PolyCoreServices.cpp

@@ -29,7 +29,6 @@
 #include "polycode/core/PolyMaterialManager.h"
 #include "polycode/core/PolyRenderer.h"
 #include "polycode/core/PolyConfig.h"
-#include "polycode/core/PolyFontManager.h"
 #include "polycode/core/PolySceneManager.h"
 #include "polycode/core/PolyTimerManager.h"
 #include "polycode/core/PolyTweenManager.h"
@@ -75,9 +74,6 @@ TimerManager *CoreServices::getTimerManager() {
 	return timerManager;
 }
 
-FontManager *CoreServices::getFontManager() {
-	return fontManager;
-}
 
 Config *CoreServices::getConfig() {
 	return config;
@@ -97,7 +93,6 @@ CoreServices::CoreServices() : EventDispatcher() {
 	timerManager = new TimerManager();
 	tweenManager = new TweenManager();
 	soundManager = new SoundManager();
-	fontManager = new FontManager();
 }
 
 CoreServices::~CoreServices() {
@@ -107,7 +102,6 @@ CoreServices::~CoreServices() {
 	delete tweenManager;
 	delete resourceManager;
 	delete soundManager;
-	delete fontManager;
     delete logger;
     delete config;
     delete renderer;

+ 5 - 4
src/core/PolyFont.cpp

@@ -27,8 +27,7 @@
 
 using namespace Polycode;
 
-Font::Font(const String& fileName, FT_Library FTLibrary) {
-
+Font::Font(const String& fileName, FT_Library FTLibrary) : Resource(Resource::RESOURCE_FONT) {
 	this->fileName = fileName;
 	
 	loaded = false;
@@ -56,6 +55,8 @@ Font::Font(const String& fileName, FT_Library FTLibrary) {
 	} else {
 		Logger::log("Invalid font file specified (%s)\n", fileName.c_str());	
 	}
+    
+    setResourcePath(fileName);
 }
 
 String Font::getFontPath() {
@@ -63,11 +64,11 @@ String Font::getFontPath() {
 }
 
 void Font::setFontName(String fontName) {
-	this->fontName = fontName;
+    setResourceName(fontName);
 }
 
 String Font::getFontName() {
-	return fontName;
+    return getResourceName();
 }
 
 bool Font::isValid() const {

+ 0 - 104
src/core/PolyFontManager.cpp

@@ -1,104 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "polycode/core/PolyFontManager.h"
-#include "polycode/core/PolyFont.h"
-#include FT_LCD_FILTER_H
-
-using namespace Polycode;
-
-FontManager::FontManager() {
-    FT_Init_FreeType(&FTLibrary);
-    FT_Library_SetLcdFilter(FTLibrary, FT_LCD_FILTER_LIGHT);
-}
-
-FontManager::~FontManager() {
-	for(int i=0; i < fonts.size(); i++) {
-		FontEntry entry = fonts[i];
-		delete entry.font;
-	}
-	fonts.clear();
-    FT_Done_FreeType(FTLibrary);    
-}
-
-unsigned int FontManager::getNumFonts() const {
-	return fonts.size();
-}
-
-FontEntry *FontManager::getFontEntryByIndex(const unsigned int index) {
-	if(index < fonts.size()) {
-		return &fonts[index];
-	} else {
-		return NULL;
-	}
-}
-
-void FontManager::removeFontEntry(FontEntry *entry, bool deleteFont) {
-	for(int i=0; i < fonts.size(); i++) {
-		FontEntry *listEntry = &fonts[i];
-		if(listEntry == entry) {
-			if(deleteFont) {
-				delete listEntry->font;
-			}		
-			fonts.erase(fonts.begin()+i);
-			return;
-		}
-	}
-}
-
-void FontManager::registerFont(const String& fontName, const String& fontPath) {
-	Font *font = new Font(fontPath, FTLibrary);
-	if(font->loaded) {
-		FontEntry newEntry;
-		newEntry.font = font;
-		newEntry.fontName = fontName;
-		font->setFontName(fontName);
-		fonts.push_back(newEntry);
-	} else {
-		delete font;
-	}
-}
-
-FontEntry *FontManager::getFontEntryByFontPath(const String &fontPath) {
-	for(int i=0; i < fonts.size(); i++) {
-		FontEntry *entry = &fonts[i];
-		if(entry->font->getFontPath() == fontPath) {
-			return entry;
-		}
-	}
-	return NULL;
-}
-
-Font *FontManager::getFontByName(const String& fontName) {
-	for(int i=0; i < fonts.size(); i++) {
-		FontEntry entry = fonts[i];
-		if(entry.fontName == fontName)
-			return entry.font;
-	}
-	
-	if(fonts.size() > 0) {
-		FontEntry entry = fonts[0];
-		return entry.font;		
-	}
-	
-	return NULL;
-}

+ 5 - 4
src/core/PolyMesh.cpp

@@ -33,8 +33,8 @@ using std::vector;
 
 using namespace Polycode;
 
-Mesh::Mesh(const String& fileName)
-: vertexPositionArray(3, RenderDataArray::VERTEX_DATA_ARRAY),
+Mesh::Mesh(const String& fileName) : Resource(Resource::RESOURCE_MESH),
+vertexPositionArray(3, RenderDataArray::VERTEX_DATA_ARRAY),
 vertexColorArray(4, RenderDataArray::COLOR_DATA_ARRAY),
 vertexNormalArray(3, RenderDataArray::NORMAL_DATA_ARRAY),
 vertexTexCoordArray(2, RenderDataArray::TEXCOORD_DATA_ARRAY),
@@ -49,10 +49,11 @@ indexArray(RenderDataArray::INDEX_DATA_ARRAY)
     meshType = TRI_MESH;
     meshHasVertexBuffer = false;
     loadMesh(fileName);
+    setResourcePath(fileName);
 }
 
-Mesh::Mesh(int meshType)
-: vertexPositionArray(3, RenderDataArray::VERTEX_DATA_ARRAY),
+Mesh::Mesh(int meshType) : Resource(Resource::RESOURCE_MESH),
+vertexPositionArray(3, RenderDataArray::VERTEX_DATA_ARRAY),
 vertexColorArray(4, RenderDataArray::COLOR_DATA_ARRAY),
 vertexNormalArray(3, RenderDataArray::NORMAL_DATA_ARRAY),
 vertexTexCoordArray(2, RenderDataArray::TEXCOORD_DATA_ARRAY),

+ 51 - 9
src/core/PolyResourceManager.cpp

@@ -24,11 +24,11 @@
 #include "polycode/core/PolyCoreServices.h"
 #include "polycode/core/PolyCubemap.h"
 #include "polycode/core/PolyMaterialManager.h"
-#include "polycode/core/PolyFontManager.h"
 #include "polycode/core/PolyLogger.h"
 #include "polycode/core/PolyMaterial.h"
 #include "polycode/core/PolyShader.h"
 #include "polycode/core/PolyTexture.h"
+#include "polycode/core/PolyFont.h"
 #include "tinyxml.h"
 
 using std::vector;
@@ -148,7 +148,9 @@ void ResourcePool::loadResourcesFromFolderWithLoader(const String &folder, bool
                 newResource = loader->loadResource(resourceDir[i].fullPath, this);
             }
             if(newResource) {
-                newResource->setResourceName(resourceDir[i].name);
+                if(newResource->getResourceName() == "") {
+                    newResource->setResourceName(resourceDir[i].name);
+                }
                 newResource->setResourcePath(resourceDir[i].fullPath);
                 addResource(newResource);
             }
@@ -160,11 +162,43 @@ void ResourcePool::loadResourcesFromFolderWithLoader(const String &folder, bool
     }
 }
 
+Resource *ResourcePool::loadResource(const String &path) {
+    OSFileEntry entry(path, OSFileEntry::TYPE_FILE);
+    Resource *newResource = NULL;
+    for(int r = 0; r < Services()->getResourceManager()->getNumResourceLoaders(); r++) {
+        ResourceLoader *loader = Services()->getResourceManager()->getResourceLoaderAtIndex(r);
+        if(loader->canHandleExtension(entry.extension)) {
+            newResource = loader->loadResource(entry.fullPath, this);
+            if(newResource) {
+                newResource->setResourceName(entry.name);
+                newResource->setResourcePath(entry.fullPath);
+                addResource(newResource);
+                break;
+            }
+        }
+    }
+    return newResource;
+}
+
+Resource *ResourcePool::loadResourceWithName(const String &path, const String &name) {
+    OSFileEntry entry(path, OSFileEntry::TYPE_FILE);
+    Resource *newResource = NULL;
+    for(int r = 0; r < Services()->getResourceManager()->getNumResourceLoaders(); r++) {
+        ResourceLoader *loader = Services()->getResourceManager()->getResourceLoaderAtIndex(r);
+        if(loader->canHandleExtension(entry.extension)) {
+            newResource = loader->loadResource(entry.fullPath, this);
+            if(newResource) {
+                newResource->setResourceName(name);
+                newResource->setResourcePath(entry.fullPath);
+                addResource(newResource);
+                break;
+            }
+        }
+    }
+    return newResource;
+}
+
 void ResourcePool::loadResourcesFromFolder(const String &folder, bool recursive) {
-    
-    // need to do separate passes for each loader so that different types of resources load
-    // after each other
-    
     for(int r = 0; r < Services()->getResourceManager()->getNumResourceLoaders(); r++) {
         ResourceLoader *loader = Services()->getResourceManager()->getResourceLoaderAtIndex(r);
         loadResourcesFromFolderWithLoader(folder, recursive, loader, "");
@@ -321,15 +355,23 @@ Resource *ProgramResourceLoader::loadResource(const String &path, ResourcePool *
 }
 
 FontResourceLoader::FontResourceLoader() {
+    
+    FT_Init_FreeType(&FTLibrary);
+    FT_Library_SetLcdFilter(FTLibrary, FT_LCD_FILTER_LIGHT);
+    
     extensions.push_back("ttf");
     extensions.push_back("otf");
 }
 
+FontResourceLoader::~FontResourceLoader() {
+    FT_Done_FreeType(FTLibrary);
+}
+
 Resource *FontResourceLoader::loadResource(const String &path, ResourcePool *targetPool) {
     OSFileEntry entry = OSFileEntry(path, OSFileEntry::TYPE_FILE);
-    Services()->getFontManager()->registerFont(entry.nameWithoutExtension, path);
-    // TODO: make fonts resources, get rid of font manager
-    return NULL;
+    Font *font = new Font(path, FTLibrary);
+    font->setResourceName(entry.nameWithoutExtension);
+    return font;
 }
 
 void ResourceManager::handleEvent(Event *event) {

+ 5 - 2
src/core/PolySceneLabel.cpp

@@ -22,10 +22,10 @@
 
 #include "polycode/core/PolySceneLabel.h"
 #include "polycode/core/PolyCoreServices.h"
-#include "polycode/core/PolyFontManager.h"
 #include "polycode/core/PolyLabel.h"
 #include "polycode/core/PolyMesh.h"
 #include "polycode/core/PolyRenderer.h"
+#include "polycode/core/PolyResourceManager.h"
 #include "polycode/core/PolyMaterialManager.h"
 
 using namespace Polycode;
@@ -39,7 +39,10 @@ SceneLabel::SceneLabel(const String& text, int size, const String& fontName, int
 
     setMaterialByName("Unlit");
     
-	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size * CoreServices::getInstance()->getRenderer()->getBackingResolutionScaleX(), amode, premultiplyAlpha, backgroundColor, foregroundColor);
+    ResourcePool *pool = Services()->getResourceManager()->getGlobalPool();
+    Font *font = (Font*) pool->getResource(Resource::RESOURCE_FONT, fontName);
+    
+	label = new Label(font, text, size * CoreServices::getInstance()->getRenderer()->getBackingResolutionScaleX(), amode, premultiplyAlpha, backgroundColor, foregroundColor);
     
 	positionAtBaseline = SceneLabel::defaultPositionAtBaseline;
 	setAnchorPoint(SceneLabel::defaultAnchor);	

+ 1 - 1
src/core/PolySceneMesh.cpp

@@ -356,7 +356,7 @@ void SceneMesh::Render(GPUDrawBuffer *buffer) {
     drawCall.options.backfaceCull = backfaceCulled;
     drawCall.options.depthTest = depthTest;
     drawCall.options.depthWrite = depthWrite;
-
+    
     drawCall.mesh = mesh;
     drawCall.material = material;
     drawCall.shaderPasses = shaderPasses;

+ 5 - 4
src/ide/PolycodeFontEditor.cpp

@@ -37,7 +37,10 @@ PolycodeFontEditor::~PolycodeFontEditor() {
 
 bool PolycodeFontEditor::openFile(OSFileEntry filePath) {
 	
-	CoreServices::getInstance()->getFontManager()->registerFont(filePath.fullPath, filePath.fullPath);
+    
+    ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
+    
+    Resource *resource = globalPool->loadResourceWithName(filePath.fullPath, filePath.fullPath);
 		
 	anchor = new UIElement();
 	addChild(anchor);
@@ -70,9 +73,7 @@ bool PolycodeFontEditor::openFile(OSFileEntry filePath) {
 	
 	PolycodeEditor::openFile(filePath);
 	
-	// remove the font entry so it doesn't show up in project font lists
-	FontEntry *entry = 	CoreServices::getInstance()->getFontManager()->getFontEntryByFontPath(filePath.fullPath);
-	CoreServices::getInstance()->getFontManager()->removeFontEntry(entry, false);	
+    globalPool->removeResource(resource);
 	
 	return true;
 }

+ 4 - 4
src/ide/PolycodeIDEApp.cpp

@@ -63,7 +63,8 @@ core = new POLYCODE_CORE((PolycodeView*)view, 1100, 700,false,false, 0, 0,60, -1
 
     ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
     
-    CoreServices::getInstance()->getFontManager()->registerFont("sans", "Fonts/Lato-Semibold.ttf");
+    //TODO: this results in doubling "sans" in the font browsers, need to fix
+    globalPool->loadResourceWithName("Fonts/Lato-Semibold.ttf", "sans");
     
     core->addFileSource("archive", "default.pak");
     globalPool->loadResourcesFromFolder("default", true);
@@ -78,9 +79,8 @@ core = new POLYCODE_CORE((PolycodeView*)view, 1100, 700,false,false, 0, 0,60, -1
     */
 
     globalPool->loadResourcesFromFolder("Materials", true);
-			
-	CoreServices::getInstance()->getFontManager()->registerFont("section", "Fonts/Lato-Black.ttf");
-    
+    globalPool->loadResourceWithName("Fonts/Lato-Black.ttf", "section");
+	
 
 	CoreServices::getInstance()->getMaterialManager()->setTextureFilteringMode(Texture::FILTERING_LINEAR);
 	

+ 15 - 6
src/ide/PolycodeProjectEditor.cpp

@@ -60,20 +60,29 @@ ProjectFontEntry::ProjectFontEntry(String fontPath, String fontName) : UIElement
 	addFocusChild(fontFileLabel);
 	fontFileLabel->setPosition(140, 3);
 	
-	CoreServices::getInstance()->getFontManager()->registerFont(fontName, fontPath);
+    ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
+    globalPool->loadResourceWithName(fontPath, fontName);
 }
 
 void ProjectFontEntry::handleEvent(Event *event) {
+    
+    ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
+    
 	if(event->getDispatcher() == fontNameInput && event->getEventCode() == UIEvent::CHANGE_EVENT && event->getEventType() == "UIEvent") {
-		FontEntry *entry = CoreServices::getInstance()->getFontManager()->getFontEntryByFontPath(fontPath);
-		if(entry) {
-			entry->fontName = fontNameInput->getText();
+        Font *font = (Font*) globalPool->getResourceByPath(fontPath);
+		if(font) {
+			font->setResourceName(fontNameInput->getText());
 		}
 	}
 	
 	if(event->getDispatcher() == removeButton && event->getEventCode() == UIEvent::CLICK_EVENT && event->getEventType() == "UIEvent") {
-		FontEntry *entry = 	CoreServices::getInstance()->getFontManager()->getFontEntryByFontPath(fontPath);
-		CoreServices::getInstance()->getFontManager()->removeFontEntry(entry, false);
+        
+        Font *font = (Font*) globalPool->getResourceByPath(fontPath);
+        if(font) {
+            globalPool->removeResource(font);
+            font->setResourceName(fontNameInput->getText());
+        }
+        
 		dispatchEvent(new Event(), Event::CHANGE_EVENT);
 	}
 }

+ 2 - 1
src/ide/PolycodeProjectManager.cpp

@@ -70,7 +70,8 @@ PolycodeProject* PolycodeProjectManager::openProject(String path) {
 	for(int i=0; i < newProject->data.fonts.size(); i++) {
 		String fontPath = projectPath+"/"+newProject->data.fonts[i].fontPath;
 		String fontName = newProject->data.fonts[i].fontName;
-		CoreServices::getInstance()->getFontManager()->registerFont(fontName, fontPath);		
+        ResourcePool *pool = Services()->getResourceManager()->getGlobalPool();
+        pool->loadResourceWithName(fontPath, fontName);
 	}
 	
 	setActiveProject(newProject);

+ 9 - 7
src/ide/PolycodeProps.cpp

@@ -3625,14 +3625,15 @@ SceneLabelSheet::SceneLabelSheet() : PropSheet("LABEL", "UILabel") {
 
 void SceneLabelSheet::refreshFonts() {
 	
-	FontManager *fontManager = CoreServices::getInstance()->getFontManager();
+    ResourcePool *pool = Services()->getResourceManager()->getGlobalPool();
 	
 	font->comboEntry->clearItems();
 	
-	for(int i=0; i < fontManager->getNumFonts(); i++) {
-		FontEntry *entry = fontManager->getFontEntryByIndex(i);
-		if(entry->fontName != "section") {
-			font->comboEntry->addComboItem(entry->fontName);
+    std::vector<Resource*> fonts = pool->getResources(Resource::RESOURCE_FONT);
+    
+	for(int i=0; i < fonts.size(); i++) {
+		if(fonts[i]->getResourceName() != "section") {
+			font->comboEntry->addComboItem(fonts[i]->getResourceName());
 		}
 	}
 
@@ -3677,8 +3678,9 @@ void SceneLabelSheet::handleEvent(Event *event) {
 	}
 
 	if(event->getDispatcher() == font) {
-		String fontName = font->comboEntry->getSelectedItem()->label;
-		Font *font = CoreServices::getInstance()->getFontManager()->getFontByName(fontName);
+		String fontName = font->comboEntry->getSelectedItem()->label;        
+        ResourcePool *pool = Services()->getResourceManager()->getGlobalPool();
+        Font *font = (Font*)pool->getResource(Resource::RESOURCE_FONT, fontName);
 		label->getLabel()->setFont(font);
 		label->setText(caption->get());
 		dispatchEvent(new Event(), Event::CHANGE_EVENT);