00001 /***************************************************************************/ 00002 /* */ 00003 /* ftlcdfil.h */ 00004 /* */ 00005 /* FreeType API for color filtering of subpixel bitmap glyphs */ 00006 /* (specification). */ 00007 /* */ 00008 /* Copyright 2006, 2007, 2008 by */ 00009 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 00010 /* */ 00011 /* This file is part of the FreeType project, and may only be used, */ 00012 /* modified, and distributed under the terms of the FreeType project */ 00013 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 00014 /* this file you indicate that you have read the license and */ 00015 /* understand and accept it fully. */ 00016 /* */ 00017 /***************************************************************************/ 00018 00019 00020 #ifndef __FT_LCD_FILTER_H__ 00021 #define __FT_LCD_FILTER_H__ 00022 00023 #include <ft2build.h> 00024 #include FT_FREETYPE_H 00025 00026 #ifdef FREETYPE_H 00027 #error "freetype.h of FreeType 1 has been loaded!" 00028 #error "Please fix the directory search order for header files" 00029 #error "so that freetype.h of FreeType 2 is found first." 00030 #endif 00031 00032 00033 FT_BEGIN_HEADER 00034 00035 /*************************************************************************** 00036 * 00037 * @section: 00038 * lcd_filtering 00039 * 00040 * @title: 00041 * LCD Filtering 00042 * 00043 * @abstract: 00044 * Reduce color fringes of LCD-optimized bitmaps. 00045 * 00046 * @description: 00047 * The @FT_Library_SetLcdFilter API can be used to specify a low-pass 00048 * filter which is then applied to LCD-optimized bitmaps generated 00049 * through @FT_Render_Glyph. This is useful to reduce color fringes 00050 * which would occur with unfiltered rendering. 00051 * 00052 * Note that no filter is active by default, and that this function is 00053 * *not* implemented in default builds of the library. You need to 00054 * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file 00055 * in order to activate it. 00056 */ 00057 00058 00059 /**************************************************************************** 00060 * 00061 * @func: 00062 * FT_LcdFilter 00063 * 00064 * @description: 00065 * A list of values to identify various types of LCD filters. 00066 * 00067 * @values: 00068 * FT_LCD_FILTER_NONE :: 00069 * Do not perform filtering. When used with subpixel rendering, this 00070 * results in sometimes severe color fringes. 00071 * 00072 * FT_LCD_FILTER_DEFAULT :: 00073 * The default filter reduces color fringes considerably, at the cost 00074 * of a slight blurriness in the output. 00075 * 00076 * FT_LCD_FILTER_LIGHT :: 00077 * The light filter is a variant that produces less blurriness at the 00078 * cost of slightly more color fringes than the default one. It might 00079 * be better, depending on taste, your monitor, or your personal vision. 00080 * 00081 * FT_LCD_FILTER_LEGACY :: 00082 * This filter corresponds to the original libXft color filter. It 00083 * provides high contrast output but can exhibit really bad color 00084 * fringes if glyphs are not extremely well hinted to the pixel grid. 00085 * In other words, it only works well if the TrueType bytecode 00086 * interpreter is enabled *and* high-quality hinted fonts are used. 00087 * 00088 * This filter is only provided for comparison purposes, and might be 00089 * disabled or stay unsupported in the future. 00090 * 00091 * @since: 00092 * 2.3.0 00093 */ 00094 typedef enum FT_LcdFilter_ 00095 { 00096 FT_LCD_FILTER_NONE = 0, 00097 FT_LCD_FILTER_DEFAULT = 1, 00098 FT_LCD_FILTER_LIGHT = 2, 00099 FT_LCD_FILTER_LEGACY = 16, 00100 00101 FT_LCD_FILTER_MAX /* do not remove */ 00102 00103 } FT_LcdFilter; 00104 00105 00106 /************************************************************************** 00107 * 00108 * @func: 00109 * FT_Library_SetLcdFilter 00110 * 00111 * @description: 00112 * This function is used to apply color filtering to LCD decimated 00113 * bitmaps, like the ones used when calling @FT_Render_Glyph with 00114 * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. 00115 * 00116 * @input: 00117 * library :: 00118 * A handle to the target library instance. 00119 * 00120 * filter :: 00121 * The filter type. 00122 * 00123 * You can use @FT_LCD_FILTER_NONE here to disable this feature, or 00124 * @FT_LCD_FILTER_DEFAULT to use a default filter that should work 00125 * well on most LCD screens. 00126 * 00127 * @return: 00128 * FreeType error code. 0~means success. 00129 * 00130 * @note: 00131 * This feature is always disabled by default. Clients must make an 00132 * explicit call to this function with a `filter' value other than 00133 * @FT_LCD_FILTER_NONE in order to enable it. 00134 * 00135 * Due to *PATENTS* covering subpixel rendering, this function doesn't 00136 * do anything except returning `FT_Err_Unimplemented_Feature' if the 00137 * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not 00138 * defined in your build of the library, which should correspond to all 00139 * default builds of FreeType. 00140 * 00141 * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, 00142 * @FT_Outline_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char. 00143 * 00144 * It does _not_ affect the output of @FT_Outline_Render and 00145 * @FT_Outline_Get_Bitmap. 00146 * 00147 * If this feature is activated, the dimensions of LCD glyph bitmaps are 00148 * either larger or taller than the dimensions of the corresponding 00149 * outline with regards to the pixel grid. For example, for 00150 * @FT_RENDER_MODE_LCD, the filter adds up to 3~pixels to the left, and 00151 * up to 3~pixels to the right. 00152 * 00153 * The bitmap offset values are adjusted correctly, so clients shouldn't 00154 * need to modify their layout and glyph positioning code when enabling 00155 * the filter. 00156 * 00157 * @since: 00158 * 2.3.0 00159 */ 00160 FT_EXPORT( FT_Error ) 00161 FT_Library_SetLcdFilter( FT_Library library, 00162 FT_LcdFilter filter ); 00163 00164 /* */ 00165 00166 00167 FT_END_HEADER 00168 00169 #endif /* __FT_LCD_FILTER_H__ */ 00170 00171 00172 /* END */