* * rct2: 0x006C23B1 */
| 36 | * rct2: 0x006C23B1 |
| 37 | */ |
| 38 | int32_t getStringWidthNewlined(std::string_view text, FontStyle fontStyle) |
| 39 | { |
| 40 | u8string buffer; |
| 41 | |
| 42 | std::optional<int32_t> maxWidth; |
| 43 | FmtString fmt(text); |
| 44 | for (const auto& token : fmt) |
| 45 | { |
| 46 | if (token.kind == FormatToken::newline || token.kind == FormatToken::newlineSmall) |
| 47 | { |
| 48 | auto width = getStringWidth(buffer, fontStyle); |
| 49 | if (!maxWidth.has_value() || maxWidth.value() > width) |
| 50 | { |
| 51 | maxWidth = width; |
| 52 | } |
| 53 | buffer.clear(); |
| 54 | } |
| 55 | else |
| 56 | { |
| 57 | buffer.append(token.text); |
| 58 | } |
| 59 | } |
| 60 | if (!maxWidth.has_value()) |
| 61 | { |
| 62 | maxWidth = getStringWidth(buffer, fontStyle); |
| 63 | } |
| 64 | return maxWidth.value(); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Clip the text in buffer to width, add ellipsis and return the new width of the clipped string |
no test coverage detected