| 141 | } |
| 142 | |
| 143 | bool WinFont::create(const char *name, dsize_t size, U32 charset /* = TGE_ANSI_CHARSET */) |
| 144 | { |
| 145 | if(name == NULL || size < 1) |
| 146 | return false; |
| 147 | |
| 148 | if(charset > NUMCHARSETMAP) |
| 149 | charset = TGE_ANSI_CHARSET; |
| 150 | |
| 151 | U32 weight = 0; |
| 152 | U32 doItalic = 0; |
| 153 | |
| 154 | String nameStr = name; |
| 155 | nameStr = nameStr.trim(); |
| 156 | |
| 157 | bool haveModifier; |
| 158 | do |
| 159 | { |
| 160 | haveModifier = false; |
| 161 | if( nameStr.compare( "Bold", 4, String::NoCase | String::Right ) == 0 ) |
| 162 | { |
| 163 | weight = 700; |
| 164 | nameStr = nameStr.substr( 0, nameStr.length() - 4 ).trim(); |
| 165 | haveModifier = true; |
| 166 | } |
| 167 | if( nameStr.compare( "Italic", 6, String::NoCase | String::Right ) == 0 ) |
| 168 | { |
| 169 | doItalic = 1; |
| 170 | nameStr = nameStr.substr( 0, nameStr.length() - 6 ).trim(); |
| 171 | haveModifier = true; |
| 172 | } |
| 173 | } |
| 174 | while( haveModifier ); |
| 175 | |
| 176 | #ifdef UNICODE |
| 177 | const UTF16* n = nameStr.utf16(); |
| 178 | mFont = CreateFont(size,0,0,0,weight,doItalic,0,0,DEFAULT_CHARSET,OUT_TT_PRECIS,0,PROOF_QUALITY,0,n); |
| 179 | #else |
| 180 | mFont = CreateFont(size,0,0,0,weight,doItalic,0,0,charsetMap[charset],OUT_TT_PRECIS,0,PROOF_QUALITY,0,name); |
| 181 | #endif |
| 182 | if(mFont == NULL) |
| 183 | return false; |
| 184 | |
| 185 | SelectObject(fontHDC, fontBMP); |
| 186 | SelectObject(fontHDC, mFont); |
| 187 | GetTextMetrics(fontHDC, &mTextMetric); |
| 188 | |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | bool WinFont::isValidChar(const UTF16 ch) const |
| 193 | { |