tileclk: Improve clock info text display

master
stweedo 2025-06-25 00:20:41 -05:00
parent ad54f17e30
commit 6651455960
1 changed files with 7 additions and 3 deletions

View File

@ -812,10 +812,14 @@
const maxTextWidth = options.w - imgSize - padding * 3;
if (g.stringWidth(text) > maxTextWidth) {
while (g.stringWidth(text + "...") > maxTextWidth && text.length > 0) {
text = text.substr(0, text.length - 1);
if (text.indexOf(' ') === -1) {
g.setFont("6x8:2");
if (g.stringWidth(text) > maxTextWidth) g.setFont("6x8:1");
} else {
g.setFont("6x8:2");
const lines = g.wrapString(text, maxTextWidth);
text = lines.slice(0, 2).join("\n") + (lines.length > 2 ? "..." : "");
}
text = text + "...";
}
const textWidth = g.stringWidth(text);