MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / create

Method create

Engine/source/platformWin32/winFont.cpp:142–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

createTypeMethod · 0.45
EnumDevicesProcMethod · 0.45
createPlatformFontFunction · 0.45

Calls 5

trimMethod · 0.80
substrMethod · 0.80
compareMethod · 0.45
lengthMethod · 0.45
utf16Method · 0.45

Tested by

no test coverage detected