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