summaryrefslogtreecommitdiffstats
path: root/lib/fonts/fonts.c
blob: 5a9d3f11f01d9c66bc530fae804e3ed47587cbe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * `Soft' font definitions
 *
 *    Created 1995 by Geert Uytterhoeven
 *    Rewritten 1998 by Martin Mares <mj@ucw.cz>
 *
 *	2001 - Documented with DocBook
 *	- Brad Douglas <brad@neruo.com>
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file COPYING in the main directory of this archive
 * for more details.
 */

#include <module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/font.h>

#define NO_FONTS

static const struct font_desc *fonts[] = {
#ifdef CONFIG_FONT_8x16
#undef NO_FONTS
    &font_vga_8x16,
#endif
#ifdef CONFIG_FONT_7x14
#undef NO_FONTS
    &font_7x14,
#endif
#ifdef CONFIG_FONT_MINI_4x6
#undef NO_FONTS
    &font_mini_4x6,
#endif
};

#define num_fonts ARRAY_SIZE(fonts)

#ifdef NO_FONTS
#error No fonts configured.
#endif

static char *font_names;

const struct font_desc *find_font_enum(int n)
{
	if (n > num_fonts)
		return NULL;

	return fonts[n];
}

struct param_d *add_param_font(struct device_d *dev,
		int (*set)(struct param_d *p, void *priv),
		int (*get)(struct param_d *p, void *priv),
		int *value, void *priv)
{
	unsigned int i;

	if (!font_names) {
		font_names = xmalloc(sizeof(char *) * num_fonts);

		for (i = 0; i < num_fonts; i++)
			((const char **)font_names)[i] = fonts[i]->name;
	}

	return dev_add_param_enum(dev, "font",
			set, get, value,
			(const char **)font_names, num_fonts, priv);
}

MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
MODULE_DESCRIPTION("Console Fonts");
MODULE_LICENSE("GPL");