Skip to contentSkip to conversation

video: Allow querying the font size

PATCH In review Simon Glass 5 participants 8 messages Jan 8, 2024 – Oct 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 video: Allow querying the font size

All the font size to be queried using the 'font size' command.

---

 cmd/font.c             | 17 +++++++++--------
 doc/usage/cmd/font.rst |  6 ++++--
 test/cmd/font.c        |  9 +++++++++
 3 files changed, 22 insertions(+), 10 deletions(-)
cmd/font.c +9 -8
index cb39c88063f..c7fe2a70a49 100644
@@ -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;
doc/usage/cmd/font.rst +4 -2
index 8ba149d7599..fea0df3f745 100644
@@ -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
     =>
test/cmd/font.c +9 -0
index 1fe05c1ead5..9c1eebf799e 100644
@@ -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);
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 coreboot: Switch to a monospaced font

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.

---

 configs/coreboot64_defconfig |  3 +++
 configs/coreboot_defconfig   |  3 +++
 test/cmd/font.c              | 12 +++++++++---
 3 files changed, 15 insertions(+), 3 deletions(-)
configs/coreboot64_defconfig +3 -0
index 49c982ef756..c4571090859 100644
@@ -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
configs/coreboot_defconfig +3 -0
index d4e44e00dca..7aa841bb54b 100644
@@ -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
test/cmd/font.c +9 -3
index 9c1eebf799e..ee1c610106d 100644
@@ -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;
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] coreboot: Switch to a monospaced font

Quoted 8 lines

From: Simon Glass <[email protected]>
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.

Quoted 68 lines

---

 configs/coreboot64_defconfig |  3 +++
 configs/coreboot_defconfig   |  3 +++
 test/cmd/font.c              | 12 +++++++++---
 3 files changed, 15 insertions(+), 3 deletions(-)
configs/coreboot64_defconfig +3 -0
index 49c982ef756..c4571090859 100644
@@ -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
configs/coreboot_defconfig +3 -0
index d4e44e00dca..7aa841bb54b 100644
@@ -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
test/cmd/font.c +9 -3
index 9c1eebf799e..ee1c610106d 100644
@@ -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;
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 2/2] coreboot: Switch to a monospaced font

Quoted 11 lines · Mark Kettenis
Quoted 8 lines

From: Simon Glass <[email protected]>
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.

Quoted 69 lines
Quoted 69 lines

---

 configs/coreboot64_defconfig |  3 +++
 configs/coreboot_defconfig   |  3 +++
 test/cmd/font.c              | 12 +++++++++---
 3 files changed, 15 insertions(+), 3 deletions(-)
configs/coreboot64_defconfig +3 -0
index 49c982ef756..c4571090859 100644
@@ -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
configs/coreboot_defconfig +3 -0
index d4e44e00dca..7aa841bb54b 100644
@@ -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
test/cmd/font.c +9 -3
index 9c1eebf799e..ee1c610106d 100644
@@ -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

#4 lore raw

Re: [PATCH 2/2] coreboot: Switch to a monospaced font

+ Tom and Anatolij,

Quoted 10 lines · Dragan Simic
Quoted 8 lines · Mark Kettenis
Quoted 8 lines

From: Simon Glass <[email protected]>
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.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

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

#5 lore raw

Re: [PATCH 2/2] coreboot: Switch to a monospaced font

Quoted 18 lines · Bin Meng

+ Tom and Anatolij,

Quoted 15 lines · Dragan Simic
Quoted 12 lines · Mark Kettenis
Quoted 9 lines

From: Simon Glass <[email protected]>
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.

Quoted 7 lines
Quoted 2 lines

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.

Signature · 1 line
Tom
#6 lore raw

Re: [PATCH 2/2] coreboot: Switch to a monospaced font

Quoted 18 lines · Bin Meng

+ Tom and Anatolij,

Quoted 15 lines · Dragan Simic
Quoted 12 lines · Mark Kettenis
Quoted 9 lines

From: Simon Glass <[email protected]>
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.

Quoted 7 lines
Quoted 2 lines

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.

Signature · 3 lines
Tom

Applied to u-boot-dm, thanks!