| 1354 | } |
| 1355 | |
| 1356 | std::string GfxRenderer::truncatedText(const int fontId, const char* text, const int maxWidth, |
| 1357 | const EpdFontFamily::Style style) const { |
| 1358 | if (!text || maxWidth <= 0) return ""; |
| 1359 | |
| 1360 | std::string item = text; |
| 1361 | // U+2026 HORIZONTAL ELLIPSIS (UTF-8: 0xE2 0x80 0xA6) |
| 1362 | const char* ellipsis = "\xe2\x80\xa6"; |
| 1363 | int textWidth = getTextWidth(fontId, item.c_str(), style); |
| 1364 | if (textWidth <= maxWidth) { |
| 1365 | // Text fits, return as is |
| 1366 | return item; |
| 1367 | } |
| 1368 | |
| 1369 | while (!item.empty() && getTextWidth(fontId, (item + ellipsis).c_str(), style) >= maxWidth) { |
| 1370 | utf8RemoveLastChar(item); |
| 1371 | } |
| 1372 | |
| 1373 | return item.empty() ? ellipsis : item + ellipsis; |
| 1374 | } |
| 1375 | |
| 1376 | std::vector<std::string> GfxRenderer::wrappedText(const int fontId, const char* text, const int maxWidth, |
| 1377 | const int maxLines, const EpdFontFamily::Style style) const { |
no test coverage detected