[148] | 1 | /*------------------------------------------------------------------------- |
---|
| 2 | This source file is a part of OGRE |
---|
| 3 | (Object-oriented Graphics Rendering Engine) |
---|
| 4 | |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
---|
| 8 | Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 9 | of this software and associated documentation files (the "Software"), to deal |
---|
| 10 | in the Software without restriction, including without limitation the rights |
---|
| 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 12 | copies of the Software, and to permit persons to whom the Software is |
---|
| 13 | furnished to do so, subject to the following conditions: |
---|
| 14 | |
---|
| 15 | The above copyright notice and this permission notice shall be included in |
---|
| 16 | all copies or substantial portions of the Software. |
---|
| 17 | |
---|
| 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 24 | THE SOFTWARE |
---|
| 25 | -------------------------------------------------------------------------*/ |
---|
| 26 | |
---|
| 27 | #ifndef _FontManager_H__ |
---|
| 28 | #define _FontManager_H__ |
---|
| 29 | |
---|
| 30 | #include "OgreOverlayPrerequisites.h" |
---|
| 31 | #include "OgreSingleton.h" |
---|
| 32 | #include "OgreResourceManager.h" |
---|
| 33 | #include "OgreFont.h" |
---|
| 34 | |
---|
| 35 | namespace Ogre |
---|
| 36 | { |
---|
| 37 | /** \addtogroup Core |
---|
| 38 | * @{ |
---|
| 39 | */ |
---|
| 40 | /** \addtogroup Resources |
---|
| 41 | * @{ |
---|
| 42 | */ |
---|
| 43 | /** Manages Font resources, parsing .fontdef files and generally organising them.*/ |
---|
| 44 | class _OgreOverlayExport FontManager : public ResourceManager, public Singleton< FontManager > |
---|
| 45 | { |
---|
| 46 | public: |
---|
| 47 | |
---|
| 48 | FontManager(); |
---|
| 49 | ~FontManager(); |
---|
| 50 | |
---|
| 51 | /// Create a new font |
---|
| 52 | /// @see ResourceManager::createResource |
---|
| 53 | FontPtr create (const String& name, const String& group, |
---|
| 54 | bool isManual = false, ManualResourceLoader* loader = 0, |
---|
| 55 | const NameValuePairList* createParams = 0); |
---|
| 56 | |
---|
| 57 | /// Get a resource by name |
---|
| 58 | /// @see ResourceManager::getResourceByName |
---|
| 59 | FontPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | /** @copydoc ScriptLoader::parseScript */ |
---|
| 63 | void parseScript(DataStreamPtr& stream, const String& groupName); |
---|
| 64 | /** Override standard Singleton retrieval. |
---|
| 65 | @remarks |
---|
| 66 | Why do we do this? Well, it's because the Singleton |
---|
| 67 | implementation is in a .h file, which means it gets compiled |
---|
| 68 | into anybody who includes it. This is needed for the |
---|
| 69 | Singleton template to work, but we actually only want it |
---|
| 70 | compiled into the implementation of the class based on the |
---|
| 71 | Singleton, not all of them. If we don't change this, we get |
---|
| 72 | link errors when trying to use the Singleton-based class from |
---|
| 73 | an outside dll. |
---|
| 74 | @par |
---|
| 75 | This method just delegates to the template version anyway, |
---|
| 76 | but the implementation stays in this single compilation unit, |
---|
| 77 | preventing link errors. |
---|
| 78 | */ |
---|
| 79 | static FontManager& getSingleton(void); |
---|
| 80 | /** Override standard Singleton retrieval. |
---|
| 81 | @remarks |
---|
| 82 | Why do we do this? Well, it's because the Singleton |
---|
| 83 | implementation is in a .h file, which means it gets compiled |
---|
| 84 | into anybody who includes it. This is needed for the |
---|
| 85 | Singleton template to work, but we actually only want it |
---|
| 86 | compiled into the implementation of the class based on the |
---|
| 87 | Singleton, not all of them. If we don't change this, we get |
---|
| 88 | link errors when trying to use the Singleton-based class from |
---|
| 89 | an outside dll. |
---|
| 90 | @par |
---|
| 91 | This method just delegates to the template version anyway, |
---|
| 92 | but the implementation stays in this single compilation unit, |
---|
| 93 | preventing link errors. |
---|
| 94 | */ |
---|
| 95 | static FontManager* getSingletonPtr(void); |
---|
| 96 | |
---|
| 97 | protected: |
---|
| 98 | |
---|
| 99 | /// Internal methods |
---|
| 100 | Resource* createImpl(const String& name, ResourceHandle handle, |
---|
| 101 | const String& group, bool isManual, ManualResourceLoader* loader, |
---|
| 102 | const NameValuePairList* params); |
---|
| 103 | void parseAttribute(const String& line, FontPtr& pFont); |
---|
| 104 | |
---|
| 105 | void logBadAttrib(const String& line, FontPtr& pFont); |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | }; |
---|
| 109 | /** @} */ |
---|
| 110 | /** @} */ |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | #endif |
---|