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

Function GetCharPosInString

src/gfx_layout.cpp:425–432  ·  view source on GitHub ↗

* Get the leading corner of a character in a single-line string relative * to the start of the string. * @param str String containing the character. * @param pos Index to the character in the string. * @param start_fontsize Font size to start the text with. * @return Upper left corner of the glyph associated with the character. */

Source from the content-addressed store, hash-verified

423 * @return Upper left corner of the glyph associated with the character.
424 */
425ParagraphLayouter::Position GetCharPosInString(std::string_view str, size_t pos, FontSize start_fontsize)
426{
427 assert(pos <= str.size());
428 auto it_ch = str.begin() + pos;
429
430 Layouter layout(str, INT32_MAX, start_fontsize);
431 return layout.GetCharPosition(it_ch);
432}
433
434/**
435 * Get the character from a string that is drawn at a specific position.

Callers 4

GetTextBoundingRectMethod · 0.85
GetBoundingRectMethod · 0.85
UpdateCaretPositionMethod · 0.85
UpdateMarkedTextMethod · 0.85

Calls 3

GetCharPositionMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected