MyGUI  3.0.1
MyGUI_ResourceTrueTypeFont.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_RESOURCE_TRUE_TYPE_FONT_H__
24 #define __MYGUI_RESOURCE_TRUE_TYPE_FONT_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_ITexture.h"
28 #include "MyGUI_IFont.h"
29 
30 namespace MyGUI
31 {
32 
34  public IFont
35  {
37 
38  public:
39  typedef std::vector<PairCodePoint> VectorPairCodePoint;
40  typedef std::vector<RangeInfo> VectorRangeInfo;
41  typedef std::vector<PairCodeCoord> VectorPairCodeCoord;
42 
43  public:
45  virtual ~ResourceTrueTypeFont();
46 
47  virtual void deserialization(xml::ElementPtr _node, Version _version);
48 
49  virtual GlyphInfo* getGlyphInfo(Char _id);
50 
51  virtual ITexture* getTextureFont() { return mTexture; }
52 
53  // получившаяся высота при генерации в пикселях
54  virtual int getDefaultHeight() { return mHeightPix; }
55 
56  private:
57  void addCodePointRange(Char _first, Char _second);
58  void addHideCodePointRange(Char _first, Char _second);
59 
60  // проверяет, входит ли символ в зоны ненужных символов
61  bool checkHidePointCode(Char _id);
62 
64  void clearCodePointRanges();
65 
66  void initialise();
67 
68  void addGlyph(GlyphInfo * _info, Char _index, int _left, int _top, int _right, int _bottom, int _finalw, int _finalh, float _aspect, int _addHeight = 0);
69  // write 2 or 4 bytes into buffer: LA or LLLA if _rgba is true
70  uint8* writeData(uint8* _pDest, unsigned char _luminance, unsigned char _alpha, bool _rgba);
71 
72  private:
73  // Source of the font
74  std::string mSource;
75  // Size of the truetype font, in points
76  float mTtfSize;
77  // Resolution (dpi) of truetype font
78  uint mTtfResolution;
79 
80  bool mAntialiasColour;
81 
82  int mDistance;
83  int mSpaceWidth;
84  int mTabWidth;
85  int mCursorWidth;
86  int mSelectionWidth;
87  int mOffsetHeight;
88  int mHeightPix;
89 
90  // отдельная информация о символах
91  GlyphInfo mSpaceGlyphInfo, mTabGlyphInfo, mSelectGlyphInfo, mSelectDeactiveGlyphInfo, mCursorGlyphInfo;
92 
93  // символы которые не нужно рисовать
94  VectorPairCodePoint mVectorHideCodePoint;
95 
96  // вся информация о символах
97  VectorRangeInfo mVectorRangeInfo;
98 
99  MyGUI::ITexture* mTexture;
100 
101  };
102 
103 } // namespace MyGUI
104 
105 #endif // __MYGUI_RESOURCE_TRUE_TYPE_FONT_H__