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