aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Corry <kevin@corry.com>2017-08-11 16:18:37 -0500
committerRoss Burton <ross.burton@intel.com>2017-09-02 01:01:20 +0100
commit2015f7073e98dd9562db0936a254af5ef56356cf (patch)
treeb34d80a2058e622b9af62376cef7a35a1371c550
parent5b3c1cc28f5abdc2c33830150b48b278cc4f7bca (diff)
downloadpsplash-master.tar.gz
psplash-master.tar.bz2
psplash-master.zip
Fix text width calculation.HEADmaster
Psplash: Fix text width calculation. Using the "psplash-write MSG <message_text>" command, you can display messages when the splash screen is running. As part of this, psplash needs to calculate the height and width of the box to render on the screen to hold the text (which will appear on top of the background image), which it does in the psplash_fb_text_size() function in psplash-fb.c. If the message contains multiple lines (i.e. it contains one or more newline characters), then it looks like the intention is for psplash to use the length of the longest single line as the width of this text box. However, there's a bug in this calculation that leads to some multi-line messages being rendered off the left edge of the screen, instead of properly centered. To fix this, each time a newline is encountered, if the width of the current line (w) is greater than the maximum line width (mw), update the maximum width. Also, reset the current line width to zero so we can correctly calculate the width of the next line. Signed-off-by: Kevin Corry <kevin@corry.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--psplash-fb.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/psplash-fb.c b/psplash-fb.c
index d344e5a..c064d18 100644
--- a/psplash-fb.c
+++ b/psplash-fb.c
@@ -483,7 +483,8 @@ psplash_fb_text_size (int *width,
if (*c == '\n')
{
if (w > mw)
- mw = 0;
+ mw = w;
+ w = 0;
h += font->height;
continue;
}