| .. | .. |
|---|
| 20 | 20 | #endif |
|---|
| 21 | 21 | #include <linux/font.h> |
|---|
| 22 | 22 | |
|---|
| 23 | | -#define NO_FONTS |
|---|
| 24 | | - |
|---|
| 25 | 23 | static const struct font_desc *fonts[] = { |
|---|
| 26 | 24 | #ifdef CONFIG_FONT_8x8 |
|---|
| 27 | | -#undef NO_FONTS |
|---|
| 28 | | - &font_vga_8x8, |
|---|
| 25 | + &font_vga_8x8, |
|---|
| 29 | 26 | #endif |
|---|
| 30 | 27 | #ifdef CONFIG_FONT_8x16 |
|---|
| 31 | | -#undef NO_FONTS |
|---|
| 32 | | - &font_vga_8x16, |
|---|
| 28 | + &font_vga_8x16, |
|---|
| 33 | 29 | #endif |
|---|
| 34 | 30 | #ifdef CONFIG_FONT_6x11 |
|---|
| 35 | | -#undef NO_FONTS |
|---|
| 36 | | - &font_vga_6x11, |
|---|
| 31 | + &font_vga_6x11, |
|---|
| 37 | 32 | #endif |
|---|
| 38 | 33 | #ifdef CONFIG_FONT_7x14 |
|---|
| 39 | | -#undef NO_FONTS |
|---|
| 40 | | - &font_7x14, |
|---|
| 34 | + &font_7x14, |
|---|
| 41 | 35 | #endif |
|---|
| 42 | 36 | #ifdef CONFIG_FONT_SUN8x16 |
|---|
| 43 | | -#undef NO_FONTS |
|---|
| 44 | | - &font_sun_8x16, |
|---|
| 37 | + &font_sun_8x16, |
|---|
| 45 | 38 | #endif |
|---|
| 46 | 39 | #ifdef CONFIG_FONT_SUN12x22 |
|---|
| 47 | | -#undef NO_FONTS |
|---|
| 48 | | - &font_sun_12x22, |
|---|
| 40 | + &font_sun_12x22, |
|---|
| 49 | 41 | #endif |
|---|
| 50 | 42 | #ifdef CONFIG_FONT_10x18 |
|---|
| 51 | | -#undef NO_FONTS |
|---|
| 52 | | - &font_10x18, |
|---|
| 43 | + &font_10x18, |
|---|
| 53 | 44 | #endif |
|---|
| 54 | 45 | #ifdef CONFIG_FONT_ACORN_8x8 |
|---|
| 55 | | -#undef NO_FONTS |
|---|
| 56 | | - &font_acorn_8x8, |
|---|
| 46 | + &font_acorn_8x8, |
|---|
| 57 | 47 | #endif |
|---|
| 58 | 48 | #ifdef CONFIG_FONT_PEARL_8x8 |
|---|
| 59 | | -#undef NO_FONTS |
|---|
| 60 | | - &font_pearl_8x8, |
|---|
| 49 | + &font_pearl_8x8, |
|---|
| 61 | 50 | #endif |
|---|
| 62 | 51 | #ifdef CONFIG_FONT_MINI_4x6 |
|---|
| 63 | | -#undef NO_FONTS |
|---|
| 64 | | - &font_mini_4x6, |
|---|
| 52 | + &font_mini_4x6, |
|---|
| 65 | 53 | #endif |
|---|
| 66 | 54 | #ifdef CONFIG_FONT_6x10 |
|---|
| 67 | | -#undef NO_FONTS |
|---|
| 68 | | - &font_6x10, |
|---|
| 55 | + &font_6x10, |
|---|
| 56 | +#endif |
|---|
| 57 | +#ifdef CONFIG_FONT_TER16x32 |
|---|
| 58 | + &font_ter_16x32, |
|---|
| 59 | +#endif |
|---|
| 60 | +#ifdef CONFIG_FONT_6x8 |
|---|
| 61 | + &font_6x8, |
|---|
| 69 | 62 | #endif |
|---|
| 70 | 63 | }; |
|---|
| 71 | 64 | |
|---|
| .. | .. |
|---|
| 86 | 79 | * specified font. |
|---|
| 87 | 80 | * |
|---|
| 88 | 81 | */ |
|---|
| 89 | | - |
|---|
| 90 | 82 | const struct font_desc *find_font(const char *name) |
|---|
| 91 | 83 | { |
|---|
| 92 | | - unsigned int i; |
|---|
| 84 | + unsigned int i; |
|---|
| 93 | 85 | |
|---|
| 94 | | - for (i = 0; i < num_fonts; i++) |
|---|
| 95 | | - if (!strcmp(fonts[i]->name, name)) |
|---|
| 96 | | - return fonts[i]; |
|---|
| 97 | | - return NULL; |
|---|
| 86 | + BUILD_BUG_ON(!num_fonts); |
|---|
| 87 | + for (i = 0; i < num_fonts; i++) |
|---|
| 88 | + if (!strcmp(fonts[i]->name, name)) |
|---|
| 89 | + return fonts[i]; |
|---|
| 90 | + return NULL; |
|---|
| 98 | 91 | } |
|---|
| 92 | +EXPORT_SYMBOL(find_font); |
|---|
| 99 | 93 | |
|---|
| 100 | 94 | |
|---|
| 101 | 95 | /** |
|---|
| .. | .. |
|---|
| 112 | 106 | * chosen font. |
|---|
| 113 | 107 | * |
|---|
| 114 | 108 | */ |
|---|
| 115 | | - |
|---|
| 116 | 109 | const struct font_desc *get_default_font(int xres, int yres, u32 font_w, |
|---|
| 117 | 110 | u32 font_h) |
|---|
| 118 | 111 | { |
|---|
| 119 | | - int i, c, cc; |
|---|
| 120 | | - const struct font_desc *f, *g; |
|---|
| 112 | + int i, c, cc, res; |
|---|
| 113 | + const struct font_desc *f, *g; |
|---|
| 121 | 114 | |
|---|
| 122 | | - g = NULL; |
|---|
| 123 | | - cc = -10000; |
|---|
| 124 | | - for(i=0; i<num_fonts; i++) { |
|---|
| 125 | | - f = fonts[i]; |
|---|
| 126 | | - c = f->pref; |
|---|
| 115 | + g = NULL; |
|---|
| 116 | + cc = -10000; |
|---|
| 117 | + for (i = 0; i < num_fonts; i++) { |
|---|
| 118 | + f = fonts[i]; |
|---|
| 119 | + c = f->pref; |
|---|
| 127 | 120 | #if defined(__mc68000__) |
|---|
| 128 | 121 | #ifdef CONFIG_FONT_PEARL_8x8 |
|---|
| 129 | | - if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX) |
|---|
| 130 | | - c = 100; |
|---|
| 122 | + if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX) |
|---|
| 123 | + c = 100; |
|---|
| 131 | 124 | #endif |
|---|
| 132 | 125 | #ifdef CONFIG_FONT_6x11 |
|---|
| 133 | | - if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX) |
|---|
| 134 | | - c = 100; |
|---|
| 126 | + if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX) |
|---|
| 127 | + c = 100; |
|---|
| 135 | 128 | #endif |
|---|
| 136 | 129 | #endif |
|---|
| 137 | | - if ((yres < 400) == (f->height <= 8)) |
|---|
| 138 | | - c += 1000; |
|---|
| 130 | + if ((yres < 400) == (f->height <= 8)) |
|---|
| 131 | + c += 1000; |
|---|
| 139 | 132 | |
|---|
| 140 | | - if ((font_w & (1 << (f->width - 1))) && |
|---|
| 141 | | - (font_h & (1 << (f->height - 1)))) |
|---|
| 142 | | - c += 1000; |
|---|
| 133 | + /* prefer a bigger font for high resolution */ |
|---|
| 134 | + res = (xres / f->width) * (yres / f->height) / 1000; |
|---|
| 135 | + if (res > 20) |
|---|
| 136 | + c += 20 - res; |
|---|
| 143 | 137 | |
|---|
| 144 | | - if (c > cc) { |
|---|
| 145 | | - cc = c; |
|---|
| 146 | | - g = f; |
|---|
| 138 | + if ((font_w & (1U << (f->width - 1))) && |
|---|
| 139 | + (font_h & (1U << (f->height - 1)))) |
|---|
| 140 | + c += 1000; |
|---|
| 141 | + |
|---|
| 142 | + if (c > cc) { |
|---|
| 143 | + cc = c; |
|---|
| 144 | + g = f; |
|---|
| 145 | + } |
|---|
| 147 | 146 | } |
|---|
| 148 | | - } |
|---|
| 149 | | - return g; |
|---|
| 147 | + return g; |
|---|
| 150 | 148 | } |
|---|
| 151 | | - |
|---|
| 152 | | -EXPORT_SYMBOL(find_font); |
|---|
| 153 | 149 | EXPORT_SYMBOL(get_default_font); |
|---|
| 154 | 150 | |
|---|
| 155 | 151 | MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); |
|---|