[PATCH 6/6] video: support Unicode in video console
Heinrich Schuchardt
xypron.glpk at gmx.de
Sat Feb 27 14:08:40 CET 2021
UEFI programs use Unicode for console output, e.g. GRUB uses characters
from the 0x2500 code block to draw a box around the menu.
The TrueType console supports UTF-32. The normal console supports code page
437. We have to convert the UTF-8 stream passed to putc() accordingly.
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
drivers/video/vidconsole-uclass.c | 22 +++++++++++++++++-----
include/video_console.h | 2 +-
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index a355328851..d5095f69e0 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -32,7 +32,7 @@ struct vid_rgb {
#define CONFIG_CONSOLE_SCROLL_LINES 1
#endif
-int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch)
+int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int ch)
{
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
@@ -479,8 +479,14 @@ error:
priv->escape = 0;
}
-/* Put that actual character on the screen (using the CP437 code page). */
-static int vidconsole_output_glyph(struct udevice *dev, char ch)
+/*
+ * vidconsole_output_glyph() - put the actual character on the screen
+ *
+ * @dev: video device
+ * @ch: character: Unicode for Truetype, codepage 437 otherwise
+ * Return: 0 for success
+ */
+static int vidconsole_output_glyph(struct udevice *dev, int ch)
{
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
int ret;
@@ -505,17 +511,23 @@ static int vidconsole_output_glyph(struct udevice *dev, char ch)
return 0;
}
-int vidconsole_put_char(struct udevice *dev, char ch)
+int vidconsole_put_char(struct udevice *dev, char c)
{
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+ int ch;
int ret;
if (IS_ENABLED(CONFIG_EFI_LOADER)) {
static char buffer[5];
- ch = utf8_to_cp437_stream(ch, buffer);
+ if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE))
+ ch = utf8_to_utf32_stream(c, buffer);
+ else
+ ch = utf8_to_cp437_stream(c, buffer);
if (!ch)
return 0;
+ } else {
+ ch = c;
}
if (priv->escape) {
diff --git a/include/video_console.h b/include/video_console.h
index 5e6eb3cc81..8747299d61 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -174,7 +174,7 @@ struct vidconsole_ops {
* if all is OK, -EAGAIN if we ran out of space on this line, other -ve
* on error
*/
-int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch);
+int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int ch);
/**
* vidconsole_move_rows() - Move text rows from one place to another
--
2.30.0
More information about the U-Boot
mailing list