MyGUI  3.4.1
MyGUI_ResourceManualFont.h
Go to the documentation of this file.
1 /*
2  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3  * Distributed under the MIT License
4  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5  */
6 
7 #ifndef MYGUI_RESOURCE_MANUAL_FONT_H_
8 #define MYGUI_RESOURCE_MANUAL_FONT_H_
9 
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_ITexture.h"
12 #include "MyGUI_IFont.h"
13 
14 #include <unordered_map>
15 
16 namespace MyGUI
17 {
18 
20  public IFont
21  {
23 
24  public:
26 
27  void deserialization(xml::ElementPtr _node, Version _version) override;
28 
29  // Returns the glyph info for the specified code point, or the glyph info for a substitute glyph if the code point does not
30  // exist in this font. Returns nullptr if the code point does not exist and there is no substitute glyph available.
31  const GlyphInfo* getGlyphInfo(Char _id) const override;
32 
33  ITexture* getTextureFont() const override;
34 
35  // дефолтная высота, указанная в настройках шрифта
36  int getDefaultHeight() const override;
37 
38  // Manual loading methods, not needed when loading from XML
39  // Set the source texture by name
40  void setSource(const std::string& value);
41  // Set the shader by name
42  void setShader(const std::string& value);
43  // Set the source texture directly
44  // Note: the user is responsible for deallocation of the texture.
45  void setTexture(MyGUI::ITexture* texture);
46  // Set the default height of the font
47  void setDefaultHeight(int value);
48  // Add a glyph for character 'id'
49  void addGlyphInfo(Char id, const GlyphInfo& info);
50 
51  private:
52  // Loads the texture specified by mSource.
53  void loadTexture();
54 
55  // A map of code points to glyph info objects.
56  typedef std::unordered_map<Char, GlyphInfo> CharMap;
57 
58  // The following variables are set directly from values specified by the user.
59  std::string mSource; // Source (filename) of the font.
60  std::string mShader; // Optional shader, applied to the font.
61 
62  // The following variables are calculated automatically.
63  int mDefaultHeight; // The nominal height of the font in pixels.
64  GlyphInfo* mSubstituteGlyphInfo; // The glyph info to use as a substitute for code points that don't exist in the font.
65  MyGUI::ITexture* mTexture; // The texture that contains all of the rendered glyphs in the font.
66 
67  CharMap mCharMap; // A map of code points to glyph info objects.
68  };
69 
70 } // namespace MyGUI
71 
72 #endif // MYGUI_RESOURCE_MANUAL_FONT_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:48
unsigned int Char
Definition: MyGUI_Types.h:49