/** * Returns the dimensions of a particular character in the font. * @param c Font character. * @return Width and Height dimensions (X and Y are ignored). */ SDL_Rect Font::getCharSize(wchar_t c) { SDL_Rect size = { 0, 0, 0, 0 }; if (c != 1 && !isLinebreak(c) && !isSpace(c)) { size.w = _chars[c].w + _spacing; size.h = _chars[c].h + _spacing; } else { if (_monospace) size.w = _width + _spacing; else if (isNonBreakableSpace(c)) size.w = _width / 4; else size.w = _width / 2; size.h = _height + _spacing; } // In case anyone mixes them up size.x = size.w; size.y = size.h; return size; }
/** * Returns the dimensions of a particular character in the font. * @param c Font character. * @return Width and Height dimensions (X and Y are ignored). */ SDL_Rect Font::getCharSize(wchar_t c) { SDL_Rect size = { 0, 0, 0, 0 }; if (c != 1 && !isLinebreak(c) && !isSpace(c)) { FontImage *image = &_images[_chars[c].first]; size.w = _chars[c].second.w + image->spacing; size.h = _chars[c].second.h + image->spacing; } else { if (_monospace) size.w = getWidth() + getSpacing(); else if (isNonBreakableSpace(c)) size.w = getWidth() / 4; else size.w = getWidth() / 2; size.h = getHeight() + getSpacing(); } // In case anyone mixes them up size.x = size.w; size.y = size.h; return size; }