blob: 9be83bed19597dd45bfec2736b51b2d8c7b0c1fa [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/drivers/video/fonts.c -- `Soft' font definitions
3 *
4 * Created 1995 by Geert Uytterhoeven
5 * Rewritten 1998 by Martin Mares <mj@ucw.cz>
6 *
7 * 2001 - Documented with DocBook
8 * - Brad Douglas <brad@neruo.com>
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/types.h>
18#include <linux/string.h>
19#if defined(__mc68000__) || defined(CONFIG_APUS)
20#include <asm/setup.h>
21#endif
22#include <linux/font.h>
23
24#define NO_FONTS
25
Jan Beulich2f4516d2005-09-13 01:25:44 -070026static const struct font_desc *fonts[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#ifdef CONFIG_FONT_8x8
28#undef NO_FONTS
29 &font_vga_8x8,
30#endif
31#ifdef CONFIG_FONT_8x16
32#undef NO_FONTS
33 &font_vga_8x16,
34#endif
35#ifdef CONFIG_FONT_6x11
36#undef NO_FONTS
37 &font_vga_6x11,
38#endif
Jurriaan303b86d2005-06-21 17:17:06 -070039#ifdef CONFIG_FONT_7x14
40#undef NO_FONTS
41 &font_7x14,
42#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#ifdef CONFIG_FONT_SUN8x16
44#undef NO_FONTS
45 &font_sun_8x16,
46#endif
47#ifdef CONFIG_FONT_SUN12x22
48#undef NO_FONTS
49 &font_sun_12x22,
50#endif
Jurriaan303b86d2005-06-21 17:17:06 -070051#ifdef CONFIG_FONT_10x18
52#undef NO_FONTS
53 &font_10x18,
54#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#ifdef CONFIG_FONT_ACORN_8x8
56#undef NO_FONTS
57 &font_acorn_8x8,
58#endif
59#ifdef CONFIG_FONT_PEARL_8x8
60#undef NO_FONTS
61 &font_pearl_8x8,
62#endif
63#ifdef CONFIG_FONT_MINI_4x6
64#undef NO_FONTS
65 &font_mini_4x6,
66#endif
Zach Smith998e6d52005-11-07 01:00:52 -080067#ifdef CONFIG_FONT_RL
68#undef NO_FONTS
69 &font_rl,
70#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
73#define num_fonts (sizeof(fonts)/sizeof(*fonts))
74
75#ifdef NO_FONTS
76#error No fonts configured.
77#endif
78
79
80/**
81 * find_font - find a font
82 * @name: string name of a font
83 *
84 * Find a specified font with string name @name.
85 *
86 * Returns %NULL if no font found, or a pointer to the
87 * specified font.
88 *
89 */
90
Jan Beulich2f4516d2005-09-13 01:25:44 -070091const struct font_desc *find_font(const char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
93 unsigned int i;
94
95 for (i = 0; i < num_fonts; i++)
96 if (!strcmp(fonts[i]->name, name))
97 return fonts[i];
98 return NULL;
99}
100
101
102/**
103 * get_default_font - get default font
104 * @xres: screen size of X
105 * @yres: screen size of Y
106 *
107 * Get the default font for a specified screen size.
108 * Dimensions are in pixels.
109 *
110 * Returns %NULL if no font is found, or a pointer to the
111 * chosen font.
112 *
113 */
114
Jan Beulich2f4516d2005-09-13 01:25:44 -0700115const struct font_desc *get_default_font(int xres, int yres)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
117 int i, c, cc;
Jan Beulich2f4516d2005-09-13 01:25:44 -0700118 const struct font_desc *f, *g;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120 g = NULL;
121 cc = -10000;
122 for(i=0; i<num_fonts; i++) {
123 f = fonts[i];
124 c = f->pref;
125#if defined(__mc68000__) || defined(CONFIG_APUS)
126#ifdef CONFIG_FONT_PEARL_8x8
127 if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX)
128 c = 100;
129#endif
130#ifdef CONFIG_FONT_6x11
131 if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX)
132 c = 100;
133#endif
134#endif
135 if ((yres < 400) == (f->height <= 8))
136 c += 1000;
137 if (c > cc) {
138 cc = c;
139 g = f;
140 }
141 }
142 return g;
143}
144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145EXPORT_SYMBOL(find_font);
146EXPORT_SYMBOL(get_default_font);
147
148MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
149MODULE_DESCRIPTION("Console Fonts");
150MODULE_LICENSE("GPL");