fonts.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #include <linux/config.h>
  15. #include <linux/module.h>
  16. #include <linux/types.h>
  17. #include <linux/string.h>
  18. #if defined(__mc68000__) || defined(CONFIG_APUS)
  19. #include <asm/setup.h>
  20. #endif
  21. #include <linux/font.h>
  22. #define NO_FONTS
  23. static struct font_desc *fonts[] = {
  24. #ifdef CONFIG_FONT_8x8
  25. #undef NO_FONTS
  26. &font_vga_8x8,
  27. #endif
  28. #ifdef CONFIG_FONT_8x16
  29. #undef NO_FONTS
  30. &font_vga_8x16,
  31. #endif
  32. #ifdef CONFIG_FONT_6x11
  33. #undef NO_FONTS
  34. &font_vga_6x11,
  35. #endif
  36. #ifdef CONFIG_FONT_SUN8x16
  37. #undef NO_FONTS
  38. &font_sun_8x16,
  39. #endif
  40. #ifdef CONFIG_FONT_SUN12x22
  41. #undef NO_FONTS
  42. &font_sun_12x22,
  43. #endif
  44. #ifdef CONFIG_FONT_ACORN_8x8
  45. #undef NO_FONTS
  46. &font_acorn_8x8,
  47. #endif
  48. #ifdef CONFIG_FONT_PEARL_8x8
  49. #undef NO_FONTS
  50. &font_pearl_8x8,
  51. #endif
  52. #ifdef CONFIG_FONT_MINI_4x6
  53. #undef NO_FONTS
  54. &font_mini_4x6,
  55. #endif
  56. };
  57. #define num_fonts (sizeof(fonts)/sizeof(*fonts))
  58. #ifdef NO_FONTS
  59. #error No fonts configured.
  60. #endif
  61. /**
  62. * find_font - find a font
  63. * @name: string name of a font
  64. *
  65. * Find a specified font with string name @name.
  66. *
  67. * Returns %NULL if no font found, or a pointer to the
  68. * specified font.
  69. *
  70. */
  71. struct font_desc *find_font(char *name)
  72. {
  73. unsigned int i;
  74. for (i = 0; i < num_fonts; i++)
  75. if (!strcmp(fonts[i]->name, name))
  76. return fonts[i];
  77. return NULL;
  78. }
  79. /**
  80. * get_default_font - get default font
  81. * @xres: screen size of X
  82. * @yres: screen size of Y
  83. *
  84. * Get the default font for a specified screen size.
  85. * Dimensions are in pixels.
  86. *
  87. * Returns %NULL if no font is found, or a pointer to the
  88. * chosen font.
  89. *
  90. */
  91. struct font_desc *get_default_font(int xres, int yres)
  92. {
  93. int i, c, cc;
  94. struct font_desc *f, *g;
  95. g = NULL;
  96. cc = -10000;
  97. for(i=0; i<num_fonts; i++) {
  98. f = fonts[i];
  99. c = f->pref;
  100. #if defined(__mc68000__) || defined(CONFIG_APUS)
  101. #ifdef CONFIG_FONT_PEARL_8x8
  102. if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX)
  103. c = 100;
  104. #endif
  105. #ifdef CONFIG_FONT_6x11
  106. if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX)
  107. c = 100;
  108. #endif
  109. #endif
  110. if ((yres < 400) == (f->height <= 8))
  111. c += 1000;
  112. if (c > cc) {
  113. cc = c;
  114. g = f;
  115. }
  116. }
  117. return g;
  118. }
  119. EXPORT_SYMBOL(fonts);
  120. EXPORT_SYMBOL(find_font);
  121. EXPORT_SYMBOL(get_default_font);
  122. MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
  123. MODULE_DESCRIPTION("Console Fonts");
  124. MODULE_LICENSE("GPL");