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_FONT_DATA_H__ 00023 #define __MYGUI_FONT_DATA_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 00027 namespace MyGUI 00028 { 00029 00030 struct MYGUI_EXPORT FontCodeType 00031 { 00032 enum Enum 00033 { 00034 Selected = 6, 00035 SelectedBack = 7, 00036 Cursor = 8, 00037 Tab = 9, 00038 LF = 0x000A, 00039 CR = 0x000D, 00040 Space = 0x0020, 00041 LatinStart = 0x0021, 00042 NEL = 0x0085, 00043 LatinEnd = 0x00A6, 00044 MAX 00045 }; 00046 00047 FontCodeType(Enum _value = MAX) : 00048 value(_value) 00049 { 00050 } 00051 00052 friend bool operator == (FontCodeType const& a, FontCodeType const& b) 00053 { 00054 return a.value == b.value; 00055 } 00056 00057 friend bool operator != (FontCodeType const& a, FontCodeType const& b) 00058 { 00059 return a.value != b.value; 00060 } 00061 00062 private: 00063 Enum value; 00064 }; 00065 00066 // информация об одном символе 00067 struct GlyphInfo 00068 { 00069 public: 00070 GlyphInfo() : 00071 codePoint(0), 00072 width(0) 00073 { 00074 } 00075 00076 public: 00077 FloatRect uvRect; 00078 Char codePoint; 00079 int width; 00080 }; 00081 00082 typedef std::vector<GlyphInfo> VectorGlyphInfo; 00083 00084 // информация об диапазоне 00085 //FIXME move to std::pair 00086 class PairCodePoint 00087 { 00088 public: 00089 PairCodePoint() : 00090 first(0), 00091 last(0) 00092 { 00093 } 00094 00095 PairCodePoint(Char _first, Char _last) : 00096 first(_first), 00097 last(_last) 00098 { 00099 } 00100 00101 // проверяет входит ли символ в диапазон 00102 bool isExist(Char _code) const 00103 { 00104 return _code >= first && _code <= last; 00105 } 00106 00107 public: 00108 Char first; 00109 Char last; 00110 }; 00111 00112 // инфомация о диапазоне символов 00113 class RangeInfo 00114 { 00115 public: 00116 RangeInfo() : 00117 first(0), 00118 last(0) 00119 { 00120 } 00121 00122 RangeInfo(Char _first, Char _last) : 00123 first(_first), 00124 last(_last) 00125 { 00126 range.resize(last - first + 1); 00127 } 00128 00129 // проверяет входит ли символ в диапазон 00130 bool isExist(Char _code) const 00131 { 00132 return _code >= first && _code <= last; 00133 } 00134 00135 // возвращает указатель на глиф, или 0, если код не входит в диапазон 00136 GlyphInfo* getInfo(Char _code) 00137 { 00138 return isExist(_code) ? &range[_code - first] : nullptr; 00139 } 00140 00141 void setInfo(Char _code, GlyphInfo* _value) 00142 { 00143 if (isExist(_code)) range[_code - first] = *_value; 00144 } 00145 00146 public: 00147 Char first; 00148 Char last; 00149 VectorGlyphInfo range; 00150 }; 00151 00152 // FIXME move to resource font 00153 class PairCodeCoord 00154 { 00155 public: 00156 PairCodeCoord() : 00157 code(0) 00158 { 00159 } 00160 00161 PairCodeCoord(Char _code, const IntCoord& _coord) : 00162 code(_code), 00163 coord(_coord) 00164 { 00165 } 00166 00167 bool operator < (const PairCodeCoord& _value) const 00168 { 00169 return code < _value.code; 00170 } 00171 00172 public: 00173 Char code; 00174 IntCoord coord; 00175 }; 00176 00177 } // namespace MyGUI 00178 00179 #endif // __MYGUI_FONT_DATA_H__