Skip to content

Commit 14986d6

Browse files
authored
Merge pull request #1400 from lightnin/master
Messages: Use large font for message body when message < 2 lines
2 parents 5b93191 + 77d89ad commit 14986d6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

apps/messages/app.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,18 @@ function showMessage(msgid) {
270270
checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1});
271271
}});
272272
}
273-
var bodyFont = fontMedium;
274-
lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10);
275-
var body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
273+
// If body of message is only two lines long w/ large font, use large font.
274+
var body=msg.body, bodyFont = fontLarge, lines;
275+
if (body) {
276+
var w = g.getWidth()-48;
277+
if (g.setFont(bodyFont).stringWidth(body) > w * 2)
278+
bodyFont = fontMedium;
279+
if (g.setFont(bodyFont).stringWidth(body) > w) {
280+
lines = g.setFont(bodyFont).wrapString(msg.body, g.getWidth()-10);
281+
body = (lines.length>4) ? lines.slice(0,4).join("\n")+"..." : lines.join("\n");
282+
}
283+
}
284+
276285
layout = new Layout({ type:"v", c: [
277286
{type:"h", fillx:1, bgCol:colBg, c: [
278287
{ type:"btn", src:getMessageImage(msg), col:getMessageImageCol(msg), pad: 3, cb:()=>{

0 commit comments

Comments
 (0)