ftlcdfil.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /***************************************************************************/
  2. /* */
  3. /* ftlcdfil.h */
  4. /* */
  5. /* FreeType API for color filtering of subpixel bitmap glyphs */
  6. /* (specification). */
  7. /* */
  8. /* Copyright 2006, 2007 by */
  9. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  10. /* */
  11. /* This file is part of the FreeType project, and may only be used, */
  12. /* modified, and distributed under the terms of the FreeType project */
  13. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /***************************************************************************/
  18. #ifndef __FT_LCD_FILTER_H__
  19. #define __FT_LCD_FILTER_H__
  20. #include <ft2build.h>
  21. #include FT_FREETYPE_H
  22. FT_BEGIN_HEADER
  23. /***************************************************************************
  24. *
  25. * @section:
  26. * lcd_filtering
  27. *
  28. * @title:
  29. * LCD Filtering
  30. *
  31. * @abstract:
  32. * Reduce color fringes of LCD-optimized bitmaps.
  33. *
  34. * @description:
  35. * The @FT_Library_SetLcdFilter API can be used to specify a low-pass
  36. * filter which is then applied to LCD-optimized bitmaps generated
  37. * through @FT_Render_Glyph. This is useful to reduce color fringes
  38. * which would occur with unfiltered rendering.
  39. *
  40. * Note that no filter is active by default, and that this function is
  41. * *not* implemented in default builds of the library. You need to
  42. * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file
  43. * in order to activate it.
  44. */
  45. /****************************************************************************
  46. *
  47. * @func:
  48. * FT_LcdFilter
  49. *
  50. * @description:
  51. * A list of values to identify various types of LCD filters.
  52. *
  53. * @values:
  54. * FT_LCD_FILTER_NONE ::
  55. * Do not perform filtering. When used with subpixel rendering, this
  56. * results in sometimes severe color fringes.
  57. *
  58. * FT_LCD_FILTER_DEFAULT ::
  59. * The default filter reduces color fringes considerably, at the cost
  60. * of a slight blurriness in the output.
  61. *
  62. * FT_LCD_FILTER_LIGHT ::
  63. * The light filter is a variant that produces less blurriness at the
  64. * cost of slightly more color fringes than the default one. It might
  65. * be better, depending on taste, your monitor, or your personal vision.
  66. *
  67. * FT_LCD_FILTER_LEGACY ::
  68. * This filter corresponds to the original libXft color filter. It
  69. * provides high contrast output but can exhibit really bad color
  70. * fringes if glyphs are not extremely well hinted to the pixel grid.
  71. * In other words, it only works well if the TrueType bytecode
  72. * interpreter is enabled *and* high-quality hinted fonts are used.
  73. *
  74. * This filter is only provided for comparison purposes, and might be
  75. * disabled or stay unsupported in the future.
  76. *
  77. * @since:
  78. * 2.3.0
  79. */
  80. typedef enum
  81. {
  82. FT_LCD_FILTER_NONE = 0,
  83. FT_LCD_FILTER_DEFAULT = 1,
  84. FT_LCD_FILTER_LIGHT = 2,
  85. FT_LCD_FILTER_LEGACY = 16,
  86. FT_LCD_FILTER_MAX /* do not remove */
  87. } FT_LcdFilter;
  88. /**************************************************************************
  89. *
  90. * @func:
  91. * FT_Library_SetLcdFilter
  92. *
  93. * @description:
  94. * This function is used to apply color filtering to LCD decimated
  95. * bitmaps, like the ones used when calling @FT_Render_Glyph with
  96. * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V.
  97. *
  98. * @input:
  99. * library ::
  100. * A handle to the target library instance.
  101. *
  102. * filter ::
  103. * The filter type.
  104. *
  105. * You can use @FT_LCD_FILTER_NONE here to disable this feature, or
  106. * @FT_LCD_FILTER_DEFAULT to use a default filter that should work
  107. * well on most LCD screens.
  108. *
  109. * @return:
  110. * FreeType error code. 0 means success.
  111. *
  112. * @note:
  113. * This feature is always disabled by default. Clients must make an
  114. * explicit call to this function with a `filter' value other than
  115. * @FT_LCD_FILTER_NONE in order to enable it.
  116. *
  117. * Due to *PATENTS* covering subpixel rendering, this function doesn't
  118. * do anything except returning `FT_Err_Unimplemented_Feature' if the
  119. * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
  120. * defined in your build of the library, which should correspond to all
  121. * default builds of FreeType.
  122. *
  123. * The filter affects glyph bitmaps rendered through @FT_Render_Glyph,
  124. * @FT_Outline_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char.
  125. *
  126. * It does _not_ affect the output of @FT_Outline_Render and
  127. * @FT_Outline_Get_Bitmap.
  128. *
  129. * If this feature is activated, the dimensions of LCD glyph bitmaps are
  130. * either larger or taller than the dimensions of the corresponding
  131. * outline with regards to the pixel grid. For example, for
  132. * @FT_RENDER_MODE_LCD, the filter adds up to 3 pixels to the left, and
  133. * up to 3 pixels to the right.
  134. *
  135. * The bitmap offset values are adjusted correctly, so clients shouldn't
  136. * need to modify their layout and glyph positioning code when enabling
  137. * the filter.
  138. *
  139. * @since:
  140. * 2.3.0
  141. */
  142. FT_EXPORT( FT_Error )
  143. FT_Library_SetLcdFilter( FT_Library library,
  144. FT_LcdFilter filter );
  145. /* */
  146. FT_END_HEADER
  147. #endif /* __FT_LCD_FILTER_H__ */
  148. /* END */