Re: [PATCH v2 03/13] vt: Store font in struct vc_font
flat view
From: Helge Deller <deller@gmx.de>
Date: 2026-03-03 14:31:55
Also in:
dri-devel, lkml
On 3/2/26 15:08, Thomas Zimmermann wrote:
Replace struct console_font with struct vc_font for the type of the vc_font field of struct vc_data. Struct console_font is UAPI, which prevents further changes. Hence a new data type is required. Struct console_font has a documented vertical pitch of 32 bytes. This is not the case after the font data has been loaded into the kernel. Changing the type of vc_font addresses this inconsistency. The font data is now declared as constant, as it might come from the kernel's read-only section. There's some fallout throughout the console code where non-const variables refer to it. Fix them. A later update will declare the font data to a dedicated data type. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> --- drivers/video/fbdev/core/bitblit.c | 11 +++++------ drivers/video/fbdev/core/fbcon.c | 4 ++-- drivers/video/fbdev/core/fbcon.h | 4 ++-- include/linux/console_struct.h | 29 +++++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 12 deletions(-)
....
quoted hunk ↗ jump to hunk
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index ebdb9750d348..7fdcae6ed49c 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h@@ -13,8 +13,9 @@ #ifndef _LINUX_CONSOLE_STRUCT_H #define _LINUX_CONSOLE_STRUCT_H -#include <linux/wait.h> +#include <linux/math.h> #include <linux/vt.h> +#include <linux/wait.h> #include <linux/workqueue.h> struct uni_pagedict;@@ -58,6 +59,30 @@ struct vc_state { bool reverse; }; +/** + * struct vc_font - Describes a font + * @width: The width of a single glyph in bits + * @height: The height of a single glyph in scanlines + * @charcount: The number of glyphs in the font + * @data: The raw font data + * + * Font data is organized as an array of glyphs. Each glyph is a bitmap with + * set bits indicating the foreground color. Unset bits indicate background + * color. The fields @width and @height store a single glyph's number of + * horizontal bits and vertical scanlines. If width is not a multiple of 8, + * there are trailing bits to fill up the byte. These bits should not be drawn. + * + * The field @data points to the first glphy's first byte. The value @charcount + * gives the number of glyphs in the font. There are no empty scanlines between + * two adjacent glyphs. + */ +struct vc_font { + unsigned int width; + unsigned int height; + unsigned int charcount;
I wonder if we shouldn't declare width and height as "u8" or "short int" type? And charcount as u16 or "short int" ? Makes later calculations shorter & easier. Helge