[PATCH 1/2] video: Allow querying the font size

All the font size to be queried using the 'font size' command.
Signed-off-by: Simon Glass sjg@chromium.org ---
cmd/font.c | 17 +++++++++-------- doc/usage/cmd/font.rst | 6 ++++-- test/cmd/font.c | 9 +++++++++ 3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/cmd/font.c b/cmd/font.c index cb39c88063f..c7fe2a70a49 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -56,9 +56,6 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, uint size; int ret;
- if (argc != 2) - return CMD_RET_USAGE; - if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) return CMD_RET_FAILURE; ret = vidconsole_get_font_size(dev, &font_name, &size); @@ -67,12 +64,16 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; }
- size = dectoul(argv[1], NULL); + if (argc < 2) { + printf("%d\n", size); + } else { + size = dectoul(argv[1], NULL);
- ret = vidconsole_select_font(dev, font_name, size); - if (ret) { - printf("Failed (error %d)\n", ret); - return CMD_RET_FAILURE; + ret = vidconsole_select_font(dev, font_name, size); + if (ret) { + printf("Failed (error %d)\n", ret); + return CMD_RET_FAILURE; + } }
return 0; diff --git a/doc/usage/cmd/font.rst b/doc/usage/cmd/font.rst index 8ba149d7599..fea0df3f745 100644 --- a/doc/usage/cmd/font.rst +++ b/doc/usage/cmd/font.rst @@ -10,7 +10,7 @@ Synopis
font list font select <name> [<size>] - font size <size> + font size [<size>]
Description ----------- @@ -31,7 +31,7 @@ This selects a new font and optionally changes the size. font size ~~~~~~~~~
-This changes the font size only. +This changes the font size only. With no argument it shows the current size.
Examples -------- @@ -41,6 +41,8 @@ Examples => font list nimbus_sans_l_regular cantoraone_regular + => font size + 30 => font size 40 => font select cantoraone_regular 20 => diff --git a/test/cmd/font.c b/test/cmd/font.c index 1fe05c1ead5..9c1eebf799e 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -60,10 +60,19 @@ static int font_test_base(struct unit_test_state *uts) ut_assertok(vidconsole_get_font_size(dev, &name, &size)); ut_asserteq_str("cantoraone_regular", name); ut_asserteq(40, size); + ut_assertok(ut_check_console_end(uts)); + + ut_assertok(run_command("font size", 0)); + ut_assert_nextline("40"); + ut_assertok(ut_check_console_end(uts));
ut_assertok(run_command("font size 30", 0)); ut_assertok(ut_check_console_end(uts));
+ ut_assertok(run_command("font size", 0)); + ut_assert_nextline("30"); + ut_assertok(ut_check_console_end(uts)); + ut_assertok(vidconsole_get_font_size(dev, &name, &size)); ut_asserteq_str("cantoraone_regular", name); ut_asserteq(30, size);

The default font is proportional, with different character widths. Select a monospace font for coreboot so that the 'dm tree' output lines up correctly.
Update the coreboot tests to match.
Signed-off-by: Simon Glass sjg@chromium.org ---
configs/coreboot64_defconfig | 3 +++ configs/coreboot_defconfig | 3 +++ test/cmd/font.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/configs/coreboot64_defconfig b/configs/coreboot64_defconfig index 49c982ef756..c4571090859 100644 --- a/configs/coreboot64_defconfig +++ b/configs/coreboot64_defconfig @@ -64,6 +64,9 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_SIZE=20 +# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set +CONFIG_CONSOLE_TRUETYPE_ANKACODER=y CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_SPL_ACPI=y CONFIG_CMD_DHRYSTONE=y diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig index d4e44e00dca..7aa841bb54b 100644 --- a/configs/coreboot_defconfig +++ b/configs/coreboot_defconfig @@ -61,6 +61,9 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_SIZE=20 +# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set +CONFIG_CONSOLE_TRUETYPE_ANKACODER=y CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_CMD_DHRYSTONE=y # CONFIG_GZIP is not set diff --git a/test/cmd/font.c b/test/cmd/font.c index 9c1eebf799e..ee1c610106d 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -29,14 +29,20 @@ static int font_test_base(struct unit_test_state *uts)
ut_assertok(console_record_reset_enable()); ut_assertok(run_command("font list", 0)); - ut_assert_nextline("nimbus_sans_l_regular"); + if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_NIMBUS)) + ut_assert_nextline("nimbus_sans_l_regular"); + if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER)) + ut_assert_nextline("ankacoder_c75_r"); if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE)) ut_assert_nextline("cantoraone_regular"); ut_assertok(ut_check_console_end(uts));
ut_assertok(vidconsole_get_font_size(dev, &name, &size)); - ut_asserteq_str("nimbus_sans_l_regular", name); - ut_asserteq(18, size); + if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER)) + ut_asserteq_str("ankacoder_c75_r", name); + else + ut_asserteq_str("nimbus_sans_l_regular", name); + ut_asserteq(CONFIG_CONSOLE_TRUETYPE_SIZE, size);
if (!IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE)) return 0;

From: Simon Glass sjg@chromium.org Date: Sun, 7 Jan 2024 17:14:55 -0700
The default font is proportional, with different character widths. Select a monospace font for coreboot so that the 'dm tree' output lines up correctly.
Update the coreboot tests to match.
To be honest, I think defaulting to a proportional font is wrong as a default for something like U-Boot.
Signed-off-by: Simon Glass sjg@chromium.org
configs/coreboot64_defconfig | 3 +++ configs/coreboot_defconfig | 3 +++ test/cmd/font.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/configs/coreboot64_defconfig b/configs/coreboot64_defconfig index 49c982ef756..c4571090859 100644 --- a/configs/coreboot64_defconfig +++ b/configs/coreboot64_defconfig @@ -64,6 +64,9 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_SIZE=20 +# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set +CONFIG_CONSOLE_TRUETYPE_ANKACODER=y CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_SPL_ACPI=y CONFIG_CMD_DHRYSTONE=y diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig index d4e44e00dca..7aa841bb54b 100644 --- a/configs/coreboot_defconfig +++ b/configs/coreboot_defconfig @@ -61,6 +61,9 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_SIZE=20 +# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set +CONFIG_CONSOLE_TRUETYPE_ANKACODER=y CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_CMD_DHRYSTONE=y # CONFIG_GZIP is not set diff --git a/test/cmd/font.c b/test/cmd/font.c index 9c1eebf799e..ee1c610106d 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -29,14 +29,20 @@ static int font_test_base(struct unit_test_state *uts)
ut_assertok(console_record_reset_enable()); ut_assertok(run_command("font list", 0));
- ut_assert_nextline("nimbus_sans_l_regular");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_NIMBUS))
ut_assert_nextline("nimbus_sans_l_regular");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER))
ut_assert_nextline("ankacoder_c75_r");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE)) ut_assert_nextline("cantoraone_regular"); ut_assertok(ut_check_console_end(uts));
ut_assertok(vidconsole_get_font_size(dev, &name, &size));
- ut_asserteq_str("nimbus_sans_l_regular", name);
- ut_asserteq(18, size);
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER))
ut_asserteq_str("ankacoder_c75_r", name);
else
ut_asserteq_str("nimbus_sans_l_regular", name);
ut_asserteq(CONFIG_CONSOLE_TRUETYPE_SIZE, size);
if (!IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE)) return 0;
-- 2.34.1

On 2024-01-08 10:29, Mark Kettenis wrote:
From: Simon Glass sjg@chromium.org Date: Sun, 7 Jan 2024 17:14:55 -0700
The default font is proportional, with different character widths. Select a monospace font for coreboot so that the 'dm tree' output lines up correctly.
Update the coreboot tests to match.
To be honest, I think defaulting to a proportional font is wrong as a default for something like U-Boot.
I agree, it makes very little sense to default to a proportional font.
Signed-off-by: Simon Glass sjg@chromium.org
configs/coreboot64_defconfig | 3 +++ configs/coreboot_defconfig | 3 +++ test/cmd/font.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/configs/coreboot64_defconfig b/configs/coreboot64_defconfig index 49c982ef756..c4571090859 100644 --- a/configs/coreboot64_defconfig +++ b/configs/coreboot64_defconfig @@ -64,6 +64,9 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_SIZE=20 +# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set +CONFIG_CONSOLE_TRUETYPE_ANKACODER=y CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_SPL_ACPI=y CONFIG_CMD_DHRYSTONE=y diff --git a/configs/coreboot_defconfig b/configs/coreboot_defconfig index d4e44e00dca..7aa841bb54b 100644 --- a/configs/coreboot_defconfig +++ b/configs/coreboot_defconfig @@ -61,6 +61,9 @@ CONFIG_SOUND=y CONFIG_SOUND_I8254=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_TRUETYPE=y +CONFIG_CONSOLE_TRUETYPE_SIZE=20 +# CONFIG_CONSOLE_TRUETYPE_NIMBUS is not set +CONFIG_CONSOLE_TRUETYPE_ANKACODER=y CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_CMD_DHRYSTONE=y # CONFIG_GZIP is not set diff --git a/test/cmd/font.c b/test/cmd/font.c index 9c1eebf799e..ee1c610106d 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -29,14 +29,20 @@ static int font_test_base(struct unit_test_state *uts)
ut_assertok(console_record_reset_enable()); ut_assertok(run_command("font list", 0));
- ut_assert_nextline("nimbus_sans_l_regular");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_NIMBUS))
ut_assert_nextline("nimbus_sans_l_regular");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER))
ut_assert_nextline("ankacoder_c75_r");
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE)) ut_assert_nextline("cantoraone_regular"); ut_assertok(ut_check_console_end(uts));
ut_assertok(vidconsole_get_font_size(dev, &name, &size));
- ut_asserteq_str("nimbus_sans_l_regular", name);
- ut_asserteq(18, size);
if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER))
ut_asserteq_str("ankacoder_c75_r", name);
else
ut_asserteq_str("nimbus_sans_l_regular", name);
ut_asserteq(CONFIG_CONSOLE_TRUETYPE_SIZE, size);
if (!IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_CANTORAONE)) return 0;
-- 2.34.1

+ Tom and Anatolij,
On Mon, Jan 8, 2024 at 5:33 PM Dragan Simic dsimic@manjaro.org wrote:
On 2024-01-08 10:29, Mark Kettenis wrote:
From: Simon Glass sjg@chromium.org Date: Sun, 7 Jan 2024 17:14:55 -0700
The default font is proportional, with different character widths. Select a monospace font for coreboot so that the 'dm tree' output lines up correctly.
Update the coreboot tests to match.
To be honest, I think defaulting to a proportional font is wrong as a default for something like U-Boot.
I agree, it makes very little sense to default to a proportional font.
So we should revert
commit b093753471c1a30d680868a9f4d9f6db090bf0b7 ("video: Add a default TrueType font")
Regards, Bin

On Mon, Jan 08, 2024 at 09:09:39PM +0800, Bin Meng wrote:
- Tom and Anatolij,
On Mon, Jan 8, 2024 at 5:33 PM Dragan Simic dsimic@manjaro.org wrote:
On 2024-01-08 10:29, Mark Kettenis wrote:
From: Simon Glass sjg@chromium.org Date: Sun, 7 Jan 2024 17:14:55 -0700
The default font is proportional, with different character widths. Select a monospace font for coreboot so that the 'dm tree' output lines up correctly.
Update the coreboot tests to match.
To be honest, I think defaulting to a proportional font is wrong as a default for something like U-Boot.
I agree, it makes very little sense to default to a proportional font.
So we should revert
commit b093753471c1a30d680868a9f4d9f6db090bf0b7 ("video: Add a default TrueType font")
Well, I would "fixes" that commit and drop default y there and instead make the monospace font the default and explain why the switch, rather than revert.

On Mon, Jan 08, 2024 at 09:09:39PM +0800, Bin Meng wrote:
- Tom and Anatolij,
On Mon, Jan 8, 2024 at 5:33 PM Dragan Simic dsimic@manjaro.org wrote:
On 2024-01-08 10:29, Mark Kettenis wrote:
From: Simon Glass sjg@chromium.org Date: Sun, 7 Jan 2024 17:14:55 -0700
The default font is proportional, with different character widths. Select a monospace font for coreboot so that the 'dm tree' output lines up correctly.
Update the coreboot tests to match.
To be honest, I think defaulting to a proportional font is wrong as a default for something like U-Boot.
I agree, it makes very little sense to default to a proportional font.
So we should revert
commit b093753471c1a30d680868a9f4d9f6db090bf0b7 ("video: Add a default TrueType font")
Well, I would "fixes" that commit and drop default y there and instead make the monospace font the default and explain why the switch, rather than revert.

All the font size to be queried using the 'font size' command.
Signed-off-by: Simon Glass sjg@chromium.org ---
cmd/font.c | 17 +++++++++-------- doc/usage/cmd/font.rst | 6 ++++-- test/cmd/font.c | 9 +++++++++ 3 files changed, 22 insertions(+), 10 deletions(-)
Applied to u-boot-dm, thanks!
participants (5)
-
Bin Meng
-
Dragan Simic
-
Mark Kettenis
-
Simon Glass
-
Tom Rini