fonts.c 2.8 KB

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