MyGUI
3.2.1
|
00001 /* 00002 * This source file is part of MyGUI. For the latest info, see http://mygui.info/ 00003 * Distributed under the MIT License 00004 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT) 00005 */ 00006 00007 #ifndef __MYGUI_RESOURCE_MANUAL_FONT_H__ 00008 #define __MYGUI_RESOURCE_MANUAL_FONT_H__ 00009 00010 #include "MyGUI_Prerequest.h" 00011 #include "MyGUI_ITexture.h" 00012 #include "MyGUI_IFont.h" 00013 00014 namespace MyGUI 00015 { 00016 00017 class MYGUI_EXPORT ResourceManualFont : 00018 public IFont 00019 { 00020 MYGUI_RTTI_DERIVED( ResourceManualFont ) 00021 00022 public: 00023 ResourceManualFont(); 00024 virtual ~ResourceManualFont(); 00025 00026 virtual void deserialization(xml::ElementPtr _node, Version _version); 00027 00028 // Returns the glyph info for the specified code point, or the glyph info for a substitute glyph if the code point does not 00029 // exist in this font. Returns nullptr if the code point does not exist and there is no substitute glyph available. 00030 virtual GlyphInfo* getGlyphInfo(Char _id); 00031 00032 virtual ITexture* getTextureFont(); 00033 00034 // дефолтная высота, указанная в настройках шрифта 00035 virtual int getDefaultHeight(); 00036 00037 // Manual loading methods, not needed when loading from XML 00038 // Set the source texture name 00039 void setSource(const std::string& value); 00040 // Set the default height of the font 00041 void setDefaultHeight(int value); 00042 // Add a glyph for character 'id' 00043 void addGlyphInfo(Char id, const GlyphInfo& info); 00044 00045 private: 00046 // Loads the texture specified by mSource. 00047 void loadTexture(); 00048 00049 // A map of code points to glyph info objects. 00050 typedef std::map<Char, GlyphInfo> CharMap; 00051 00052 // The following variables are set directly from values specified by the user. 00053 std::string mSource; // Source (filename) of the font. 00054 00055 // The following variables are calculated automatically. 00056 int mDefaultHeight; // The nominal height of the font in pixels. 00057 GlyphInfo* mSubstituteGlyphInfo; // The glyph info to use as a substitute for code points that don't exist in the font. 00058 MyGUI::ITexture* mTexture; // The texture that contains all of the rendered glyphs in the font. 00059 00060 CharMap mCharMap; // A map of code points to glyph info objects. 00061 }; 00062 00063 } // namespace MyGUI 00064 00065 #endif // __MYGUI_RESOURCE_MANUAL_FONT_H__