lib/fonts: Remove internal symbols and macros from public header file

Define access macros for font_data_t in fonts.c. Define struct font_data
and declare most of the font symbols in the internal header font.h, where
they can only be seen by the font code.

Also move font indices into internal font.h. They appear to be unused
though. There is m86k assembly code that operates on the idx field, so
leave them in place for now.

List all built-in fonts in a separate section in the public header file.

v2:
- do not add config guards around font symbols (Helge)
- keep declaration of built-in fonts in public header

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>
master
Thomas Zimmermann 2026-03-09 15:14:55 +01:00 committed by Helge Deller
parent c37bd7c8d3
commit db65872b38
17 changed files with 85 additions and 55 deletions

View File

@ -77,36 +77,6 @@ struct font_desc {
int pref;
};
#define VGA8x8_IDX 0
#define VGA8x16_IDX 1
#define PEARL8x8_IDX 2
#define VGA6x11_IDX 3
#define FONT7x14_IDX 4
#define FONT10x18_IDX 5
#define SUN8x16_IDX 6
#define SUN12x22_IDX 7
#define ACORN8x8_IDX 8
#define MINI4x6_IDX 9
#define FONT6x10_IDX 10
#define TER16x32_IDX 11
#define FONT6x8_IDX 12
#define TER10x18_IDX 13
extern const struct font_desc font_vga_8x8,
font_vga_8x16,
font_pearl_8x8,
font_vga_6x11,
font_7x14,
font_10x18,
font_sun_8x16,
font_sun_12x22,
font_acorn_8x8,
font_mini_4x6,
font_6x10,
font_ter_16x32,
font_6x8,
font_ter_10x18;
/* Find a font with a specific name */
extern const struct font_desc *find_font(const char *name);
@ -120,16 +90,23 @@ extern const struct font_desc *get_default_font(int xres, int yres,
/* Max. length for the name of a predefined font */
#define MAX_FONT_NAME 32
/* Extra word getters */
#define REFCOUNT(fd) (((int *)(fd))[-1])
#define FNTSIZE(fd) (((int *)(fd))[-2])
#define FNTSUM(fd) (((int *)(fd))[-4])
/*
* Built-in fonts
*/
#define FONT_EXTRA_WORDS 4
struct font_data {
unsigned int extra[FONT_EXTRA_WORDS];
unsigned char data[];
} __packed;
extern const struct font_desc font_10x18;
extern const struct font_desc font_6x10;
extern const struct font_desc font_6x8;
extern const struct font_desc font_7x14;
extern const struct font_desc font_acorn_8x8;
extern const struct font_desc font_mini_4x6;
extern const struct font_desc font_pearl_8x8;
extern const struct font_desc font_sun_12x22;
extern const struct font_desc font_sun_8x16;
extern const struct font_desc font_ter_10x18;
extern const struct font_desc font_ter_16x32;
extern const struct font_desc font_vga_6x11;
extern const struct font_desc font_vga_8x16;
extern const struct font_desc font_vga_8x8;
#endif /* _VIDEO_FONT_H */

38
lib/fonts/font.h Normal file
View File

@ -0,0 +1,38 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LIB_FONTS_FONT_H
#define _LIB_FONTS_FONT_H
#include <linux/font.h>
/*
* Font data
*/
#define FONT_EXTRA_WORDS 4
struct font_data {
unsigned int extra[FONT_EXTRA_WORDS];
unsigned char data[];
} __packed;
/*
* Built-in fonts
*/
#define VGA8x8_IDX 0
#define VGA8x16_IDX 1
#define PEARL8x8_IDX 2
#define VGA6x11_IDX 3
#define FONT7x14_IDX 4
#define FONT10x18_IDX 5
#define SUN8x16_IDX 6
#define SUN12x22_IDX 7
#define ACORN8x8_IDX 8
#define MINI4x6_IDX 9
#define FONT6x10_IDX 10
#define TER16x32_IDX 11
#define FONT6x8_IDX 12
#define TER10x18_IDX 13
#endif

View File

@ -4,7 +4,7 @@
* by Jurriaan Kalkman 06-2005 *
********************************/
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 9216

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 2560

View File

@ -5,7 +5,7 @@
/* */
/**********************************************/
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX (11*256)

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 2048

View File

@ -4,7 +4,7 @@
/* by Jurriaan Kalkman 05-2005 */
/**************************************/
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 3584

View File

@ -5,9 +5,10 @@
/* */
/**********************************************/
#include <linux/font.h>
#include <linux/module.h>
#include "font.h"
#define FONTDATAMAX 4096
static const struct font_data fontdata_8x16 = {

View File

@ -5,7 +5,7 @@
/* */
/**********************************************/
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 2048

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Acorn-like font definition, with PC graphics characters */
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 2048

View File

@ -39,7 +39,7 @@ __END__;
MSBit to LSBit = left to right.
*/
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 1536

View File

@ -10,7 +10,7 @@
/* */
/**********************************************/
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 2048

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 11264

View File

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#include "font.h"
#define FONTDATAMAX 4096

View File

@ -1,7 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#include <linux/module.h>
#include "font.h"
#define FONTDATAMAX 9216
static const struct font_data fontdata_ter10x18 = {

View File

@ -1,7 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/font.h>
#include <linux/module.h>
#include "font.h"
#define FONTDATAMAX 16384
static const struct font_data fontdata_ter16x32 = {

View File

@ -13,7 +13,6 @@
*/
#include <linux/container_of.h>
#include <linux/font.h>
#include <linux/kd.h>
#include <linux/module.h>
#include <linux/overflow.h>
@ -25,12 +24,19 @@
#include <asm/setup.h>
#endif
#include "font.h"
#define console_font_pitch(font) DIV_ROUND_UP((font)->width, 8)
/*
* Helpers for font_data_t
*/
/* Extra word getters */
#define REFCOUNT(fd) (((int *)(fd))[-1])
#define FNTSIZE(fd) (((int *)(fd))[-2])
#define FNTSUM(fd) (((int *)(fd))[-4])
static struct font_data *to_font_data_struct(font_data_t *fd)
{
return container_of(fd, struct font_data, data[0]);