1 diff -rup libcairo-1.2.4.orig/src/cairo-ft-font.c libcairo-1.2.4/src/cairo-ft-font.c
2 --- libcairo-1.2.4.orig/src/cairo-ft-font.c 2006-08-22 21:40:02.802247352 +0800
3 +++ libcairo-1.2.4/src/cairo-ft-font.c 2006-08-22 21:40:39.443677008 +0800
5 #include FT_SYNTHESIS_H
10 #define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0))
11 #define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
12 #define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0))
13 @@ -492,6 +494,8 @@ _cairo_ft_unscaled_font_destroy (void *a
17 +static const int fir_filter[5] = { 0x1C, 0x38, 0x55, 0x38, 0x1C };
20 _has_unlocked_face (void *entry)
22 @@ -779,7 +783,220 @@ _get_bitmap_surface (FT_Bitmap *bi
24 format = CAIRO_FORMAT_A8;
26 - case CAIRO_ANTIALIAS_SUBPIXEL: {
27 + case CAIRO_ANTIALIAS_SUBPIXEL:
30 + unsigned char* line;
31 + unsigned char* bufBitmap;
33 + unsigned char *data_rgba;
34 + unsigned int width_rgba, stride_rgba;
38 + switch (font_options->subpixel_order) {
39 + case CAIRO_SUBPIXEL_ORDER_DEFAULT:
40 + case CAIRO_SUBPIXEL_ORDER_RGB:
41 + case CAIRO_SUBPIXEL_ORDER_BGR:
46 + case CAIRO_SUBPIXEL_ORDER_VRGB:
47 + case CAIRO_SUBPIXEL_ORDER_VBGR:
53 + * Filter the glyph to soften the color fringes
56 + stride = bitmap->pitch;
57 + stride_rgba = (width_rgba * 4 + 3) & ~3;
58 + data_rgba = calloc (1, stride_rgba * height);
60 + /* perform in-place FIR filtering in either the horizontal or
61 + * vertical direction. We're going to modify the RGB graymap,
62 + * but that's ok, because we either own it, or its part of
63 + * the FreeType glyph slot, which will not be used anymore.
65 + pitch = bitmap->pitch;
66 + line = (unsigned char*)bitmap->buffer;
68 + line -= pitch*(height-1);
72 + switch (font_options->subpixel_order) {
73 + case CAIRO_SUBPIXEL_ORDER_DEFAULT:
74 + case CAIRO_SUBPIXEL_ORDER_RGB:
75 + case CAIRO_SUBPIXEL_ORDER_BGR:
79 + for ( h = height; h > 0; h--, line += pitch ) {
80 + int pix[6] = { 0, 0, 0, 0, 0, 0 };
81 + unsigned char* p = line;
82 + unsigned char* limit = line + width*3;
86 + for (nn = 0; nn < 3; nn++)
87 + pix[2 + nn] += val * fir_filter[nn];
90 + for (nn = 0; nn < 4; nn++)
91 + pix[1 + nn] += val * fir_filter[nn];
95 + for ( ; p < limit; p++ ) {
97 + for (nn = 0; nn < 5; nn++)
98 + pix[nn] += val * fir_filter[nn];
100 + val2 = pix[0] / 256;
101 + val2 |= -(val2 >> 8);
102 + p[-2] = (unsigned char)val2;
104 + for (nn = 0; nn < 5; nn++)
105 + pix[nn] = pix[nn + 1];
107 + for (nn = 0; nn < 2; nn++ ) {
108 + val2 = pix[nn] / 256;
109 + val2 |= -(val2 >> 8);
110 + p[nn - 2] = (unsigned char)val2;
115 + case CAIRO_SUBPIXEL_ORDER_VRGB:
116 + case CAIRO_SUBPIXEL_ORDER_VBGR:
120 + for (w = 0; w < width; w++ ) {
121 + int pix[6] = { 0, 0, 0, 0, 0, 0 };
122 + unsigned char* p = bufBitmap + w;
123 + unsigned char* limit = bufBitmap + w + height*3*pitch;
127 + for (nn = 0; nn < 3; nn++)
128 + pix[2 + nn] += val*fir_filter[nn];
131 + for (nn = 0; nn < 4; nn++ )
132 + pix[1 + nn] += val * fir_filter[nn];
135 + for ( ; p < limit; p += pitch ) {
137 + for (nn = 0; nn < 5; nn++ )
138 + pix[nn] += val * fir_filter[nn];
140 + val2 = pix[0] / 256;
141 + val2 |= -(val2 >> 8);
142 + p[-2 * pitch] = (unsigned char)val2;
144 + for (nn = 0; nn < 5; nn++)
145 + pix[nn] = pix[nn+1];
148 + for (nn = 0; nn < 2; nn++) {
149 + val2 = pix[nn] / 256;
150 + val2 |= -(val2 >> 8);
151 + p[(nn - 2) * pitch] = (unsigned char)val2;
156 + default: /* shouldn't happen */
160 + /* now copy the resulting graymap into an ARGB32 image */
162 + unsigned char* in_line = bufBitmap;
163 + unsigned char* out_line = data_rgba;
166 + switch (font_options->subpixel_order) {
167 + case CAIRO_SUBPIXEL_ORDER_DEFAULT:
168 + case CAIRO_SUBPIXEL_ORDER_RGB:
169 + for ( ; h > 0; h--, in_line += pitch, out_line += stride_rgba) {
170 + unsigned char* in = in_line;
171 + int* out = (int*)out_line;
174 + for (w = width; w > 0; w--, in += 3, out += 1) {
179 + out[0] = (g << 24) | (r << 16) | (g << 8) | b;
183 + case CAIRO_SUBPIXEL_ORDER_BGR:
184 + for ( ; h > 0; h--, in_line += pitch, out_line += stride_rgba) {
185 + unsigned char* in = in_line;
186 + int* out = (int*)out_line;
189 + for (w = width; w > 0; w--, in += 3, out += 1) {
194 + out[0] = (g << 24) | (r << 16) | (g << 8) | b;
198 + case CAIRO_SUBPIXEL_ORDER_VRGB:
199 + for ( ; h > 0; h--, in_line += pitch*3, out_line += stride_rgba) {
200 + unsigned char* in = in_line;
201 + int* out = (int*)out_line;
204 + for (w = width; w > 0; w--, in += 1, out += 1) {
207 + int b = in[pitch*2];
209 + out[0] = (g << 24) | (r << 16) | (g << 8) | b;
213 + case CAIRO_SUBPIXEL_ORDER_VBGR:
214 + for ( ; h > 0; h--, in_line += pitch*3, out_line += stride_rgba) {
215 + unsigned char* in = in_line;
216 + int* out = (int*)out_line;
219 + for (w = width; w > 0; w--, in += 1, out += 1) {
220 + int r = in[2*pitch];
224 + out[0] = (g << 24) | (r << 16) | (g << 8) | b;
232 + free (bitmap->buffer);
234 + stride = stride_rgba;
235 + format = CAIRO_FORMAT_ARGB32;
239 +#else /* !FIR_FILTER */
242 unsigned char *in_line, *out_line, *in;
244 @@ -871,6 +1088,7 @@ _get_bitmap_surface (FT_Bitmap *bi
248 +#endif /* !FIR_FILTER */
251 case FT_PIXEL_MODE_GRAY2:
252 @@ -986,12 +1204,22 @@ _render_glyph_outline (FT_Face
262 case CAIRO_SUBPIXEL_ORDER_VRGB:
263 case CAIRO_SUBPIXEL_ORDER_VBGR:
274 FT_Outline_Transform (outline, &matrix);
275 Only in libcairo-1.2.4/src: cairo-ft-font.c.orig