fonts.c 2.8 KB

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