[02/33] video: Support truetype fonts on a 32-bit display
diff mbox series

Message ID 20200112120216.2.I25364ae19a2d5679c51aa1cdeebea29d805fbe68@changeid
State Superseded
Delegated to: Simon Glass
Headers show
Series
  • sandbox: Move to SDL2
Related show

Commit Message

Simon Glass Jan. 12, 2020, 7:05 p.m. UTC
At present only a 16bpp display is supported for Truetype fonts. Add
support for 32bpp also since this is quite common.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/console_truetype.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Anatolij Gustschin Jan. 12, 2020, 7:59 p.m. UTC | #1
Hi Simon,

On Sun, 12 Jan 2020 12:05:53 -0700
Simon Glass sjg@chromium.org wrote:

> At present only a 16bpp display is supported for Truetype fonts. Add
> support for 32bpp also since this is quite common.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Anatolij Gustschin <agust@denx.de>

--
Anatolij

Patch
diff mbox series

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 30086600fb..0a725c5c15 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -286,6 +286,27 @@  static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 			}
 			break;
 		}
+#endif
+#ifdef CONFIG_VIDEO_BPP32
+		case VIDEO_BPP32: {
+			u32 *dst = (u32 *)line + xoff;
+			int i;
+
+			for (i = 0; i < width; i++) {
+				int val = *bits;
+				int out;
+
+				if (vid_priv->colour_bg)
+					val = 255 - val;
+				out = val | val << 8 | val << 16;
+				if (vid_priv->colour_fg)
+					*dst++ |= out;
+				else
+					*dst++ &= out;
+				bits++;
+			}
+			break;
+		}
 #endif
 		default:
 			free(data);