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

Method create

Engine/source/platformWin32/winFont.cpp:143–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143bool 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
192bool WinFont::isValidChar(const UTF16 ch) const
193{

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