From 665145596033e67c8b918a9fbabebd326b44812d Mon Sep 17 00:00:00 2001 From: stweedo Date: Wed, 25 Jun 2025 00:20:41 -0500 Subject: [PATCH] tileclk: Improve clock info text display --- apps/tileclk/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/tileclk/app.js b/apps/tileclk/app.js index 3147b7e92..37fbe2a37 100644 --- a/apps/tileclk/app.js +++ b/apps/tileclk/app.js @@ -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);