Skip to content

Commit 6651455

Browse files
committed
tileclk: Improve clock info text display
1 parent ad54f17 commit 6651455

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/tileclk/app.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,14 @@
812812
const maxTextWidth = options.w - imgSize - padding * 3;
813813

814814
if (g.stringWidth(text) > maxTextWidth) {
815-
while (g.stringWidth(text + "...") > maxTextWidth && text.length > 0) {
816-
text = text.substr(0, text.length - 1);
815+
if (text.indexOf(' ') === -1) {
816+
g.setFont("6x8:2");
817+
if (g.stringWidth(text) > maxTextWidth) g.setFont("6x8:1");
818+
} else {
819+
g.setFont("6x8:2");
820+
const lines = g.wrapString(text, maxTextWidth);
821+
text = lines.slice(0, 2).join("\n") + (lines.length > 2 ? "..." : "");
817822
}
818-
text = text + "...";
819823
}
820824

821825
const textWidth = g.stringWidth(text);

0 commit comments

Comments
 (0)