mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] fbconsole: support fonts wider than 16 pixels
@ 2024-08-24 20:04 Ahmad Fatoum
  2024-08-24 20:04 ` [PATCH 2/2] fonts: add TER16x32 font Ahmad Fatoum
  2024-08-26 11:13 ` [PATCH 1/2] fbconsole: support fonts wider than 16 pixels Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-08-24 20:04 UTC (permalink / raw)
  To: barebox; +Cc: spu, Ahmad Fatoum

We have a nested loop that iterates over all pixels in a font, but it
only looks at the first 8 bits. This worked so far, because our biggest
font was VGA8x16. In the follow-up commit, a 16x32 font will be added,
so we need to prepare the code to consider the whole width of a font.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/video/fbconsole.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
index 6c85e8e06a8c..cec1afec56cb 100644
--- a/drivers/video/fbconsole.c
+++ b/drivers/video/fbconsole.c
@@ -117,7 +117,7 @@ static void drawchar(struct fbc_priv *priv, int x, int y, int c)
 	int bpp = priv->fb->bits_per_pixel >> 3;
 	void *adr;
 	int i;
-	const char *inbuf;
+	const uint8_t *inbuf;
 	int line_length;
 	u32 color, bgcolor;
 	struct rgb *rgb;
@@ -142,21 +142,30 @@ static void drawchar(struct fbc_priv *priv, int x, int y, int c)
 	bgcolor = gu_rgb_to_pixel(priv->fb, rgb->r, rgb->g, rgb->b, 0xff);
 
 	for (i = 0; i < priv->font->height; i++) {
-		uint8_t t = inbuf[i];
+		uint8_t mask = 0x80;
 		int j;
 
 		adr = buf + line_length * (priv->margin.top + y * priv->font->height + i) +
 		      (priv->margin.left + x * priv->font->width) * bpp;
 
 		for (j = 0; j < priv->font->width; j++) {
-			if (t & 0x80)
+			if (!mask) {
+				inbuf++;
+				mask = 0x80;
+			}
+
+			if (*inbuf & mask)
 				gu_set_pixel(priv->fb, adr, color);
 			else
 				gu_set_pixel(priv->fb, adr, bgcolor);
 
 			adr += priv->fb->bits_per_pixel >> 3;
-			t <<= 1;
+			mask >>= 1;
+
 		}
+
+		inbuf++;
+		mask = 0x80;
 	}
 }
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-26 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-24 20:04 [PATCH 1/2] fbconsole: support fonts wider than 16 pixels Ahmad Fatoum
2024-08-24 20:04 ` [PATCH 2/2] fonts: add TER16x32 font Ahmad Fatoum
2024-08-26 11:13 ` [PATCH 1/2] fbconsole: support fonts wider than 16 pixels Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox