fonts.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #include <linux/module.h>
  15. #include <linux/types.h>
  16. #include <linux/string.h>
  17. #if defined(__mc68000__)
  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. #ifdef CONFIG_FONT_6x10
  64. #undef NO_FONTS
  65. &font_6x10,
  66. #endif
  67. };
  68. #define num_fonts ARRAY_SIZE(fonts)
  69. #ifdef NO_FONTS
  70. #error No fonts configured.
  71. #endif
  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. for (i = 0; i < num_fonts; i++)
  86. if (!strcmp(fonts[i]->name, name))
  87. return fonts[i];
  88. return NULL;
  89. }
  90. /**
  91. * get_default_font - get default font
  92. * @xres: screen size of X
  93. * @yres: screen size of Y
  94. * @font_w: bit array of supported widths (1 - 32)
  95. * @font_h: bit array of supported heights (1 - 32)
  96. *
  97. * Get the default font for a specified screen size.
  98. * Dimensions are in pixels.
  99. *
  100. * Returns %NULL if no font is found, or a pointer to the
  101. * chosen font.
  102. *
  103. */
  104. const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
  105. u32 font_h)
  106. {
  107. int i, c, cc;
  108. const struct font_desc *f, *g;
  109. g = NULL;
  110. cc = -10000;
  111. for(i=0; i<num_fonts; i++) {
  112. f = fonts[i];
  113. c = f->pref;
  114. #if defined(__mc68000__)
  115. #ifdef CONFIG_FONT_PEARL_8x8
  116. if (MACH_IS_AMIGA && f->idx == PEARL8x8_IDX)
  117. c = 100;
  118. #endif
  119. #ifdef CONFIG_FONT_6x11
  120. if (MACH_IS_MAC && xres < 640 && f->idx == VGA6x11_IDX)
  121. c = 100;
  122. #endif
  123. #endif
  124. if ((yres < 400) == (f->height <= 8))
  125. c += 1000;
  126. if ((font_w & (1 << (f->width - 1))) &&
  127. (font_h & (1 << (f->height - 1))))
  128. c += 1000;
  129. if (c > cc) {
  130. cc = c;
  131. g = f;
  132. }
  133. }
  134. return g;
  135. }
  136. EXPORT_SYMBOL(find_font);
  137. EXPORT_SYMBOL(get_default_font);
  138. MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
  139. MODULE_DESCRIPTION("Console Fonts");
  140. MODULE_LICENSE("GPL");