From 4274503bff1c76173ae0a6653924e17492e9d6d0 Mon Sep 17 00:00:00 2001 From: Amos Blanton Date: Sun, 6 Feb 2022 11:25:30 +0100 Subject: [PATCH 1/2] When message body is < 1 line wide, use large font. --- apps/messages/app.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/messages/app.js b/apps/messages/app.js index 3e692a0cc..1e9e22733 100644 --- a/apps/messages/app.js +++ b/apps/messages/app.js @@ -270,9 +270,18 @@ function showMessage(msgid) { checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1}); }}); } - var bodyFont = fontMedium; - lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10); - var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n"); + // If body of message is only one line, use large font. + var body=msg.body, bodyFont = fontLarge, lines; + if (body) { + var w = g.getWidth()-48; + if (g.setFont(bodyFont).stringWidth(body) > w) + bodyFont = fontMedium; + if (g.setFont(bodyFont).stringWidth(body) > w) { + lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10); + body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n"); + } + } + layout = new Layout({ type:"v", c: [ {type:"h", fillx:1, bgCol:colBg, c: [ { type:"btn", src:getMessageImage(msg), col:getMessageImageCol(msg), pad: 3, cb:()=>{ From 77d89ad0db4679b601b35c96318a9f0152698817 Mon Sep 17 00:00:00 2001 From: Amos Blanton Date: Sun, 6 Feb 2022 13:26:04 +0100 Subject: [PATCH 2/2] Allow large font for message body that fits in 2 lines --- apps/messages/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/messages/app.js b/apps/messages/app.js index 1e9e22733..d475be9c1 100644 --- a/apps/messages/app.js +++ b/apps/messages/app.js @@ -270,11 +270,11 @@ function showMessage(msgid) { checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1}); }}); } - // If body of message is only one line, use large font. + // If body of message is only two lines long w/ large font, use large font. var body=msg.body, bodyFont = fontLarge, lines; if (body) { var w = g.getWidth()-48; - if (g.setFont(bodyFont).stringWidth(body) > w) + if (g.setFont(bodyFont).stringWidth(body) > w * 2) bodyFont = fontMedium; if (g.setFont(bodyFont).stringWidth(body) > w) { lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10);