MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_RESOURCE_TRUE_TYPE_FONT_H__ 00023 #define __MYGUI_RESOURCE_TRUE_TYPE_FONT_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_ITexture.h" 00027 #include "MyGUI_IFont.h" 00028 00029 namespace MyGUI 00030 { 00031 00032 class MYGUI_EXPORT ResourceTrueTypeFont : 00033 public IFont 00034 { 00035 MYGUI_RTTI_DERIVED( ResourceTrueTypeFont ) 00036 00037 public: 00038 typedef std::vector<PairCodePoint> VectorPairCodePoint; 00039 typedef std::vector<RangeInfo> VectorRangeInfo; 00040 typedef std::vector<PairCodeCoord> VectorPairCodeCoord; 00041 00042 ResourceTrueTypeFont(); 00043 virtual ~ResourceTrueTypeFont(); 00044 00045 virtual void deserialization(xml::ElementPtr _node, Version _version); 00046 00047 virtual GlyphInfo* getGlyphInfo(Char _id); 00048 00049 virtual ITexture* getTextureFont(); 00050 00051 // получившаяся высота при генерации в пикселях 00052 virtual int getDefaultHeight(); 00053 00054 private: 00055 void addCodePointRange(Char _first, Char _second); 00056 void addHideCodePointRange(Char _first, Char _second); 00057 00058 // проверяет, входит ли символ в зоны ненужных символов 00059 bool checkHidePointCode(Char _id); 00060 00062 void clearCodePointRanges(); 00063 00064 void initialise(); 00065 00066 void addGlyph(GlyphInfo* _info, Char _index, int _left, int _top, int _right, int _bottom, int _finalw, int _finalh, float _aspect, int _addHeight = 0) const; 00067 // write 2 or 4 bytes into buffer: LA or LLLA if _rgba is true 00068 uint8* writeData(uint8* _pDest, unsigned char _luminance, unsigned char _alpha, bool _rgba); 00069 00070 private: 00071 // Source of the font 00072 std::string mSource; 00073 // Size of the truetype font, in points 00074 float mTtfSize; 00075 // Resolution (dpi) of truetype font 00076 uint mTtfResolution; 00077 00078 bool mAntialiasColour; 00079 00080 int mDistance; 00081 int mSpaceWidth; 00082 int mTabWidth; 00083 int mCursorWidth; 00084 int mSelectionWidth; 00085 int mOffsetHeight; 00086 int mHeightPix; 00087 00088 // отдельная информация о символах 00089 GlyphInfo mSpaceGlyphInfo; 00090 GlyphInfo mTabGlyphInfo; 00091 GlyphInfo mSelectGlyphInfo; 00092 GlyphInfo mSelectDeactiveGlyphInfo; 00093 GlyphInfo mCursorGlyphInfo; 00094 00095 // символы которые не нужно рисовать 00096 VectorPairCodePoint mVectorHideCodePoint; 00097 00098 // вся информация о символах 00099 VectorRangeInfo mVectorRangeInfo; 00100 00101 MyGUI::ITexture* mTexture; 00102 }; 00103 00104 } // namespace MyGUI 00105 00106 #endif // __MYGUI_RESOURCE_TRUE_TYPE_FONT_H__