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

Function GetCharAtPosition

src/gfx_layout.cpp:441–447  ·  view source on GitHub ↗

* Get the character from a string that is drawn at a specific position. * @param str String to test. * @param x Position relative to the start of the string. * @param start_fontsize Font size to start the text with. * @return Index of the character position or -1 if there is no character at the position. */

Source from the content-addressed store, hash-verified

439 * @return Index of the character position or -1 if there is no character at the position.
440 */
441ptrdiff_t GetCharAtPosition(std::string_view str, int x, FontSize start_fontsize)
442{
443 if (x < 0) return -1;
444
445 Layouter layout(str, INT32_MAX, start_fontsize);
446 return layout.GetCharAtPosition(x, 0);
447}

Callers 2

GetCharAtPositionMethod · 0.85

Calls 1

GetCharAtPositionMethod · 0.45

Tested by

no test coverage detected