MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / truncatedText

Method truncatedText

lib/GfxRenderer/GfxRenderer.cpp:1356–1374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1354}
1355
1356std::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
1376std::vector<std::string> GfxRenderer::wrappedText(const int fontId, const char* text, const int maxWidth,
1377 const int maxLines, const EpdFontFamily::Style style) const {

Callers 15

drawListMethod · 0.80
drawHeaderMethod · 0.80
drawSubHeaderMethod · 0.80
drawRecentBookCoverMethod · 0.80
drawStatusBarMethod · 0.80
drawHelpTextMethod · 0.80
drawHeaderMethod · 0.80
drawButtonMenuMethod · 0.80
drawListMethod · 0.80
drawHeaderMethod · 0.80
drawSubHeaderMethod · 0.80
drawListMethod · 0.80

Calls 2

utf8RemoveLastCharFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected