rev |
line source |
nuclear@0
|
1 /***************************************************************************/
|
nuclear@0
|
2 /* */
|
nuclear@0
|
3 /* ftlcdfil.h */
|
nuclear@0
|
4 /* */
|
nuclear@0
|
5 /* FreeType API for color filtering of subpixel bitmap glyphs */
|
nuclear@0
|
6 /* (specification). */
|
nuclear@0
|
7 /* */
|
nuclear@0
|
8 /* Copyright 2006, 2007, 2008, 2010 by */
|
nuclear@0
|
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
nuclear@0
|
10 /* */
|
nuclear@0
|
11 /* This file is part of the FreeType project, and may only be used, */
|
nuclear@0
|
12 /* modified, and distributed under the terms of the FreeType project */
|
nuclear@0
|
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
nuclear@0
|
14 /* this file you indicate that you have read the license and */
|
nuclear@0
|
15 /* understand and accept it fully. */
|
nuclear@0
|
16 /* */
|
nuclear@0
|
17 /***************************************************************************/
|
nuclear@0
|
18
|
nuclear@0
|
19
|
nuclear@0
|
20 #ifndef __FT_LCD_FILTER_H__
|
nuclear@0
|
21 #define __FT_LCD_FILTER_H__
|
nuclear@0
|
22
|
nuclear@0
|
23 #include <ft2build.h>
|
nuclear@0
|
24 #include FT_FREETYPE_H
|
nuclear@0
|
25
|
nuclear@0
|
26 #ifdef FREETYPE_H
|
nuclear@0
|
27 #error "freetype.h of FreeType 1 has been loaded!"
|
nuclear@0
|
28 #error "Please fix the directory search order for header files"
|
nuclear@0
|
29 #error "so that freetype.h of FreeType 2 is found first."
|
nuclear@0
|
30 #endif
|
nuclear@0
|
31
|
nuclear@0
|
32
|
nuclear@0
|
33 FT_BEGIN_HEADER
|
nuclear@0
|
34
|
nuclear@0
|
35 /***************************************************************************
|
nuclear@0
|
36 *
|
nuclear@0
|
37 * @section:
|
nuclear@0
|
38 * lcd_filtering
|
nuclear@0
|
39 *
|
nuclear@0
|
40 * @title:
|
nuclear@0
|
41 * LCD Filtering
|
nuclear@0
|
42 *
|
nuclear@0
|
43 * @abstract:
|
nuclear@0
|
44 * Reduce color fringes of LCD-optimized bitmaps.
|
nuclear@0
|
45 *
|
nuclear@0
|
46 * @description:
|
nuclear@0
|
47 * The @FT_Library_SetLcdFilter API can be used to specify a low-pass
|
nuclear@0
|
48 * filter which is then applied to LCD-optimized bitmaps generated
|
nuclear@0
|
49 * through @FT_Render_Glyph. This is useful to reduce color fringes
|
nuclear@0
|
50 * which would occur with unfiltered rendering.
|
nuclear@0
|
51 *
|
nuclear@0
|
52 * Note that no filter is active by default, and that this function is
|
nuclear@0
|
53 * *not* implemented in default builds of the library. You need to
|
nuclear@0
|
54 * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file
|
nuclear@0
|
55 * in order to activate it.
|
nuclear@0
|
56 */
|
nuclear@0
|
57
|
nuclear@0
|
58
|
nuclear@0
|
59 /****************************************************************************
|
nuclear@0
|
60 *
|
nuclear@0
|
61 * @enum:
|
nuclear@0
|
62 * FT_LcdFilter
|
nuclear@0
|
63 *
|
nuclear@0
|
64 * @description:
|
nuclear@0
|
65 * A list of values to identify various types of LCD filters.
|
nuclear@0
|
66 *
|
nuclear@0
|
67 * @values:
|
nuclear@0
|
68 * FT_LCD_FILTER_NONE ::
|
nuclear@0
|
69 * Do not perform filtering. When used with subpixel rendering, this
|
nuclear@0
|
70 * results in sometimes severe color fringes.
|
nuclear@0
|
71 *
|
nuclear@0
|
72 * FT_LCD_FILTER_DEFAULT ::
|
nuclear@0
|
73 * The default filter reduces color fringes considerably, at the cost
|
nuclear@0
|
74 * of a slight blurriness in the output.
|
nuclear@0
|
75 *
|
nuclear@0
|
76 * FT_LCD_FILTER_LIGHT ::
|
nuclear@0
|
77 * The light filter is a variant that produces less blurriness at the
|
nuclear@0
|
78 * cost of slightly more color fringes than the default one. It might
|
nuclear@0
|
79 * be better, depending on taste, your monitor, or your personal vision.
|
nuclear@0
|
80 *
|
nuclear@0
|
81 * FT_LCD_FILTER_LEGACY ::
|
nuclear@0
|
82 * This filter corresponds to the original libXft color filter. It
|
nuclear@0
|
83 * provides high contrast output but can exhibit really bad color
|
nuclear@0
|
84 * fringes if glyphs are not extremely well hinted to the pixel grid.
|
nuclear@0
|
85 * In other words, it only works well if the TrueType bytecode
|
nuclear@0
|
86 * interpreter is enabled *and* high-quality hinted fonts are used.
|
nuclear@0
|
87 *
|
nuclear@0
|
88 * This filter is only provided for comparison purposes, and might be
|
nuclear@0
|
89 * disabled or stay unsupported in the future.
|
nuclear@0
|
90 *
|
nuclear@0
|
91 * @since:
|
nuclear@0
|
92 * 2.3.0
|
nuclear@0
|
93 */
|
nuclear@0
|
94 typedef enum FT_LcdFilter_
|
nuclear@0
|
95 {
|
nuclear@0
|
96 FT_LCD_FILTER_NONE = 0,
|
nuclear@0
|
97 FT_LCD_FILTER_DEFAULT = 1,
|
nuclear@0
|
98 FT_LCD_FILTER_LIGHT = 2,
|
nuclear@0
|
99 FT_LCD_FILTER_LEGACY = 16,
|
nuclear@0
|
100
|
nuclear@0
|
101 FT_LCD_FILTER_MAX /* do not remove */
|
nuclear@0
|
102
|
nuclear@0
|
103 } FT_LcdFilter;
|
nuclear@0
|
104
|
nuclear@0
|
105
|
nuclear@0
|
106 /**************************************************************************
|
nuclear@0
|
107 *
|
nuclear@0
|
108 * @func:
|
nuclear@0
|
109 * FT_Library_SetLcdFilter
|
nuclear@0
|
110 *
|
nuclear@0
|
111 * @description:
|
nuclear@0
|
112 * This function is used to apply color filtering to LCD decimated
|
nuclear@0
|
113 * bitmaps, like the ones used when calling @FT_Render_Glyph with
|
nuclear@0
|
114 * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V.
|
nuclear@0
|
115 *
|
nuclear@0
|
116 * @input:
|
nuclear@0
|
117 * library ::
|
nuclear@0
|
118 * A handle to the target library instance.
|
nuclear@0
|
119 *
|
nuclear@0
|
120 * filter ::
|
nuclear@0
|
121 * The filter type.
|
nuclear@0
|
122 *
|
nuclear@0
|
123 * You can use @FT_LCD_FILTER_NONE here to disable this feature, or
|
nuclear@0
|
124 * @FT_LCD_FILTER_DEFAULT to use a default filter that should work
|
nuclear@0
|
125 * well on most LCD screens.
|
nuclear@0
|
126 *
|
nuclear@0
|
127 * @return:
|
nuclear@0
|
128 * FreeType error code. 0~means success.
|
nuclear@0
|
129 *
|
nuclear@0
|
130 * @note:
|
nuclear@0
|
131 * This feature is always disabled by default. Clients must make an
|
nuclear@0
|
132 * explicit call to this function with a `filter' value other than
|
nuclear@0
|
133 * @FT_LCD_FILTER_NONE in order to enable it.
|
nuclear@0
|
134 *
|
nuclear@0
|
135 * Due to *PATENTS* covering subpixel rendering, this function doesn't
|
nuclear@0
|
136 * do anything except returning `FT_Err_Unimplemented_Feature' if the
|
nuclear@0
|
137 * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
|
nuclear@0
|
138 * defined in your build of the library, which should correspond to all
|
nuclear@0
|
139 * default builds of FreeType.
|
nuclear@0
|
140 *
|
nuclear@0
|
141 * The filter affects glyph bitmaps rendered through @FT_Render_Glyph,
|
nuclear@0
|
142 * @FT_Outline_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char.
|
nuclear@0
|
143 *
|
nuclear@0
|
144 * It does _not_ affect the output of @FT_Outline_Render and
|
nuclear@0
|
145 * @FT_Outline_Get_Bitmap.
|
nuclear@0
|
146 *
|
nuclear@0
|
147 * If this feature is activated, the dimensions of LCD glyph bitmaps are
|
nuclear@0
|
148 * either larger or taller than the dimensions of the corresponding
|
nuclear@0
|
149 * outline with regards to the pixel grid. For example, for
|
nuclear@0
|
150 * @FT_RENDER_MODE_LCD, the filter adds up to 3~pixels to the left, and
|
nuclear@0
|
151 * up to 3~pixels to the right.
|
nuclear@0
|
152 *
|
nuclear@0
|
153 * The bitmap offset values are adjusted correctly, so clients shouldn't
|
nuclear@0
|
154 * need to modify their layout and glyph positioning code when enabling
|
nuclear@0
|
155 * the filter.
|
nuclear@0
|
156 *
|
nuclear@0
|
157 * @since:
|
nuclear@0
|
158 * 2.3.0
|
nuclear@0
|
159 */
|
nuclear@0
|
160 FT_EXPORT( FT_Error )
|
nuclear@0
|
161 FT_Library_SetLcdFilter( FT_Library library,
|
nuclear@0
|
162 FT_LcdFilter filter );
|
nuclear@0
|
163
|
nuclear@0
|
164
|
nuclear@0
|
165 /**************************************************************************
|
nuclear@0
|
166 *
|
nuclear@0
|
167 * @func:
|
nuclear@0
|
168 * FT_Library_SetLcdFilterWeights
|
nuclear@0
|
169 *
|
nuclear@0
|
170 * @description:
|
nuclear@0
|
171 * Use this function to override the filter weights selected by
|
nuclear@0
|
172 * @FT_Library_SetLcdFilter. By default, FreeType uses the quintuple
|
nuclear@0
|
173 * (0x00, 0x55, 0x56, 0x55, 0x00) for FT_LCD_FILTER_LIGHT, and (0x10,
|
nuclear@0
|
174 * 0x40, 0x70, 0x40, 0x10) for FT_LCD_FILTER_DEFAULT and
|
nuclear@0
|
175 * FT_LCD_FILTER_LEGACY.
|
nuclear@0
|
176 *
|
nuclear@0
|
177 * @input:
|
nuclear@0
|
178 * library ::
|
nuclear@0
|
179 * A handle to the target library instance.
|
nuclear@0
|
180 *
|
nuclear@0
|
181 * weights ::
|
nuclear@0
|
182 * A pointer to an array; the function copies the first five bytes and
|
nuclear@0
|
183 * uses them to specify the filter weights.
|
nuclear@0
|
184 *
|
nuclear@0
|
185 * @return:
|
nuclear@0
|
186 * FreeType error code. 0~means success.
|
nuclear@0
|
187 *
|
nuclear@0
|
188 * @note:
|
nuclear@0
|
189 * Due to *PATENTS* covering subpixel rendering, this function doesn't
|
nuclear@0
|
190 * do anything except returning `FT_Err_Unimplemented_Feature' if the
|
nuclear@0
|
191 * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
|
nuclear@0
|
192 * defined in your build of the library, which should correspond to all
|
nuclear@0
|
193 * default builds of FreeType.
|
nuclear@0
|
194 *
|
nuclear@0
|
195 * This function must be called after @FT_Library_SetLcdFilter to have
|
nuclear@0
|
196 * any effect.
|
nuclear@0
|
197 *
|
nuclear@0
|
198 * @since:
|
nuclear@0
|
199 * 2.4.0
|
nuclear@0
|
200 */
|
nuclear@0
|
201 FT_EXPORT( FT_Error )
|
nuclear@0
|
202 FT_Library_SetLcdFilterWeights( FT_Library library,
|
nuclear@0
|
203 unsigned char *weights );
|
nuclear@0
|
204
|
nuclear@0
|
205 /* */
|
nuclear@0
|
206
|
nuclear@0
|
207
|
nuclear@0
|
208 FT_END_HEADER
|
nuclear@0
|
209
|
nuclear@0
|
210 #endif /* __FT_LCD_FILTER_H__ */
|
nuclear@0
|
211
|
nuclear@0
|
212
|
nuclear@0
|
213 /* END */
|