~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/fonts/fonts.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php