When message body is < 1 line wide, use large font.

pull/1400/head
Amos Blanton 2022-02-06 11:25:30 +01:00 committed by GitHub
parent 6872c38a8d
commit 4274503bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -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:()=>{