|
@@ -881,24 +881,39 @@ int DrawStringMultiLine(int left, int ri
|
|
|
* but not every possible combination
|
|
|
* @param str string to calculate pixel-width
|
|
|
* @param start_fontsize Fontsize to start the text with
|
|
|
* @return string width and height in pixels
|
|
|
*/
|
|
|
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
|
|
|
{
|
|
|
Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
|
|
|
return layout.GetBounds();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Return the string dimension in pixels. The height and width are returned
|
|
|
* in a single Dimension value. TINYFONT, BIGFONT modifiers are only
|
|
|
* supported as the first character of the string. The returned dimensions
|
|
|
* are therefore a rough estimation correct for all the current strings
|
|
|
* but not every possible combination
|
|
|
* @param str string to calculate pixel-width
|
|
|
* @param start_fontsize Fontsize to start the text with
|
|
|
* @return string width and height in pixels
|
|
|
*/
|
|
|
Dimension GetStringBoundingBox(const std::string &str, FontSize start_fontsize)
|
|
|
{
|
|
|
return GetStringBoundingBox(str.c_str(), start_fontsize);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get bounding box of a string. Uses parameters set by #SetDParam if needed.
|
|
|
* Has the same restrictions as #GetStringBoundingBox(const char *str, FontSize start_fontsize).
|
|
|
* @param strid String to examine.
|
|
|
* @return Width and height of the bounding box for the string in pixels.
|
|
|
*/
|
|
|
Dimension GetStringBoundingBox(StringID strid)
|
|
|
{
|
|
|
char buffer[DRAW_STRING_BUFFER];
|
|
|
|
|
|
GetString(buffer, strid, lastof(buffer));
|
|
|
return GetStringBoundingBox(buffer);
|
|
|
}
|