MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / getCharSize

Method getCharSize

src/Engine/Font.cpp:226–248  ·  view source on GitHub ↗

* Returns the dimensions of a particular character in the font. * @param c Font character. * @return Width and Height dimensions (X and Y are ignored). */

Source from the content-addressed store, hash-verified

224 * @return Width and Height dimensions (X and Y are ignored).
225 */
226SDL_Rect Font::getCharSize(wchar_t c)
227{
228 SDL_Rect size = { 0, 0, 0, 0 };
229 if (c != 1 && !isLinebreak(c) && !isSpace(c))
230 {
231 size.w = _chars[c].w + _spacing;
232 size.h = _chars[c].h + _spacing;
233 }
234 else
235 {
236 if (_monospace)
237 size.w = _width + _spacing;
238 else if (isNonBreakableSpace(c))
239 size.w = _width / 4;
240 else
241 size.w = _width / 2;
242 size.h = _height + _spacing;
243 }
244 // In case anyone mixes them up
245 size.x = size.w;
246 size.y = size.h;
247 return size;
248}
249
250/**
251 * Returns the surface stored within the font. Used for loading the

Callers 5

drawMethod · 0.80
exceedsMaxWidthMethod · 0.80
mousePressMethod · 0.80
processTextMethod · 0.80
drawMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected