diff options
author | James Cloos <cloos@jhcloos.com> | 2011-05-30 19:04:29 -0400 |
---|---|---|
committer | James Cloos <cloos@jhcloos.com> | 2011-05-30 19:04:29 -0400 |
commit | 80982728afa277e33022eba6cb47626e6d6c089d (patch) | |
tree | e01860ae17b060574c29c8bd69faf8862027d1bc | |
parent | cc1cbe4df07064a177d6bcdddff520fcc62908fc (diff) |
[x11-libs/cairo] Live ebuild in portage.
-rw-r--r-- | x11-libs/cairo/Manifest | 2 | ||||
-rw-r--r-- | x11-libs/cairo/cairo-9999.ebuild | 86 | ||||
-rw-r--r-- | x11-libs/cairo/files/22336.patch | 1216 |
3 files changed, 0 insertions, 1304 deletions
diff --git a/x11-libs/cairo/Manifest b/x11-libs/cairo/Manifest deleted file mode 100644 index be1313d..0000000 --- a/x11-libs/cairo/Manifest +++ /dev/null @@ -1,2 +0,0 @@ -AUX 22336.patch 36091 RMD160 b9d6f94e93f0951e5a449fc4f220aa118a00e383 SHA1 793079f3867c560eb31881112818209006d212a9 SHA256 ef526f3234599e154a0099dd5d613577e468523a75d900fd43aef821a8bf10d2 -EBUILD cairo-9999.ebuild 2386 RMD160 9fa369bb4189bcc084a53fbd89317049f025af6a SHA1 6b6d4070abc02475cf396e2c52b55b10f2a3d178 SHA256 ecddd499685e72822ae7b944383c3ac4df3da8d0639b85271638633d00b942f6 diff --git a/x11-libs/cairo/cairo-9999.ebuild b/x11-libs/cairo/cairo-9999.ebuild deleted file mode 100644 index d699d3c..0000000 --- a/x11-libs/cairo/cairo-9999.ebuild +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 1999-2009 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -EAPI=2 - -inherit autotools flag-o-matic libtool git - -EGIT_REPO_URI="git://anongit.freedesktop.org/git/cairo" - -DESCRIPTION="A vector graphics library with cross-device output support" -HOMEPAGE="http://cairographics.org/" -SRC_URI="" - -LICENSE="|| ( LGPL-2.1 MPL-1.1 )" -SLOT="0" -KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd" -IUSE="+cairoscript +cleartype debug directfb doc dri glitz opengl openvg qt sdl svg X xcb" - -# Test causes a circular depend on gtk+... since gtk+ needs cairo but test needs gtk+ so we need to block it -RESTRICT="test" - -RDEPEND="media-libs/fontconfig - >=media-libs/freetype-2.1.9 - sys-libs/zlib - media-libs/libpng - >=x11-libs/pixman-0.12.0 - directfb? ( >=dev-libs/DirectFB-0.9.24 ) - glitz? ( >=media-libs/glitz-0.5.1 ) - qt? ( x11-libs/qt ) - svg? ( dev-libs/libxml2 ) - X? ( >=x11-libs/libXrender-0.6 - x11-libs/libXext - x11-libs/libX11 - x11-libs/libXft ) - xcb? ( >=x11-libs/libxcb-0.92 - x11-libs/xcb-util )" -# test? ( -# pdf test -# x11-libs/pango -# >=x11-libs/gtk+-2.0 -# >=app-text/poppler-bindings-0.9.2[gtk] -# ps test -# virtual/ghostscript -# svg test -# >=x11-libs/gtk+-2.0 -# >=gnome-base/librsvg-2.15.0 - -DEPEND="${RDEPEND} - >=dev-util/pkgconfig-0.19 - doc? ( >=dev-util/gtk-doc-1.6 - ~app-text/docbook-xml-dtd-4.2 ) - X? ( x11-proto/renderproto ) - xcb? ( x11-proto/xcb-proto )" - -src_prepare() { - # ClearType-like patches applied by ArchLinux - use cleartype && epatch "${FILESDIR}"/22336.patch - ./autogen.sh --help - eautoreconf - - # We need to run elibtoolize to ensure correct so versioning on FreeBSD - elibtoolize -} - -src_configure() { - #gets rid of fbmmx.c inlining warnings - append-flags -finline-limit=1200 - - if use glitz && use opengl; then - export glitz_LIBS=$(pkg-config --libs glitz-glx) - fi - - econf $(use_enable X xlib) $(use_enable doc gtk-doc) \ - $(use_enable directfb) $(use_enable xcb) $(use_enable qt) \ - $(use_enable svg) $(use_enable glitz) $(use_enable X xlib-xrender) \ - $(use_enable cairoscript script) $(use_enable opengl gl)\ - $(use_enable dri drm) \ - $(use_enable debug test-surfaces) --enable-pdf --enable-png \ - --enable-ft --enable-ps \ - || die "configure failed" -} - -src_install() { - make DESTDIR="${D}" install || die "Installation failed" - dodoc AUTHORS ChangeLog NEWS README -} diff --git a/x11-libs/cairo/files/22336.patch b/x11-libs/cairo/files/22336.patch deleted file mode 100644 index 51bd8e2..0000000 --- a/x11-libs/cairo/files/22336.patch +++ /dev/null @@ -1,1216 +0,0 @@ -diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c -index b2cb230..1f43528 100644 ---- a/src/cairo-font-options.c -+++ b/src/cairo-font-options.c -@@ -39,6 +39,7 @@ - static const cairo_font_options_t _cairo_font_options_nil = { - CAIRO_ANTIALIAS_DEFAULT, - CAIRO_SUBPIXEL_ORDER_DEFAULT, -+ CAIRO_LCD_FILTER_DEFAULT, - CAIRO_HINT_STYLE_DEFAULT, - CAIRO_HINT_METRICS_DEFAULT - }; -@@ -54,6 +55,7 @@ _cairo_font_options_init_default (cairo_font_options_t *options) - { - options->antialias = CAIRO_ANTIALIAS_DEFAULT; - options->subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT; -+ options->lcd_filter = CAIRO_LCD_FILTER_DEFAULT; - options->hint_style = CAIRO_HINT_STYLE_DEFAULT; - options->hint_metrics = CAIRO_HINT_METRICS_DEFAULT; - } -@@ -64,6 +66,7 @@ _cairo_font_options_init_copy (cairo_font_options_t *options, - { - options->antialias = other->antialias; - options->subpixel_order = other->subpixel_order; -+ options->lcd_filter = other->lcd_filter; - options->hint_style = other->hint_style; - options->hint_metrics = other->hint_metrics; - } -@@ -189,6 +192,8 @@ cairo_font_options_merge (cairo_font_options_t *options, - options->antialias = other->antialias; - if (other->subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT) - options->subpixel_order = other->subpixel_order; -+ if (other->lcd_filter != CAIRO_LCD_FILTER_DEFAULT) -+ options->lcd_filter = other->lcd_filter; - if (other->hint_style != CAIRO_HINT_STYLE_DEFAULT) - options->hint_style = other->hint_style; - if (other->hint_metrics != CAIRO_HINT_METRICS_DEFAULT) -@@ -221,6 +226,7 @@ cairo_font_options_equal (const cairo_font_options_t *options, - - return (options->antialias == other->antialias && - options->subpixel_order == other->subpixel_order && -+ options->lcd_filter == other->lcd_filter && - options->hint_style == other->hint_style && - options->hint_metrics == other->hint_metrics); - } -@@ -246,7 +252,8 @@ cairo_font_options_hash (const cairo_font_options_t *options) - - return ((options->antialias) | - (options->subpixel_order << 4) | -- (options->hint_style << 8) | -+ (options->lcd_filter << 8) | -+ (options->hint_style << 12) | - (options->hint_metrics << 16)); - } - slim_hidden_def (cairo_font_options_hash); -@@ -328,6 +335,48 @@ cairo_font_options_get_subpixel_order (const cairo_font_options_t *options) - } - - /** -+ * _cairo_font_options_set_lcd_filter: -+ * @options: a #cairo_font_options_t -+ * @lcd_filter: the new LCD filter -+ * -+ * Sets the LCD filter for the font options object. The LCD filter -+ * specifies how pixels are filtered when rendered with an antialiasing -+ * mode of %CAIRO_ANTIALIAS_SUBPIXEL. See the documentation for -+ * #cairo_lcd_filter_t for full details. -+ * -+ * Since: 1.8 -+ **/ -+void -+_cairo_font_options_set_lcd_filter (cairo_font_options_t *options, -+ cairo_lcd_filter_t lcd_filter) -+{ -+ if (cairo_font_options_status (options)) -+ return; -+ -+ options->lcd_filter = lcd_filter; -+} -+ -+/** -+ * _cairo_font_options_get_lcd_filter: -+ * @options: a #cairo_font_options_t -+ * -+ * Gets the LCD filter for the font options object. -+ * See the documentation for #cairo_lcd_filter_t for full details. -+ * -+ * Return value: the LCD filter for the font options object -+ * -+ * Since: 1.8 -+ **/ -+cairo_lcd_filter_t -+_cairo_font_options_get_lcd_filter (const cairo_font_options_t *options) -+{ -+ if (cairo_font_options_status ((cairo_font_options_t *) options)) -+ return CAIRO_LCD_FILTER_DEFAULT; -+ -+ return options->lcd_filter; -+} -+ -+/** - * cairo_font_options_set_hint_style: - * @options: a #cairo_font_options_t - * @hint_style: the new hint style -diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c -index 26f4a83..d71ed34 100644 ---- a/src/cairo-ft-font.c -+++ b/src/cairo-ft-font.c -@@ -59,6 +59,30 @@ - #include FT_SYNTHESIS_H - #endif - -+#if HAVE_FT_LIBRARY_SETLCDFILTER -+#include FT_LCD_FILTER_H -+#endif -+ -+/* Fontconfig version older than 2.6 didn't have these options */ -+#ifndef FC_LCD_FILTER -+#define FC_LCD_FILTER "lcdfilter" -+#endif -+/* Some Ubuntu versions defined FC_LCD_FILTER without defining the following */ -+#ifndef FC_LCD_NONE -+#define FC_LCD_NONE 0 -+#define FC_LCD_DEFAULT 1 -+#define FC_LCD_LIGHT 2 -+#define FC_LCD_LEGACY 3 -+#endif -+ -+/* FreeType version older than 2.3.5(?) didn't have these options */ -+#ifndef FT_LCD_FILTER_NONE -+#define FT_LCD_FILTER_NONE 0 -+#define FT_LCD_FILTER_DEFAULT 1 -+#define FT_LCD_FILTER_LIGHT 2 -+#define FT_LCD_FILTER_LEGACY 16 -+#endif -+ - #define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0)) - #define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0) - #define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0)) -@@ -174,6 +198,25 @@ typedef struct _cairo_ft_unscaled_font_map { - int num_open_faces; - } cairo_ft_unscaled_font_map_t; - -+static cairo_bool_t _ft_can_lcd_filter (void) { -+#if HAVE_FT_LIBRARY_SETLCDFILTER -+ FT_Library library; -+ FT_Error fterror; -+ -+ FT_Init_FreeType(&library); -+ fterror = FT_Library_SetLcdFilter(library, FT_LCD_FILTER_DEFAULT); -+ -+ if (fterror != FT_Err_Unimplemented_Feature) -+ return TRUE; -+ else -+ return FALSE; -+ -+ FT_Done_FreeType(library); -+#else -+ return FALSE; -+#endif -+} -+ - static cairo_ft_unscaled_font_map_t *cairo_ft_unscaled_font_map = NULL; - - static void -@@ -773,6 +816,282 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled, - return CAIRO_STATUS_SUCCESS; - } - -+/* we sometimes need to convert the glyph bitmap in a FT_GlyphSlot -+ * into a different format. For example, we want to convert a -+ * FT_PIXEL_MODE_LCD or FT_PIXEL_MODE_LCD_V bitmap into a 32-bit -+ * ARGB or ABGR bitmap. -+ * -+ * this function prepares a target descriptor for this operation. -+ * -+ * input :: target bitmap descriptor. The function will set its -+ * 'width', 'rows' and 'pitch' fields, and only these -+ * -+ * slot :: the glyph slot containing the source bitmap. this -+ * function assumes that slot->format == FT_GLYPH_FORMAT_BITMAP -+ * -+ * mode :: the requested final rendering mode. supported values are -+ * MONO, NORMAL (i.e. gray), LCD and LCD_V -+ * -+ * the function returns the size in bytes of the corresponding buffer, -+ * it's up to the caller to allocate the corresponding memory block -+ * before calling _fill_xrender_bitmap -+ * -+ * it also returns -1 in case of error (e.g. incompatible arguments, -+ * like trying to convert a gray bitmap into a monochrome one) -+ */ -+static int -+_compute_xrender_bitmap_size(FT_Bitmap *target, -+ FT_GlyphSlot slot, -+ FT_Render_Mode mode) -+{ -+ FT_Bitmap *ftbit; -+ int width, height, pitch; -+ -+ if (slot->format != FT_GLYPH_FORMAT_BITMAP) -+ return -1; -+ -+ /* compute the size of the final bitmap */ -+ ftbit = &slot->bitmap; -+ -+ width = ftbit->width; -+ height = ftbit->rows; -+ pitch = (width + 3) & ~3; -+ -+ switch (ftbit->pixel_mode) { -+ case FT_PIXEL_MODE_MONO: -+ if (mode == FT_RENDER_MODE_MONO) { -+ pitch = (((width + 31) & ~31) >> 3); -+ break; -+ } -+ /* fall-through */ -+ -+ case FT_PIXEL_MODE_GRAY: -+ if (mode == FT_RENDER_MODE_LCD || -+ mode == FT_RENDER_MODE_LCD_V) -+ { -+ /* each pixel is replicated into a 32-bit ARGB value */ -+ pitch = width * 4; -+ } -+ break; -+ -+ case FT_PIXEL_MODE_LCD: -+ if (mode != FT_RENDER_MODE_LCD) -+ return -1; -+ -+ /* horz pixel triplets are packed into 32-bit ARGB values */ -+ width /= 3; -+ pitch = width * 4; -+ break; -+ -+ case FT_PIXEL_MODE_LCD_V: -+ if (mode != FT_RENDER_MODE_LCD_V) -+ return -1; -+ -+ /* vert pixel triplets are packed into 32-bit ARGB values */ -+ height /= 3; -+ pitch = width * 4; -+ break; -+ -+ default: /* unsupported source format */ -+ return -1; -+ } -+ -+ target->width = width; -+ target->rows = height; -+ target->pitch = pitch; -+ target->buffer = NULL; -+ -+ return pitch * height; -+} -+ -+/* this functions converts the glyph bitmap found in a FT_GlyphSlot -+ * into a different format (see _compute_xrender_bitmap_size) -+ * -+ * you should call this function after _compute_xrender_bitmap_size -+ * -+ * target :: target bitmap descriptor. Note that its 'buffer' pointer -+ * must point to memory allocated by the caller -+ * -+ * slot :: the glyph slot containing the source bitmap -+ * -+ * mode :: the requested final rendering mode -+ * -+ * bgr :: boolean, set if BGR or VBGR pixel ordering is needed -+ */ -+static void -+_fill_xrender_bitmap(FT_Bitmap *target, -+ FT_GlyphSlot slot, -+ FT_Render_Mode mode, -+ int bgr) -+{ -+ FT_Bitmap *ftbit = &slot->bitmap; -+ unsigned char *srcLine = ftbit->buffer; -+ unsigned char *dstLine = target->buffer; -+ int src_pitch = ftbit->pitch; -+ int width = target->width; -+ int height = target->rows; -+ int pitch = target->pitch; -+ int subpixel; -+ int h; -+ -+ subpixel = (mode == FT_RENDER_MODE_LCD || -+ mode == FT_RENDER_MODE_LCD_V); -+ -+ if (src_pitch < 0) -+ srcLine -= src_pitch * (ftbit->rows - 1); -+ -+ target->pixel_mode = ftbit->pixel_mode; -+ -+ switch (ftbit->pixel_mode) { -+ case FT_PIXEL_MODE_MONO: -+ if (subpixel) { -+ /* convert mono to ARGB32 values */ -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) { -+ int x; -+ -+ for (x = 0; x < width; x++) { -+ if (srcLine[(x >> 3)] & (0x80 >> (x & 7))) -+ ((unsigned int *) dstLine)[x] = 0xffffffffU; -+ } -+ } -+ target->pixel_mode = FT_PIXEL_MODE_LCD; -+ -+ } else if (mode == FT_RENDER_MODE_NORMAL) { -+ /* convert mono to 8-bit gray */ -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) { -+ int x; -+ -+ for (x = 0; x < width; x++) { -+ if (srcLine[(x >> 3)] & (0x80 >> (x & 7))) -+ dstLine[x] = 0xff; -+ } -+ } -+ target->pixel_mode = FT_PIXEL_MODE_GRAY; -+ -+ } else { -+ /* copy mono to mono */ -+ -+ int bytes = (width + 7) >> 3; -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) -+ memcpy (dstLine, srcLine, bytes); -+ } -+ break; -+ -+ case FT_PIXEL_MODE_GRAY: -+ if (subpixel) { -+ /* convert gray to ARGB32 values */ -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) { -+ int x; -+ unsigned int *dst = (unsigned int *) dstLine; -+ -+ for (x = 0; x < width; x++) { -+ unsigned int pix = srcLine[x]; -+ -+ pix |= (pix << 8); -+ pix |= (pix << 16); -+ -+ dst[x] = pix; -+ } -+ } -+ target->pixel_mode = FT_PIXEL_MODE_LCD; -+ } else { -+ /* copy gray into gray */ -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) -+ memcpy (dstLine, srcLine, width); -+ } -+ break; -+ -+ case FT_PIXEL_MODE_LCD: -+ if (!bgr) { -+ /* convert horizontal RGB into ARGB32 */ -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) { -+ int x; -+ unsigned char *src = srcLine; -+ unsigned int *dst = (unsigned int *) dstLine; -+ -+ for (x = 0; x < width; x++, src += 3) { -+ unsigned int pix; -+ -+ pix = ((unsigned int)src[0] << 16) | -+ ((unsigned int)src[1] << 8) | -+ ((unsigned int)src[2] ) | -+ ((unsigned int)src[1] << 24) ; -+ -+ dst[x] = pix; -+ } -+ } -+ } else { -+ /* convert horizontal BGR into ARGB32 */ -+ -+ for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) { -+ -+ int x; -+ unsigned char *src = srcLine; -+ unsigned int *dst = (unsigned int *) dstLine; -+ -+ for (x = 0; x < width; x++, src += 3) { -+ unsigned int pix; -+ -+ pix = ((unsigned int)src[2] << 16) | -+ ((unsigned int)src[1] << 8) | -+ ((unsigned int)src[0] ) | -+ ((unsigned int)src[1] << 24) ; -+ -+ dst[x] = pix; -+ } -+ } -+ } -+ break; -+ -+ default: /* FT_PIXEL_MODE_LCD_V */ -+ /* convert vertical RGB into ARGB32 */ -+ if (!bgr) { -+ -+ for (h = height; h > 0; h--, srcLine += 3 * src_pitch, dstLine += pitch) { -+ int x; -+ unsigned char* src = srcLine; -+ unsigned int* dst = (unsigned int *) dstLine; -+ -+ for (x = 0; x < width; x++, src += 1) { -+ unsigned int pix; -+ -+ pix = ((unsigned int)src[0] << 16) | -+ ((unsigned int)src[src_pitch] << 8) | -+ ((unsigned int)src[src_pitch*2] ) | -+ ((unsigned int)src[src_pitch] << 24) ; -+ -+ dst[x] = pix; -+ } -+ } -+ } else { -+ -+ for (h = height; h > 0; h--, srcLine += 3*src_pitch, dstLine += pitch) { -+ int x; -+ unsigned char *src = srcLine; -+ unsigned int *dst = (unsigned int *) dstLine; -+ -+ for (x = 0; x < width; x++, src += 1) { -+ unsigned int pix; -+ -+ pix = ((unsigned int)src[src_pitch * 2] << 16) | -+ ((unsigned int)src[src_pitch] << 8) | -+ ((unsigned int)src[0] ) | -+ ((unsigned int)src[src_pitch] << 24) ; -+ -+ dst[x] = pix; -+ } -+ } -+ } -+ } -+} -+ -+ - /* Empirically-derived subpixel filtering values thanks to Keith - * Packard and libXft. */ - static const int filters[3][3] = { -@@ -802,7 +1121,6 @@ _get_bitmap_surface (FT_Bitmap *bitmap, - int width, height, stride; - unsigned char *data; - int format = CAIRO_FORMAT_A8; -- cairo_bool_t subpixel = FALSE; - - width = bitmap->width; - height = bitmap->rows; -@@ -844,7 +1162,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap, - - #ifndef WORDS_BIGENDIAN - { -- uint8_t *d = data; -+ uint8_t *d = data; - int count = stride * height; - - while (count--) { -@@ -871,108 +1189,115 @@ _get_bitmap_surface (FT_Bitmap *bitmap, - data = _cairo_malloc_ab (height, stride); - if (!data) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); -- - memcpy (data, bitmap->buffer, stride * height); - } -- format = CAIRO_FORMAT_A8; -- break; -- case CAIRO_ANTIALIAS_SUBPIXEL: { -- int x, y; -- unsigned char *in_line, *out_line, *in; -- unsigned int *out; -- unsigned int red, green, blue; -- int rf, gf, bf; -- int s; -- int o, os; -- unsigned char *data_rgba; -- unsigned int width_rgba, stride_rgba; -- int vmul = 1; -- int hmul = 1; -+ format = CAIRO_FORMAT_A8; -+ break; -+ case CAIRO_ANTIALIAS_SUBPIXEL: -+ if (_ft_can_lcd_filter()) { -+ /* if we get there, the data from the source bitmap -+ * really comes from _fill_xrender_bitmap, and is -+ * made of 32-bit ARGB or ABGR values */ -+ assert (own_buffer != 0); -+ assert (bitmap->pixel_mode != FT_PIXEL_MODE_GRAY); - -- switch (font_options->subpixel_order) { -- case CAIRO_SUBPIXEL_ORDER_DEFAULT: -- case CAIRO_SUBPIXEL_ORDER_RGB: -- case CAIRO_SUBPIXEL_ORDER_BGR: -- default: -- width /= 3; -- hmul = 3; -- break; -- case CAIRO_SUBPIXEL_ORDER_VRGB: -- case CAIRO_SUBPIXEL_ORDER_VBGR: -- vmul = 3; -- height /= 3; -- break; -- } -- /* -- * Filter the glyph to soften the color fringes -- */ -- width_rgba = width; -- stride = bitmap->pitch; -- stride_rgba = (width_rgba * 4 + 3) & ~3; -- data_rgba = calloc (stride_rgba, height); -- if (unlikely (data_rgba == NULL)) { -- if (own_buffer) -+ data = bitmap->buffer; -+ stride = bitmap->pitch; -+ format = CAIRO_FORMAT_ARGB32; -+ } else { -+ int x, y; -+ unsigned char *in_line, *out_line, *in; -+ unsigned int *out; -+ unsigned int red, green, blue; -+ int rf, gf, bf; -+ int s; -+ int o, os; -+ unsigned char *data_rgba; -+ unsigned int width_rgba, stride_rgba; -+ int vmul = 1; -+ int hmul = 1; -+ -+ switch (font_options->subpixel_order) { -+ case CAIRO_SUBPIXEL_ORDER_DEFAULT: -+ case CAIRO_SUBPIXEL_ORDER_RGB: -+ case CAIRO_SUBPIXEL_ORDER_BGR: -+ default: -+ width /= 3; -+ hmul = 3; -+ break; -+ case CAIRO_SUBPIXEL_ORDER_VRGB: -+ case CAIRO_SUBPIXEL_ORDER_VBGR: -+ vmul = 3; -+ height /= 3; -+ break; -+ } -+ /* -+ * Filter the glyph to soften the color fringes -+ */ -+ width_rgba = width; -+ stride = bitmap->pitch; -+ stride_rgba = (width_rgba * 4 + 3) & ~3; -+ data_rgba = calloc (stride_rgba, height); -+ if (data_rgba == NULL) { -+ if (own_buffer) - free (bitmap->buffer); -- return _cairo_error (CAIRO_STATUS_NO_MEMORY); -- } -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ } - -- os = 1; -- switch (font_options->subpixel_order) { -- case CAIRO_SUBPIXEL_ORDER_VRGB: -- os = stride; -- case CAIRO_SUBPIXEL_ORDER_DEFAULT: -- case CAIRO_SUBPIXEL_ORDER_RGB: -- default: -- rf = 0; -- gf = 1; -- bf = 2; -- break; -- case CAIRO_SUBPIXEL_ORDER_VBGR: -- os = stride; -- case CAIRO_SUBPIXEL_ORDER_BGR: -- bf = 0; -- gf = 1; -- rf = 2; -- break; -- } -- in_line = bitmap->buffer; -- out_line = data_rgba; -- for (y = 0; y < height; y++) -- { -- in = in_line; -- out = (unsigned int *) out_line; -- in_line += stride * vmul; -- out_line += stride_rgba; -- for (x = 0; x < width * hmul; x += hmul) -+ os = 1; -+ switch (font_options->subpixel_order) { -+ case CAIRO_SUBPIXEL_ORDER_VRGB: -+ os = stride; -+ case CAIRO_SUBPIXEL_ORDER_DEFAULT: -+ case CAIRO_SUBPIXEL_ORDER_RGB: -+ default: -+ rf = 0; -+ gf = 1; -+ bf = 2; -+ break; -+ case CAIRO_SUBPIXEL_ORDER_VBGR: -+ os = stride; -+ case CAIRO_SUBPIXEL_ORDER_BGR: -+ bf = 0; -+ gf = 1; -+ rf = 2; -+ break; -+ } -+ in_line = bitmap->buffer; -+ out_line = data_rgba; -+ for (y = 0; y < height; y++) - { -- red = green = blue = 0; -- o = 0; -- for (s = 0; s < 3; s++) -+ in = in_line; -+ out = (unsigned int *) out_line; -+ in_line += stride * vmul; -+ out_line += stride_rgba; -+ for (x = 0; x < width * hmul; x += hmul) - { -- red += filters[rf][s]*in[x+o]; -- green += filters[gf][s]*in[x+o]; -- blue += filters[bf][s]*in[x+o]; -- o += os; -+ red = green = blue = 0; -+ o = 0; -+ for (s = 0; s < 3; s++) -+ { -+ red += filters[rf][s]*in[x+o]; -+ green += filters[gf][s]*in[x+o]; -+ blue += filters[bf][s]*in[x+o]; -+ o += os; -+ } -+ red = red / 65536; -+ green = green / 65536; -+ blue = blue / 65536; -+ *out++ = (green << 24) | (red << 16) | (green << 8) | blue; - } -- red = red / 65536; -- green = green / 65536; -- blue = blue / 65536; -- *out++ = (green << 24) | (red << 16) | (green << 8) | blue; - } -- } - -- /* Images here are stored in native format. The -- * backend must convert to its own format as needed -- */ -- -- if (own_buffer) -+ /* Images here are stored in native format. The -+ * backend must convert to its own format as needed -+ */ -+ if (own_buffer) - free (bitmap->buffer); -- data = data_rgba; -- stride = stride_rgba; -- format = CAIRO_FORMAT_ARGB32; -- subpixel = TRUE; -- break; -- } -+ data = data_rgba; -+ stride = stride_rgba; -+ format = CAIRO_FORMAT_ARGB32; -+ } - } - break; - case FT_PIXEL_MODE_GRAY2: -@@ -993,7 +1318,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap, - return (*surface)->base.status; - } - -- if (subpixel) -+ if (font_options->antialias == CAIRO_ANTIALIAS_SUBPIXEL) - pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE); - - _cairo_image_surface_assume_ownership_of_data ((*surface)); -@@ -1023,16 +1348,67 @@ _render_glyph_outline (FT_Face face, - cairo_font_options_t *font_options, - cairo_image_surface_t **surface) - { -+ int rgba = FC_RGBA_UNKNOWN; -+ int lcd_filter = FT_LCD_FILTER_LEGACY; - FT_GlyphSlot glyphslot = face->glyph; - FT_Outline *outline = &glyphslot->outline; - FT_Bitmap bitmap; - FT_BBox cbox; -- FT_Matrix matrix; -- int hmul = 1; -- int vmul = 1; -- unsigned int width, height, stride; -- cairo_bool_t subpixel = FALSE; -+ unsigned int width, height; -+ double device_offset_left, device_offset_top; - cairo_status_t status; -+ cairo_bool_t ft_can_filter = FALSE; -+ FT_Error fterror; -+ FT_Library library = glyphslot->library; -+ FT_Render_Mode render_mode = FT_RENDER_MODE_NORMAL; -+ -+#if HAVE_FT_LIBRARY_SETLCDFILTER -+ fterror = FT_Library_SetLcdFilter (library, FT_LCD_FILTER_NONE); -+ if(fterror != FT_Err_Unimplemented_Feature) -+ ft_can_filter = TRUE; -+#endif -+ -+ switch (font_options->antialias) { -+ case CAIRO_ANTIALIAS_NONE: -+ render_mode = FT_RENDER_MODE_MONO; -+ break; -+ case CAIRO_ANTIALIAS_SUBPIXEL: -+ switch (font_options->lcd_filter) { -+ case CAIRO_LCD_FILTER_NONE: -+ lcd_filter = FT_LCD_FILTER_NONE; -+ break; -+ case CAIRO_LCD_FILTER_DEFAULT: -+ case CAIRO_LCD_FILTER_INTRA_PIXEL: -+ lcd_filter = FT_LCD_FILTER_LEGACY; -+ break; -+ case CAIRO_LCD_FILTER_FIR3: -+ lcd_filter = FT_LCD_FILTER_LIGHT; -+ break; -+ case CAIRO_LCD_FILTER_FIR5: -+ lcd_filter = FT_LCD_FILTER_DEFAULT; -+ break; -+ } -+ -+ if (ft_can_filter) { -+ switch (font_options->subpixel_order) { -+ case CAIRO_SUBPIXEL_ORDER_DEFAULT: -+ case CAIRO_SUBPIXEL_ORDER_RGB: -+ case CAIRO_SUBPIXEL_ORDER_BGR: -+ render_mode = FT_RENDER_MODE_LCD; -+ break; -+ -+ case CAIRO_SUBPIXEL_ORDER_VRGB: -+ case CAIRO_SUBPIXEL_ORDER_VBGR: -+ render_mode = FT_RENDER_MODE_LCD_V; -+ break; -+ } -+ } -+ -+ break; -+ case CAIRO_ANTIALIAS_DEFAULT: -+ case CAIRO_ANTIALIAS_GRAY: -+ render_mode = FT_RENDER_MODE_NORMAL; -+ } - - FT_Outline_Get_CBox (outline, &cbox); - -@@ -1043,20 +1419,21 @@ _render_glyph_outline (FT_Face face, - - width = (unsigned int) ((cbox.xMax - cbox.xMin) >> 6); - height = (unsigned int) ((cbox.yMax - cbox.yMin) >> 6); -- stride = (width * hmul + 3) & ~3; - - if (width * height == 0) { - cairo_format_t format; - /* Looks like fb handles zero-sized images just fine */ -- switch (font_options->antialias) { -- case CAIRO_ANTIALIAS_NONE: -+ switch (render_mode) { -+ case FT_RENDER_MODE_MONO: - format = CAIRO_FORMAT_A1; - break; -- case CAIRO_ANTIALIAS_SUBPIXEL: -+ case FT_RENDER_MODE_LCD: -+ case FT_RENDER_MODE_LCD_V: - format= CAIRO_FORMAT_ARGB32; - break; -- case CAIRO_ANTIALIAS_DEFAULT: -- case CAIRO_ANTIALIAS_GRAY: -+ case FT_RENDER_MODE_LIGHT: -+ case FT_RENDER_MODE_NORMAL: -+ case FT_RENDER_MODE_MAX: - default: - format = CAIRO_FORMAT_A8; - break; -@@ -1066,75 +1443,142 @@ _render_glyph_outline (FT_Face face, - cairo_image_surface_create_for_data (NULL, format, 0, 0, 0); - if ((*surface)->base.status) - return (*surface)->base.status; -- } else { - -- matrix.xx = matrix.yy = 0x10000L; -- matrix.xy = matrix.yx = 0; -+ } else { -+ int bitmap_size; - -- switch (font_options->antialias) { -- case CAIRO_ANTIALIAS_NONE: -- bitmap.pixel_mode = FT_PIXEL_MODE_MONO; -- bitmap.num_grays = 1; -- stride = ((width + 31) & -32) >> 3; -- break; -- case CAIRO_ANTIALIAS_DEFAULT: -- case CAIRO_ANTIALIAS_GRAY: -- bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; -- bitmap.num_grays = 256; -- stride = (width + 3) & -4; -- break; -- case CAIRO_ANTIALIAS_SUBPIXEL: -- switch (font_options->subpixel_order) { -- case CAIRO_SUBPIXEL_ORDER_RGB: -- case CAIRO_SUBPIXEL_ORDER_BGR: -- case CAIRO_SUBPIXEL_ORDER_DEFAULT: -+ if (ft_can_filter) { -+ switch (render_mode) { -+ case FT_RENDER_MODE_LCD: -+ if (font_options->subpixel_order == CAIRO_SUBPIXEL_ORDER_BGR) { -+ rgba = FC_RGBA_BGR; -+ } else { -+ rgba = FC_RGBA_RGB; -+ } -+ break; -+ case FT_RENDER_MODE_LCD_V: -+ if (font_options->subpixel_order == CAIRO_SUBPIXEL_ORDER_VBGR) { -+ rgba = FC_RGBA_VBGR; -+ } else { -+ rgba = FC_RGBA_VRGB; -+ } -+ break; -+ case FT_RENDER_MODE_MONO: -+ case FT_RENDER_MODE_LIGHT: -+ case FT_RENDER_MODE_NORMAL: -+ case FT_RENDER_MODE_MAX: - default: -- matrix.xx *= 3; -- hmul = 3; -- subpixel = TRUE; - break; -- case CAIRO_SUBPIXEL_ORDER_VRGB: -- case CAIRO_SUBPIXEL_ORDER_VBGR: -- matrix.yy *= 3; -- vmul = 3; -- subpixel = TRUE; -+ } -+ -+#if HAVE_FT_LIBRARY_SETLCDFILTER -+ FT_Library_SetLcdFilter (library, lcd_filter); -+#endif -+ -+ fterror = FT_Render_Glyph (face->glyph, render_mode); -+ -+#if HAVE_FT_LIBRARY_SETLCDFILTER -+ FT_Library_SetLcdFilter (library, FT_LCD_FILTER_NONE); -+#endif -+ -+ if (fterror != 0) -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ -+ bitmap_size = _compute_xrender_bitmap_size (&bitmap, -+ face->glyph, -+ render_mode); -+ if (bitmap_size < 0) -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ -+ bitmap.buffer = calloc (1, bitmap_size); -+ if (bitmap.buffer == NULL) -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ -+ _fill_xrender_bitmap (&bitmap, face->glyph, render_mode, -+ (rgba == FC_RGBA_BGR || rgba == FC_RGBA_VBGR)); -+ -+ device_offset_left = (double)-glyphslot->bitmap_left; -+ device_offset_top = (double)+glyphslot->bitmap_top; -+ } else { -+ FT_Matrix matrix; -+ int hmul = 1; -+ int vmul = 1; -+ unsigned int stride; -+ -+ stride = (width * hmul + 3) & ~3; -+ -+ matrix.xx = matrix.yy = 0x10000L; -+ matrix.xy = matrix.yx = 0; -+ -+ switch (font_options->antialias) { -+ case CAIRO_ANTIALIAS_NONE: -+ bitmap.pixel_mode = FT_PIXEL_MODE_MONO; -+ bitmap.num_grays = 1; -+ stride = ((width + 31) & -32) >> 3; - break; -+ case CAIRO_ANTIALIAS_DEFAULT: -+ case CAIRO_ANTIALIAS_GRAY: -+ bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; -+ bitmap.num_grays = 256; -+ stride = (width + 3) & -4; -+ break; -+ case CAIRO_ANTIALIAS_SUBPIXEL: -+ switch (font_options->subpixel_order) { -+ case CAIRO_SUBPIXEL_ORDER_RGB: -+ case CAIRO_SUBPIXEL_ORDER_BGR: -+ case CAIRO_SUBPIXEL_ORDER_DEFAULT: -+ default: -+ matrix.xx *= 3; -+ hmul = 3; -+ break; -+ case CAIRO_SUBPIXEL_ORDER_VRGB: -+ case CAIRO_SUBPIXEL_ORDER_VBGR: -+ matrix.yy *= 3; -+ vmul = 3; -+ break; -+ } -+ -+ FT_Outline_Transform (outline, &matrix); -+ -+ bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; -+ bitmap.num_grays = 256; -+ stride = (width * hmul + 3) & -4; - } -- FT_Outline_Transform (outline, &matrix); - -- bitmap.pixel_mode = FT_PIXEL_MODE_GRAY; -- bitmap.num_grays = 256; -- stride = (width * hmul + 3) & -4; -- } -+ bitmap.pitch = stride; -+ bitmap.width = width * hmul; -+ bitmap.rows = height * vmul; -+ bitmap.buffer = calloc (stride, bitmap.rows); -+ if (bitmap.buffer == NULL) -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); - -- bitmap.pitch = stride; -- bitmap.width = width * hmul; -- bitmap.rows = height * vmul; -- bitmap.buffer = calloc (stride, bitmap.rows); -- if (unlikely (bitmap.buffer == NULL)) -- return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ FT_Outline_Translate (outline, -cbox.xMin*hmul, -cbox.yMin*vmul); - -- FT_Outline_Translate (outline, -cbox.xMin*hmul, -cbox.yMin*vmul); -+ if (FT_Outline_Get_Bitmap (glyphslot->library, outline, &bitmap) != 0) { -+ free (bitmap.buffer); -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ } - -- if (FT_Outline_Get_Bitmap (glyphslot->library, outline, &bitmap) != 0) { -- free (bitmap.buffer); -- return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ device_offset_left = floor (-(double) cbox.xMin / 64.0); -+ device_offset_top = floor (+(double) cbox.yMax / 64.0); - } - -+ /* Note: -+ * _get_bitmap_surface will free bitmap.buffer if there is an error -+ */ - status = _get_bitmap_surface (&bitmap, TRUE, font_options, surface); - if (unlikely (status)) - return status; -- } - -- /* -- * Note: the font's coordinate system is upside down from ours, so the -- * Y coordinate of the control box needs to be negated. Moreover, device -- * offsets are position of glyph origin relative to top left while xMin -- * and yMax are offsets of top left relative to origin. Another negation. -- */ -- cairo_surface_set_device_offset (&(*surface)->base, -- floor (-(double) cbox.xMin / 64.0), -- floor (+(double) cbox.yMax / 64.0)); -+ /* Note: the font's coordinate system is upside down from ours, so the -+ * Y coordinate of the control box needs to be negated. Moreover, device -+ * offsets are position of glyph origin relative to top left while xMin -+ * and yMax are offsets of top left relative to origin. Another negation. -+ */ -+ cairo_surface_set_device_offset (&(*surface)->base, -+ device_offset_left, -+ device_offset_top); -+ } - - return CAIRO_STATUS_SUCCESS; - } -@@ -1351,9 +1795,10 @@ _get_pattern_ft_options (FcPattern *pattern, cairo_ft_options_t *ret) - if (FcPatternGetBool (pattern, - FC_ANTIALIAS, 0, &antialias) != FcResultMatch) - antialias = FcTrue; -- -+ - if (antialias) { - cairo_subpixel_order_t subpixel_order; -+ int lcd_filter; - - /* disable hinting if requested */ - if (FcPatternGetBool (pattern, -@@ -1389,6 +1834,25 @@ _get_pattern_ft_options (FcPattern *pattern, cairo_ft_options_t *ret) - ft_options.base.antialias = CAIRO_ANTIALIAS_SUBPIXEL; - } - -+ if (FcPatternGetInteger (pattern, -+ FC_LCD_FILTER, 0, &lcd_filter) == FcResultMatch) -+ { -+ switch (lcd_filter) { -+ case FC_LCD_NONE: -+ ft_options.base.lcd_filter = CAIRO_LCD_FILTER_NONE; -+ break; -+ case FC_LCD_DEFAULT: -+ ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR5; -+ break; -+ case FC_LCD_LIGHT: -+ ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR3; -+ break; -+ case FC_LCD_LEGACY: -+ ft_options.base.lcd_filter = CAIRO_LCD_FILTER_INTRA_PIXEL; -+ break; -+ } -+ } -+ - #ifdef FC_HINT_STYLE - if (FcPatternGetInteger (pattern, - FC_HINT_STYLE, 0, &hintstyle) != FcResultMatch) -@@ -1490,6 +1954,12 @@ _cairo_ft_options_merge (cairo_ft_options_t *options, - if (other->base.hint_style == CAIRO_HINT_STYLE_NONE) - options->base.hint_style = CAIRO_HINT_STYLE_NONE; - -+ if (options->base.lcd_filter == CAIRO_LCD_FILTER_DEFAULT) -+ options->base.lcd_filter = other->base.lcd_filter; -+ -+ if (other->base.lcd_filter == CAIRO_LCD_FILTER_NONE) -+ options->base.lcd_filter = CAIRO_LCD_FILTER_NONE; -+ - if (options->base.antialias == CAIRO_ANTIALIAS_NONE) { - if (options->base.hint_style == CAIRO_HINT_STYLE_NONE) - load_flags |= FT_LOAD_NO_HINTING; -@@ -1502,7 +1972,7 @@ _cairo_ft_options_merge (cairo_ft_options_t *options, - load_flags |= FT_LOAD_NO_HINTING; - break; - case CAIRO_HINT_STYLE_SLIGHT: -- load_target = FT_LOAD_TARGET_LIGHT; -+ load_target |= FT_LOAD_TARGET_LIGHT; - break; - case CAIRO_HINT_STYLE_MEDIUM: - break; -@@ -2516,6 +2986,34 @@ _cairo_ft_font_options_substitute (const cairo_font_options_t *options, - } - } - -+ if (options->lcd_filter != CAIRO_LCD_FILTER_DEFAULT) -+ { -+ if (FcPatternGet (pattern, FC_LCD_FILTER, 0, &v) == FcResultNoMatch) -+ { -+ int lcd_filter; -+ -+ switch (options->lcd_filter) { -+ case CAIRO_LCD_FILTER_NONE: -+ lcd_filter = FT_LCD_FILTER_NONE; -+ break; -+ case CAIRO_LCD_FILTER_DEFAULT: -+ case CAIRO_LCD_FILTER_INTRA_PIXEL: -+ lcd_filter = FT_LCD_FILTER_LEGACY; -+ break; -+ case CAIRO_LCD_FILTER_FIR3: -+ lcd_filter = FT_LCD_FILTER_LIGHT; -+ break; -+ default: -+ case CAIRO_LCD_FILTER_FIR5: -+ lcd_filter = FT_LCD_FILTER_DEFAULT; -+ break; -+ } -+ -+ if (! FcPatternAddInteger (pattern, FC_LCD_FILTER, lcd_filter)) -+ return _cairo_error (CAIRO_STATUS_NO_MEMORY); -+ } -+ } -+ - if (options->hint_style != CAIRO_HINT_STYLE_DEFAULT) - { - if (FcPatternGet (pattern, FC_HINTING, 0, &v) == FcResultNoMatch) -diff --git a/src/cairo-mutex.c b/src/cairo-mutex.c -index 5b6a6e1..8b50a2e 100644 ---- a/src/cairo-mutex.c -+++ b/src/cairo-mutex.c -@@ -35,7 +35,7 @@ - - #include "cairo-mutex-private.h" - --#define CAIRO_MUTEX_DECLARE(mutex) cairo_mutex_t mutex = CAIRO_MUTEX_NIL_INITIALIZER; -+#define CAIRO_MUTEX_DECLARE(mutex) cairo_private cairo_mutex_t mutex = CAIRO_MUTEX_NIL_INITIALIZER; - #include "cairo-mutex-list-private.h" - #undef CAIRO_MUTEX_DECLARE - -diff --git a/src/cairo-surface.c b/src/cairo-surface.c -index f656ed5..4561117 100644 ---- a/src/cairo-surface.c -+++ b/src/cairo-surface.c -@@ -70,6 +70,7 @@ const cairo_surface_t name = { \ - FALSE, /* has_font_options */ \ - { CAIRO_ANTIALIAS_DEFAULT, /* antialias */ \ - CAIRO_SUBPIXEL_ORDER_DEFAULT, /* subpixel_order */ \ -+ CAIRO_LCD_FILTER_DEFAULT, /* lcd_filter */ \ - CAIRO_HINT_STYLE_DEFAULT, /* hint_style */ \ - CAIRO_HINT_METRICS_DEFAULT /* hint_metrics */ \ - } /* font_options */ \ -diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h -index a68fe50..ba608bb 100644 ---- a/src/cairo-types-private.h -+++ b/src/cairo-types-private.h -@@ -117,9 +117,35 @@ struct _cairo_array { - cairo_bool_t is_snapshot; - }; - -+ -+/** -+ * cairo_lcd_filter_t: -+ * @CAIRO_LCD_FILTER_DEFAULT: Use the default LCD filter for -+ * font backend and target device -+ * @CAIRO_LCD_FILTER_NONE: Do not perform LCD filtering -+ * @CAIRO_LCD_FILTER_INTRA_PIXEL: Intra-pixel filter -+ * @CAIRO_LCD_FILTER_FIR3: FIR filter with a 3x3 kernel -+ * @CAIRO_LCD_FILTER_FIR5: FIR filter with a 5x5 kernel -+ * -+ * The LCD filter specifies the low-pass filter applied to LCD-optimized -+ * bitmaps generated with an antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL. -+ * -+ * Note: This API was temporarily made available in the public -+ * interface during the 1.7.x development series, but was made private -+ * before 1.8. -+ **/ -+typedef enum _cairo_lcd_filter { -+ CAIRO_LCD_FILTER_DEFAULT, -+ CAIRO_LCD_FILTER_NONE, -+ CAIRO_LCD_FILTER_INTRA_PIXEL, -+ CAIRO_LCD_FILTER_FIR3, -+ CAIRO_LCD_FILTER_FIR5 -+} cairo_lcd_filter_t; -+ - struct _cairo_font_options { - cairo_antialias_t antialias; - cairo_subpixel_order_t subpixel_order; -+ cairo_lcd_filter_t lcd_filter; - cairo_hint_style_t hint_style; - cairo_hint_metrics_t hint_metrics; - }; -diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c -index e491a33..4248b64 100644 ---- a/src/cairo-xlib-screen.c -+++ b/src/cairo-xlib-screen.c -@@ -150,13 +150,22 @@ _cairo_xlib_init_screen_font_options (Display *dpy, - cairo_bool_t xft_antialias; - int xft_hintstyle; - int xft_rgba; -+ int xft_lcdfilter; - cairo_antialias_t antialias; - cairo_subpixel_order_t subpixel_order; -+ cairo_lcd_filter_t lcd_filter; - cairo_hint_style_t hint_style; - - if (!get_boolean_default (dpy, "antialias", &xft_antialias)) - xft_antialias = TRUE; - -+ if (!get_integer_default (dpy, "lcdfilter", &xft_lcdfilter)) { -+ /* -1 is an non-existant Fontconfig constant used to differentiate -+ * the case when no lcdfilter property is available. -+ */ -+ xft_lcdfilter = -1; -+ } -+ - if (!get_boolean_default (dpy, "hinting", &xft_hinting)) - xft_hinting = TRUE; - -@@ -239,6 +248,24 @@ _cairo_xlib_init_screen_font_options (Display *dpy, - subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT; - } - -+ switch (xft_lcdfilter) { -+ case FC_LCD_NONE: -+ lcd_filter = CAIRO_LCD_FILTER_NONE; -+ break; -+ case FC_LCD_DEFAULT: -+ lcd_filter = CAIRO_LCD_FILTER_FIR5; -+ break; -+ case FC_LCD_LIGHT: -+ lcd_filter = CAIRO_LCD_FILTER_FIR3; -+ break; -+ case FC_LCD_LEGACY: -+ lcd_filter = CAIRO_LCD_FILTER_INTRA_PIXEL; -+ break; -+ default: -+ lcd_filter = CAIRO_LCD_FILTER_DEFAULT; -+ break; -+ } -+ - if (xft_antialias) { - if (subpixel_order == CAIRO_SUBPIXEL_ORDER_DEFAULT) - antialias = CAIRO_ANTIALIAS_GRAY; -@@ -251,6 +278,7 @@ _cairo_xlib_init_screen_font_options (Display *dpy, - cairo_font_options_set_hint_style (&info->font_options, hint_style); - cairo_font_options_set_antialias (&info->font_options, antialias); - cairo_font_options_set_subpixel_order (&info->font_options, subpixel_order); -+ _cairo_font_options_set_lcd_filter (&info->font_options, lcd_filter); - cairo_font_options_set_hint_metrics (&info->font_options, CAIRO_HINT_METRICS_ON); - } - -diff --git a/src/cairoint.h b/src/cairoint.h -index 3cd0cb3..401f638 100644 ---- a/src/cairoint.h -+++ b/src/cairoint.h -@@ -1429,6 +1429,13 @@ cairo_private void - _cairo_font_options_init_copy (cairo_font_options_t *options, - const cairo_font_options_t *other); - -+cairo_private void -+_cairo_font_options_set_lcd_filter (cairo_font_options_t *options, -+ cairo_lcd_filter_t lcd_filter); -+ -+cairo_private cairo_lcd_filter_t -+_cairo_font_options_get_lcd_filter (const cairo_font_options_t *options); -+ - /* cairo-hull.c */ - cairo_private cairo_status_t - _cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices); |