]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
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 | ||
26 | static struct font_desc *fonts[] = { | |
27 | #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 | |
303b86d9 J |
39 | #ifdef CONFIG_FONT_7x14 |
40 | #undef NO_FONTS | |
41 | &font_7x14, | |
42 | #endif | |
1da177e4 LT |
43 | #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 | |
303b86d9 J |
51 | #ifdef CONFIG_FONT_10x18 |
52 | #undef NO_FONTS | |
53 | &font_10x18, | |
54 | #endif | |
1da177e4 LT |
55 | #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 | |
67 | }; | |
68 | ||
69 | #define num_fonts (sizeof(fonts)/sizeof(*fonts)) | |
70 | ||
71 | #ifdef NO_FONTS | |
72 | #error No fonts configured. | |
73 | #endif | |
74 | ||
75 | ||
76 | /** | |
77 | * find_font - find a font | |
78 | * @name: string name of a font | |
79 | * | |
80 | * Find a specified font with string name @name. | |
81 | * | |
82 | * Returns %NULL if no font found, or a pointer to the | |
83 | * specified font. | |
84 | * | |
85 | */ | |
86 | ||
87 | struct font_desc *find_font(char *name) | |
88 | { | |
89 | unsigned int i; | |
90 | ||
91 | for (i = 0; i < num_fonts; i++) | |
92 | if (!strcmp(fonts[i]->name, name)) | |
93 | return fonts[i]; | |
94 | return NULL; | |
95 | } | |
96 | ||
97 | ||
98 | /** | |
99 | * get_default_font - get default font | |
100 | * @xres: screen size of X | |
101 | * @yres: screen size of Y | |
102 | * | |
103 | * Get the default font for a specified screen size. | |
104 | * Dimensions are in pixels. | |
105 | * | |
106 | * Returns %NULL if no font is found, or a pointer to the | |
107 | * chosen font. | |
108 | * | |
109 | */ | |
110 | ||
111 | struct font_desc *get_default_font(int xres, int yres) | |
112 | { | |
113 | int i, c, cc; | |
114 | struct font_desc *f, *g; | |
115 | ||
116 | g = NULL; | |
117 | cc = -10000; | |
118 | for(i=0; i<num_fonts; i++) { | |
119 | f = fonts[i]; | |
120 | c = f->pref; | |
121 | #if defined(__mc68000__) || defined(CONFIG_APUS) | |
122 | #ifdef CONFIG_FONT_PEARL_8x8 | |
123 | if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX) | |
124 | c = 100; | |
125 | #endif | |
126 | #ifdef CONFIG_FONT_6x11 | |
127 | if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX) | |
128 | c = 100; | |
129 | #endif | |
130 | #endif | |
131 | if ((yres < 400) == (f->height <= 8)) | |
132 | c += 1000; | |
133 | if (c > cc) { | |
134 | cc = c; | |
135 | g = f; | |
136 | } | |
137 | } | |
138 | return g; | |
139 | } | |
140 | ||
141 | EXPORT_SYMBOL(fonts); | |
142 | EXPORT_SYMBOL(find_font); | |
143 | EXPORT_SYMBOL(get_default_font); | |
144 | ||
145 | MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); | |
146 | MODULE_DESCRIPTION("Console Fonts"); | |
147 | MODULE_LICENSE("GPL"); |