MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetStringBoundingBox

Function GetStringBoundingBox

src/gfx.cpp:897–901  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

895 * @return string width and height in pixels
896 */
897Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
898{
899 Layouter layout(str, INT32_MAX, start_fontsize);
900 return layout.GetBounds();
901}
902
903/**
904 * Get bounding box of a string.

Callers 15

UpdateWidgetSizeMethod · 0.85
UpdateWidgetSizeMethod · 0.85
UpdateWidgetSizeMethod · 0.85
GetStringListWidthFunction · 0.85
GetStringListBoundingBoxFunction · 0.85
UpdateWidgetSizeMethod · 0.85
OnInitMethod · 0.85
UpdateWidgetSizeMethod · 0.85
OnPaintMethod · 0.85
UpdateWidgetSizeMethod · 0.85
UpdateWidgetSizeMethod · 0.85
UpdateWidgetSizeMethod · 0.85

Calls 2

GetStringFunction · 0.70
GetBoundsMethod · 0.45

Tested by

no test coverage detected