Skip to content

vc,fbcon,fonts: Proper handling of font data

Thomas Zimmermann dri-devel linux-fbdev lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest13 patches 1 replyIn review
  2. v213 patches 9 repliesSuperseded
  3. v113 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- fix module font linking (Nathan, Arnd)
- fix typos (Helge)
- clarify return value of font_data_put()

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13fbdev: Declare src parameter of fb_pad_ helpers as constantdrivers/video/fbdev/core/fbmem.c include/linux/fb.h+8 -80 replies
2/13vt: Remove trailing whitespacesinclude/linux/console_struct.h+1 -10 replies
3/13vt: Store font in struct vc_fontdrivers/video/fbdev/core/bitblit.c drivers/video/fbdev/core/fbcon.c drivers/video/fbdev/core/fbcon.h +1 more+36 -120 replies
4/13vt: Calculate font-buffer size with vc_font_size()drivers/video/fbdev/core/fbcon.c include/linux/console_struct.h+30 -70 replies
5/13lib/fonts: Remove trailing whitespaceslib/fonts/font_acorn_8x8.c lib/fonts/font_mini_4x6.c+5 -50 replies
6/13lib/fonts: Remove FNTCHARCNT()drivers/video/console/newport_con.c include/linux/font.h+0 -20 replies
7/13lib/fonts: Store font data as font_data_t; update consolesdrivers/video/console/newport_con.c drivers/video/fbdev/core/fbcon.c drivers/video/fbdev/core/fbcon.h +1 more+84 -270 replies
8/13lib/fonts: Read font size with font_data_size()drivers/video/console/newport_con.c drivers/video/fbdev/core/fbcon.c include/linux/font.h +1 more+31 -80 replies
9/13lib/fonts: Manage font-data lifetime with font_data_get/_put()drivers/video/console/newport_con.c drivers/video/fbdev/core/fbcon.c drivers/video/fbdev/core/fbcon.h +2 more+115 -530 replies
10/13lib/fonts: Compare font data for equality with font_data_is_equal()drivers/video/console/newport_con.c drivers/video/fbdev/core/fbcon.c include/linux/font.h +1 more+29 -90 replies
11/13lib/fonts: Create font_data_t from struct console_font with font_data_import()drivers/video/console/newport_con.c drivers/video/fbdev/core/fbcon.c include/linux/font.h +1 more+75 -530 replies
12/13lib/fonts: Store font data for user space with font_data_export()drivers/video/fbdev/core/fbcon.c include/linux/font.h lib/fonts/fonts.c+43 -550 replies
13/13lib/fonts: Remove internal symbols and macros from public header fileinclude/linux/font.h lib/fonts/font.h lib/fonts/font_10x18.c +14 more+85 -550 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 00/13] vc,fbcon,fonts: Proper handling of font data

Provide helpers for handling console font data. Update consoles and VT.

VT's vc_state stores font data as a plain byte array of glphys. Fbcon, newport_con and the kernel's internal fonts store the glyph data as an array of plain bytes plus a hidden header for reference counting, check sums and buffer sizes. The reference counting only works for user-space fonts but not for internal fonts. Font-data handling is duplicated in several places. Most of the font handling is open-coded and mixed up with VT's plain glyph arrays.

To address these issues, add proper handling of font data to all involved
components: struct vc_font for font state in VC; a font data type for the consoles. Then implement interfaces for handling font data one by one.

Patch 1 prepares the fbdev interface.

Patches 2 to 4 prepare VT's font handling.

Patches 5 to 13 refactor fbcon and newport_con to use clean interfaces for their fonts.

Fbcon has long been a source of problems and bug reports. [1] With its confusing implementation, it is hard to find the cause of these bugs. Cleaning up the fbcon code will hopefully help with resolving bug reports in the future.

The series has been tested with fbcon under DRM's bochs driver by changing fonts at runtime using the setfont utility. [2] The changes to newport_con have only been tested to compile.

v3:
- fix module font linking (Nathan, Arnd)
- fix typos (Helge)
- clarify return value of font_data_put()
v2:
- keep declaring the internal fonts in the public header file (Helge)
- rebase and clean up

[1] https://lore.kernel.org/all/[email protected]/
[2] https://www.man7.org/linux/man-pages/man8/setfont.8.html

Thomas Zimmermann (13):
fbdev: Declare src parameter of fb_pad_ helpers as constant
vt: Remove trailing whitespaces
vt: Store font in struct vc_font
vt: Calculate font-buffer size with vc_font_size() lib/fonts: Remove trailing whitespaces
lib/fonts: Remove FNTCHARCNT()
lib/fonts: Store font data as font_data_t; update consoles lib/fonts: Read font size with font_data_size()
lib/fonts: Manage font-data lifetime with font_data_get/_put() lib/fonts: Compare font data for equality with font_data_is_equal() lib/fonts: Create font_data_t from struct console_font with
font_data_import()
lib/fonts: Store font data for user space with font_data_export() lib/fonts: Remove internal symbols and macros from public header file

 drivers/video/console/newport_con.c |  61 +++-----
 drivers/video/fbdev/core/bitblit.c  |  11 +-
 drivers/video/fbdev/core/fbcon.c    | 194 +++++++----------------
 drivers/video/fbdev/core/fbcon.h    |   8 +-
 drivers/video/fbdev/core/fbmem.c    |   6 +-
 include/linux/console_struct.h      |  59 ++++++-
 include/linux/fb.h                  |  10 +-
 include/linux/font.h                | 115 +++++++++-----
 lib/fonts/font.h                    |  38 +++++
 lib/fonts/font_10x18.c              |   2 +-
 lib/fonts/font_6x10.c               |   3 +-
 lib/fonts/font_6x11.c               |   2 +-
 lib/fonts/font_6x8.c                |   3 +-
 lib/fonts/font_7x14.c               |   2 +-
 lib/fonts/font_8x16.c               |   3 +-
 lib/fonts/font_8x8.c                |   2 +-
 lib/fonts/font_acorn_8x8.c          |   4 +-
 lib/fonts/font_mini_4x6.c           |  10 +-
 lib/fonts/font_pearl_8x8.c          |   2 +-
 lib/fonts/font_sun12x22.c           |   3 +-
 lib/fonts/font_sun8x16.c            |   3 +-
 lib/fonts/font_ter10x18.c           |   4 +-
 lib/fonts/font_ter16x32.c           |   4 +-
 lib/fonts/fonts.c                   | 232 +++++++++++++++++++++++++++-
 24 files changed, 514 insertions(+), 267 deletions(-)
 create mode 100644 lib/fonts/font.h

base-commit: 3594e3a9ce7d4ad237f43ff907e9744446108603
prerequisite-patch-id: c67e5d886a47b7d0266d81100837557fda34cb24
prerequisite-patch-id: a5a973e527c88a5b47053d7a72aefe0b550197cb
prerequisite-patch-id: 719d09751d38f5da743beed6266585ee063e1e29
prerequisite-patch-id: 5030de433a01c2e99056cadb676a8e2ba35f055a
prerequisite-patch-id: f7831e8fe81681bbe7fcd7b8455753f5ab4ada2d

Signature · 1 line
2.53.0