0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/module.h>
0016 #include <linux/types.h>
0017 #include <linux/string.h>
0018 #if defined(__mc68000__)
0019 #include <asm/setup.h>
0020 #endif
0021 #include <linux/font.h>
0022
0023 static const struct font_desc *fonts[] = {
0024 #ifdef CONFIG_FONT_8x8
0025 &font_vga_8x8,
0026 #endif
0027 #ifdef CONFIG_FONT_8x16
0028 &font_vga_8x16,
0029 #endif
0030 #ifdef CONFIG_FONT_6x11
0031 &font_vga_6x11,
0032 #endif
0033 #ifdef CONFIG_FONT_7x14
0034 &font_7x14,
0035 #endif
0036 #ifdef CONFIG_FONT_SUN8x16
0037 &font_sun_8x16,
0038 #endif
0039 #ifdef CONFIG_FONT_SUN12x22
0040 &font_sun_12x22,
0041 #endif
0042 #ifdef CONFIG_FONT_10x18
0043 &font_10x18,
0044 #endif
0045 #ifdef CONFIG_FONT_ACORN_8x8
0046 &font_acorn_8x8,
0047 #endif
0048 #ifdef CONFIG_FONT_PEARL_8x8
0049 &font_pearl_8x8,
0050 #endif
0051 #ifdef CONFIG_FONT_MINI_4x6
0052 &font_mini_4x6,
0053 #endif
0054 #ifdef CONFIG_FONT_6x10
0055 &font_6x10,
0056 #endif
0057 #ifdef CONFIG_FONT_TER16x32
0058 &font_ter_16x32,
0059 #endif
0060 #ifdef CONFIG_FONT_6x8
0061 &font_6x8,
0062 #endif
0063 };
0064
0065 #define num_fonts ARRAY_SIZE(fonts)
0066
0067 #ifdef NO_FONTS
0068 #error No fonts configured.
0069 #endif
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 const struct font_desc *find_font(const char *name)
0083 {
0084 unsigned int i;
0085
0086 BUILD_BUG_ON(!num_fonts);
0087 for (i = 0; i < num_fonts; i++)
0088 if (!strcmp(fonts[i]->name, name))
0089 return fonts[i];
0090 return NULL;
0091 }
0092 EXPORT_SYMBOL(find_font);
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
0110 u32 font_h)
0111 {
0112 int i, c, cc, res;
0113 const struct font_desc *f, *g;
0114
0115 g = NULL;
0116 cc = -10000;
0117 for (i = 0; i < num_fonts; i++) {
0118 f = fonts[i];
0119 c = f->pref;
0120 #if defined(__mc68000__)
0121 #ifdef CONFIG_FONT_PEARL_8x8
0122 if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX)
0123 c = 100;
0124 #endif
0125 #ifdef CONFIG_FONT_6x11
0126 if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX)
0127 c = 100;
0128 #endif
0129 #endif
0130 if ((yres < 400) == (f->height <= 8))
0131 c += 1000;
0132
0133
0134 res = (xres / f->width) * (yres / f->height) / 1000;
0135 if (res > 20)
0136 c += 20 - res;
0137
0138 if ((font_w & (1 << (f->width - 1))) &&
0139 (font_h & (1 << (f->height - 1))))
0140 c += 1000;
0141
0142 if (c > cc) {
0143 cc = c;
0144 g = f;
0145 }
0146 }
0147 return g;
0148 }
0149 EXPORT_SYMBOL(get_default_font);
0150
0151 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
0152 MODULE_DESCRIPTION("Console Fonts");
0153 MODULE_LICENSE("GPL");