Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
ee89bd6b | 2 | * `Soft' font definitions |
1da177e4 LT |
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 | ||
1da177e4 LT |
15 | #include <linux/module.h> |
16 | #include <linux/types.h> | |
17 | #include <linux/string.h> | |
7b892806 | 18 | #if defined(__mc68000__) |
1da177e4 LT |
19 | #include <asm/setup.h> |
20 | #endif | |
21 | #include <linux/font.h> | |
22 | ||
23 | #define NO_FONTS | |
24 | ||
2f4516db | 25 | static const struct font_desc *fonts[] = { |
1da177e4 LT |
26 | #ifdef CONFIG_FONT_8x8 |
27 | #undef NO_FONTS | |
28 | &font_vga_8x8, | |
29 | #endif | |
30 | #ifdef CONFIG_FONT_8x16 | |
31 | #undef NO_FONTS | |
32 | &font_vga_8x16, | |
33 | #endif | |
34 | #ifdef CONFIG_FONT_6x11 | |
35 | #undef NO_FONTS | |
36 | &font_vga_6x11, | |
37 | #endif | |
303b86d9 J |
38 | #ifdef CONFIG_FONT_7x14 |
39 | #undef NO_FONTS | |
40 | &font_7x14, | |
41 | #endif | |
1da177e4 LT |
42 | #ifdef CONFIG_FONT_SUN8x16 |
43 | #undef NO_FONTS | |
44 | &font_sun_8x16, | |
45 | #endif | |
46 | #ifdef CONFIG_FONT_SUN12x22 | |
47 | #undef NO_FONTS | |
48 | &font_sun_12x22, | |
49 | #endif | |
303b86d9 J |
50 | #ifdef CONFIG_FONT_10x18 |
51 | #undef NO_FONTS | |
52 | &font_10x18, | |
53 | #endif | |
1da177e4 LT |
54 | #ifdef CONFIG_FONT_ACORN_8x8 |
55 | #undef NO_FONTS | |
56 | &font_acorn_8x8, | |
57 | #endif | |
58 | #ifdef CONFIG_FONT_PEARL_8x8 | |
59 | #undef NO_FONTS | |
60 | &font_pearl_8x8, | |
61 | #endif | |
62 | #ifdef CONFIG_FONT_MINI_4x6 | |
63 | #undef NO_FONTS | |
64 | &font_mini_4x6, | |
65 | #endif | |
33ac9dba MH |
66 | #ifdef CONFIG_FONT_6x10 |
67 | #undef NO_FONTS | |
68 | &font_6x10, | |
69 | #endif | |
1da177e4 LT |
70 | }; |
71 | ||
d1ae418e | 72 | #define num_fonts ARRAY_SIZE(fonts) |
1da177e4 LT |
73 | |
74 | #ifdef NO_FONTS | |
75 | #error No fonts configured. | |
76 | #endif | |
77 | ||
78 | ||
79 | /** | |
80 | * find_font - find a font | |
81 | * @name: string name of a font | |
82 | * | |
83 | * Find a specified font with string name @name. | |
84 | * | |
85 | * Returns %NULL if no font found, or a pointer to the | |
86 | * specified font. | |
87 | * | |
88 | */ | |
89 | ||
2f4516db | 90 | const struct font_desc *find_font(const char *name) |
1da177e4 LT |
91 | { |
92 | unsigned int i; | |
93 | ||
94 | for (i = 0; i < num_fonts; i++) | |
95 | if (!strcmp(fonts[i]->name, name)) | |
96 | return fonts[i]; | |
97 | return NULL; | |
98 | } | |
99 | ||
100 | ||
101 | /** | |
102 | * get_default_font - get default font | |
103 | * @xres: screen size of X | |
104 | * @yres: screen size of Y | |
2d2699d9 AD |
105 | * @font_w: bit array of supported widths (1 - 32) |
106 | * @font_h: bit array of supported heights (1 - 32) | |
1da177e4 LT |
107 | * |
108 | * Get the default font for a specified screen size. | |
109 | * Dimensions are in pixels. | |
110 | * | |
111 | * Returns %NULL if no font is found, or a pointer to the | |
112 | * chosen font. | |
113 | * | |
114 | */ | |
115 | ||
2d2699d9 AD |
116 | const struct font_desc *get_default_font(int xres, int yres, u32 font_w, |
117 | u32 font_h) | |
1da177e4 LT |
118 | { |
119 | int i, c, cc; | |
2f4516db | 120 | const struct font_desc *f, *g; |
1da177e4 LT |
121 | |
122 | g = NULL; | |
123 | cc = -10000; | |
124 | for(i=0; i<num_fonts; i++) { | |
125 | f = fonts[i]; | |
126 | c = f->pref; | |
7b892806 | 127 | #if defined(__mc68000__) |
1da177e4 LT |
128 | #ifdef CONFIG_FONT_PEARL_8x8 |
129 | if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX) | |
130 | c = 100; | |
131 | #endif | |
132 | #ifdef CONFIG_FONT_6x11 | |
133 | if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX) | |
134 | c = 100; | |
135 | #endif | |
136 | #endif | |
137 | if ((yres < 400) == (f->height <= 8)) | |
138 | c += 1000; | |
2d2699d9 | 139 | |
c81f717c AD |
140 | if ((font_w & (1 << (f->width - 1))) && |
141 | (font_h & (1 << (f->height - 1)))) | |
2d2699d9 AD |
142 | c += 1000; |
143 | ||
1da177e4 LT |
144 | if (c > cc) { |
145 | cc = c; | |
146 | g = f; | |
147 | } | |
148 | } | |
149 | return g; | |
150 | } | |
151 | ||
1da177e4 LT |
152 | EXPORT_SYMBOL(find_font); |
153 | EXPORT_SYMBOL(get_default_font); | |
154 | ||
155 | MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); | |
156 | MODULE_DESCRIPTION("Console Fonts"); | |
157 | MODULE_LICENSE("GPL"); |