aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/console/fonts.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/video/console/fonts.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/video/console/fonts.c')
-rw-r--r--drivers/video/console/fonts.c139
1 files changed, 139 insertions, 0 deletions
diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c
new file mode 100644
index 000000000000..465d678230ae
--- /dev/null
+++ b/drivers/video/console/fonts.c
@@ -0,0 +1,139 @@
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
26static 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
39#ifdef CONFIG_FONT_SUN8x16
40#undef NO_FONTS
41 &font_sun_8x16,
42#endif
43#ifdef CONFIG_FONT_SUN12x22
44#undef NO_FONTS
45 &font_sun_12x22,
46#endif
47#ifdef CONFIG_FONT_ACORN_8x8
48#undef NO_FONTS
49 &font_acorn_8x8,
50#endif
51#ifdef CONFIG_FONT_PEARL_8x8
52#undef NO_FONTS
53 &font_pearl_8x8,
54#endif
55#ifdef CONFIG_FONT_MINI_4x6
56#undef NO_FONTS
57 &font_mini_4x6,
58#endif
59};
60
61#define num_fonts (sizeof(fonts)/sizeof(*fonts))
62
63#ifdef NO_FONTS
64#error No fonts configured.
65#endif
66
67
68/**
69 * find_font - find a font
70 * @name: string name of a font
71 *
72 * Find a specified font with string name @name.
73 *
74 * Returns %NULL if no font found, or a pointer to the
75 * specified font.
76 *
77 */
78
79struct font_desc *find_font(char *name)
80{
81 unsigned int i;
82
83 for (i = 0; i < num_fonts; i++)
84 if (!strcmp(fonts[i]->name, name))
85 return fonts[i];
86 return NULL;
87}
88
89
90/**
91 * get_default_font - get default font
92 * @xres: screen size of X
93 * @yres: screen size of Y
94 *
95 * Get the default font for a specified screen size.
96 * Dimensions are in pixels.
97 *
98 * Returns %NULL if no font is found, or a pointer to the
99 * chosen font.
100 *
101 */
102
103struct font_desc *get_default_font(int xres, int yres)
104{
105 int i, c, cc;
106 struct font_desc *f, *g;
107
108 g = NULL;
109 cc = -10000;
110 for(i=0; i<num_fonts; i++) {
111 f = fonts[i];
112 c = f->pref;
113#if defined(__mc68000__) || defined(CONFIG_APUS)
114#ifdef CONFIG_FONT_PEARL_8x8
115 if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX)
116 c = 100;
117#endif
118#ifdef CONFIG_FONT_6x11
119 if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX)
120 c = 100;
121#endif
122#endif
123 if ((yres < 400) == (f->height <= 8))
124 c += 1000;
125 if (c > cc) {
126 cc = c;
127 g = f;
128 }
129 }
130 return g;
131}
132
133EXPORT_SYMBOL(fonts);
134EXPORT_SYMBOL(find_font);
135EXPORT_SYMBOL(get_default_font);
136
137MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
138MODULE_DESCRIPTION("Console Fonts");
139MODULE_LICENSE("GPL");