[yocto] [psplash][PATCH] Fix text width calculation.

Kevin Corry kevin at corry.com
Fri Aug 11 14:18:37 PDT 2017


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 at corry.com>
---
 psplash-fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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;
 	}
-- 
2.11.0




More information about the yocto mailing list