ALT Linux repositórios
S: | 1.18.0-alt1 |
5.0: | 1.8.4-alt2 |
4.1: | 1.6.4-alt2.M41.1 |
4.0: | 1.4.14-alt0.M40.1 |
+updates: | 1.4.14-alt0.M40.1 |
3.0: | 0.5.2-alt1 |
Group :: Sistema/Bibliotecas
RPM: libcairo
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: cairo-1.8.4-alt2.patch
Download
Download
.gear-rules | 2 +
.../ec2afbd4c0fdecc14d2f65200f87dab227a14317 | 13 +
.gear-tags/list | 1 +
doc/public/cairo-sections.txt | 3 +
libcairo.spec | 206 ++++++
src/Makefile.am | 1 +
src/cairo-font-options.c | 47 ++-
src/cairo-ft-font.c | 654 ++++++++++++++------
src/cairo-types-private.h | 1 +
src/cairo-xcb-surface.c | 3 +
src/cairo-xlib-screen.c | 37 ++
src/cairo.h | 26 +
src/libcairo.map | 124 ++++
13 files changed, 928 insertions(+), 190 deletions(-)
diff --git a/.gear-rules b/.gear-rules
new file mode 100644
index 0000000..6c98f0d
--- /dev/null
+++ b/.gear-rules
@@ -0,0 +1,2 @@
+tar: @version@:. name=cairo-@version@
+diff: @version@:. . name=cairo-@version@-@release@.patch
diff --git a/.gear-tags/ec2afbd4c0fdecc14d2f65200f87dab227a14317 b/.gear-tags/ec2afbd4c0fdecc14d2f65200f87dab227a14317
new file mode 100644
index 0000000..44c44ac
--- /dev/null
+++ b/.gear-tags/ec2afbd4c0fdecc14d2f65200f87dab227a14317
@@ -0,0 +1,13 @@
+object 66e8f142e381501d114888c2d1fc1e7f6d6a9857
+type commit
+tag 1.8.4
+tagger Carl Worth <cworth@cworth.org> 1226662940 +0100
+
+cairo 1.8.4 release
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.9 (GNU/Linux)
+
+iD8DBQBJHWQc6JDdNq8qSWgRAlGqAKCnQ/6swQ0CfHT0LDLwVzWFJ8eNkQCfcJBM
+thdVvMB0sYMn6oidC57fdhA=
+=OwtT
+-----END PGP SIGNATURE-----
diff --git a/.gear-tags/list b/.gear-tags/list
new file mode 100644
index 0000000..07f5a25
--- /dev/null
+++ b/.gear-tags/list
@@ -0,0 +1 @@
+ec2afbd4c0fdecc14d2f65200f87dab227a14317 1.8.4
diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index d3b7319..e474892 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -326,6 +326,9 @@ cairo_font_options_get_antialias
cairo_subpixel_order_t
cairo_font_options_set_subpixel_order
cairo_font_options_get_subpixel_order
+cairo_lcd_filter_t
+cairo_font_options_set_lcd_filter
+cairo_font_options_get_lcd_filter
cairo_hint_style_t
cairo_font_options_set_hint_style
cairo_font_options_get_hint_style
diff --git a/libcairo.spec b/libcairo.spec
new file mode 100644
index 0000000..aa5a590
--- /dev/null
+++ b/libcairo.spec
@@ -0,0 +1,206 @@
+Name: libcairo
+Version: 1.8.4
+Release: alt2
+Epoch: 1
+
+Summary: Multi-platform 2D graphics library
+License: LGPL
+Group: System/Libraries
+URL: http://cairographics.org/
+
+Packager: Valery Inozemtsev <shrek@altlinux.ru>
+
+PreReq: fontconfig >= 2.5.92
+Provides: cairo = %version-%release
+Obsoletes: cairo <= %version
+
+Source: cairo-%version.tar
+Patch: cairo-%version-%release.patch
+
+BuildRequires: fontconfig-devel >= 2.5.92 gtk-doc libXrender-devel libfreetype-devel
+BuildRequires: libglitz-devel libpixman-devel libpng-devel libxcbutil-devel
+%{?!__buildreqs:%{?!_without_check:%{?!_disable_check:BuildRequires: libpoppler-glib-devel librsvg-devel ghostscript-classic xvfb-run}}}
+
+%description
+Cairo is a vector graphics library with cross-device output support.
+
+%package devel
+Summary: Headers for developing programs that will use cairo
+Group: Development/C
+Requires: %name = %version-%release
+Provides: cairo-devel = %version-%release
+Obsoletes: cairo-devel <= %version
+
+%description devel
+Cairo is a vector graphics library with cross-device output support.
+This package contains the headers that programmers will need to develop
+applications which will use cairo library.
+
+%prep
+%setup -q -n cairo-%version
+%patch -p1
+
+%build
+> boilerplate/Makefile.am.features
+> src/Makefile.am.features
+touch ChangeLog
+%autoreconf
+%configure \
+ --enable-xlib \
+ --enable-xcb \
+ --enable-glitz \
+ --enable-ps \
+ --enable-pdf \
+ --enable-svg \
+ --enable-gtk-doc \
+ --disable-static
+%make_build
+%make -C doc/public doc
+%{?!__buildreqs:%{?!_without_check:%{?!_disable_check:xvfb-run -s "-kb -screen 0 1280x1024x24" -e %_builddir/cairo-%version/xvfb.log -a make -k test}}}
+
+%install
+%make DESTDIR=%buildroot install
+
+%files
+%doc AUTHORS NEWS README
+%_libdir/*.so.*
+
+%files devel
+%_includedir/*
+%_libdir/*.so
+%_pkgconfigdir/*.pc
+%doc %_datadir/gtk-doc/html/cairo/
+
+%changelog
+* Sun Nov 23 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.4-alt2
+- cairo-xcb: avoid leaking memory
+
+* Fri Nov 14 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.4-alt1
+- 1.8.4
+
+* Thu Nov 06 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.2-alt4
+- disabled directfb backend
+
+* Thu Nov 06 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.2-alt3
+- applied http://aur.archlinux.org/packages/cairo-lcd/cairo-lcd/lcd-filter.patch (close #17796)
+
+* Fri Oct 31 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.2-alt2
+- [scaled-font] fix typo that prevented meta_surface lookup
+
+* Thu Oct 30 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.2-alt1
+- 1.8.2
+
+* Fri Sep 26 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.8.0-alt1
+- 1.8.0
+
+* Thu Aug 28 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.7.4-alt3
+- enabled xcb backend
+
+* Sat Aug 16 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.7.4-alt2
+- applied post-1.7.4 upstream changes
+
+* Wed Aug 13 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.7.4-alt1
+- 1.7.4
+
+* Mon May 05 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.6.4-alt3
+- update lcd filtering patch from ubuntu
+
+* Thu Apr 17 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.6.4-alt2
+- rename ABI interface LIBCAIRO_1.6 to CAIRO_1.6
+
+* Wed Apr 16 2008 Valery Inozemtsev <shrek@altlinux.ru> 1:1.6.4-alt1
+- 1.6.4
+- Applied LCD subpixel filtering patch (close #14361)
+
+* Mon Jan 21 2008 Alexey Tourbin <at@altlinux.ru> 1:1.4.14-alt1
+- 1.4.12-9-g1ea07fd -> 1.4.14
+
+* Thu Dec 27 2007 Alexey Tourbin <at@altlinux.ru> 1:1.4.12-alt1
+- 1.4.10 -> 1.4.12-9-g1ea07fd (fixes CVE-2007-5503)
+- build with libglitz (requested by Alexey Gladkov)
+
+* Sun Jul 22 2007 Alexey Tourbin <at@altlinux.ru> 1:1.4.10-alt1
+- rebased from 1.2 to 1.4 branch
+- changed src.rpm packaging to keep upstream tarball
+
+* Tue Nov 14 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.6-alt1
+- 1.2.4-ga5f068e -> 1.2.6 release
+
+* Sat Sep 30 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.5-alt0.1
+- this is the first build from git repository, which I cloned from
+ git://git.cairographics.org/git/cairo; I started off with 1.2.4 release
+ and applied all my changes to the source tree (this is master branch);
+ then I merged in the changes from current 1.2 brnach (1.2.4-ga5f068e)
+ and changed rpm package version according to the changes
+- enabled test suite
+- added CAIRO_DIRECTFB ABI for cairo_directfb_surface_create()
+
+* Thu Sep 07 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.4-alt2
+- enabled directfb backend
+
+* Mon Aug 21 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.4-alt1
+- 1.2.2 -> 1.2.4
+- no longer provides/obsoletes libpixman
+
+* Thu Aug 10 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.2-alt1
+- 1.2.0 -> 1.2.2
+- renamed CAIRO_1.2.0 ABI to CAIRO_1.2
+
+* Wed Aug 02 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.0-alt3
+- upstream fix for size-zero glyphs (#9830)
+
+* Mon Jul 10 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.0-alt2
+- fixed set_dpi.patch
+
+* Sun Jul 02 2006 Alexey Tourbin <at@altlinux.ru> 1:1.2.0-alt1
+- 1.0.4 -> 1.2.0
+- restored cairo_ps_surface_set_dpi() and cairo_pdf_surface_set_dpi()
+ as aliases to cairo_surface_set_fallback_resolution() to preserve
+ binary compatibility with libcairomm etc.
+- introduced CAIRO_1.2.0 ABI
+- packaged gtk-doc files
+
+* Mon Apr 24 2006 Alexey Tourbin <at@altlinux.ru> 1:1.0.4-alt2
+- urgency=high (for 1:1.0.4-alt1): use --enable-pdf and --enable-ps
+ again to preserve ABI; also provide cairo_glitz_surface_create() stub
+- restricted the list of symbols exported by the library
+
+* Mon Apr 17 2006 Valery Inozemtsev <shrek@altlinux.ru> 1:1.0.4-alt1
+- 1.0.4
+
+* Mon Feb 20 2006 Valery Inozemtsev <shrek@altlinux.ru> 1.1.1-alt0.1
+- CVS snapshot 20060213
+
+* Thu Feb 02 2006 ALT QA Team Robot <qa-robot@altlinux.org> 1.0.2-alt3.1
+- Rebuilt for new pkg-config dependencies.
+
+* Thu Jan 19 2006 Dmitry V. Levin <ldv@altlinux.org> 1.0.2-alt3
+- Backported upstream fix for text relocations.
+
+* Tue Jan 10 2006 Valery Inozemtsev <shrek@altlinux.ru> 1.0.2-alt2
+- added verify_elf_method textrel=relaxed
+
+* Tue Oct 04 2005 Valery Inozemtsev <shrek@altlinux.ru> 1.0.2-alt1
+- 1.0.2
+
+* Fri Aug 26 2005 Valery Inozemtsev <shrek@altlinux.ru> 1.0.0-alt1
+- 1.0.0
+
+* Wed Aug 10 2005 Valery Inozemtsev <shrek@altlinux.ru> 0.9.0-alt1
+- 0.9.0
+
+* Sat Jul 23 2005 Valery Inozemtsev <shrek@altlinux.ru> 0.5.2-alt1
+- 0.5.2
+
+* Fri May 13 2005 Kachalov Anton <mouse@altlinux.ru> 0.4.0-alt1
+- 0.4.0
+
+* Sat Feb 26 2005 Valery Inozemtsev <shrek@altlinux.ru> 0.3.0-alt1
+- 0.3.0
+
+* Wed Aug 25 2004 Kachalov Anton <mouse@altlinux.ru> 0.1.23-alt2
+- added missed requires to libglitz-devel
+
+* Thu Jul 08 2004 Kachalov Anton <mouse@altlinux.ru> 0.1.23-alt1
+- first build for Sisyphus
+
diff --git a/src/Makefile.am b/src/Makefile.am
index bf87efb..2be2916 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,7 @@ libcairo_la_SOURCES = \
$(enabled_cairo_private) \
$(enabled_cairo_sources) \
$(NULL)
+export_symbols = -Wl,--version-script=libcairo.map
libcairo_la_LDFLAGS = -version-info $(CAIRO_LIBTOOL_VERSION_INFO) -no-undefined $(export_symbols)
libcairo_la_LIBADD = $(CAIRO_LIBS)
libcairo_la_DEPENDENCIES = $(cairo_def_dependency)
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index dedd337..9e47a9c 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,44 @@ 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.
+ **/
+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
+ **/
+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 cd11253..7606ce5 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -57,6 +57,8 @@
#include FT_SYNTHESIS_H
#endif
+#include FT_LCD_FILTER_H
+
#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))
@@ -737,23 +739,286 @@ _cairo_ft_unscaled_font_set_scale (cairo_ft_unscaled_font_t *unscaled,
return CAIRO_STATUS_SUCCESS;
}
-/* Empirically-derived subpixel filtering values thanks to Keith
- * Packard and libXft. */
-static const int filters[3][3] = {
- /* red */
-#if 0
- { 65538*4/7,65538*2/7,65538*1/7 },
- /* green */
- { 65536*1/4, 65536*2/4, 65537*1/4 },
- /* blue */
- { 65538*1/7,65538*2/7,65538*4/7 },
+/* 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;
+#if 1
+ pix = ((unsigned int)src[0] << 16) |
+ ((unsigned int)src[src_pitch] << 8) |
+ ((unsigned int)src[src_pitch*2] ) |
+ 0xFF000000 ;
+#else
+ pix = ((unsigned int)src[0] << 16) |
+ ((unsigned int)src[src_pitch] << 8) |
+ ((unsigned int)src[src_pitch*2] ) |
+ ((unsigned int)src[src_pitch] << 24) ;
#endif
- { 65538*9/13,65538*3/13,65538*1/13 },
- /* green */
- { 65538*1/6, 65538*4/6, 65538*1/6 },
- /* blue */
- { 65538*1/13,65538*3/13,65538*9/13 },
-};
+ 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;
+ }
+ }
+ }
+ }
+}
+
/* Fills in val->image with an image surface created from @bitmap
*/
@@ -766,7 +1031,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
int width, height, stride;
unsigned char *data;
int format = CAIRO_FORMAT_A8;
- cairo_bool_t subpixel = FALSE;
+ cairo_image_surface_t *image;
width = bitmap->width;
height = bitmap->rows;
@@ -823,11 +1088,7 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
case FT_PIXEL_MODE_GRAY:
- switch (font_options->antialias) {
- case CAIRO_ANTIALIAS_DEFAULT:
- case CAIRO_ANTIALIAS_GRAY:
- case CAIRO_ANTIALIAS_NONE:
- default:
+ if (font_options->antialias != CAIRO_ANTIALIAS_SUBPIXEL) {
stride = bitmap->pitch;
if (own_buffer) {
data = bitmap->buffer;
@@ -839,104 +1100,16 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
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;
-
- 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;
+ } else {
+ // 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);
+
+ data = bitmap->buffer;
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);
- }
-
- 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)
- {
- 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;
- }
- }
-
- /* 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;
- }
}
break;
case FT_PIXEL_MODE_GRAY2:
@@ -948,19 +1121,20 @@ _get_bitmap_surface (FT_Bitmap *bitmap,
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
- *surface = (cairo_image_surface_t *)
+ /* XXX */
+ *surface = image = (cairo_image_surface_t *)
cairo_image_surface_create_for_data (data,
format,
width, height, stride);
- if ((*surface)->base.status) {
+ if (image->base.status) {
free (data);
return (*surface)->base.status;
}
- if (subpixel)
- pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
+ if (font_options->antialias == CAIRO_ANTIALIAS_SUBPIXEL)
+ pixman_image_set_component_alpha (image->pixman_image, TRUE);
- _cairo_image_surface_assume_ownership_of_data ((*surface));
+ _cairo_image_surface_assume_ownership_of_data (image);
return CAIRO_STATUS_SUCCESS;
}
@@ -985,16 +1159,59 @@ _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;
cairo_status_t status;
+ FT_Error fterror;
+ FT_Library library = glyphslot->library;
+ FT_Render_Mode render_mode = FT_RENDER_MODE_NORMAL;
+
+ switch (font_options->antialias) {
+ case CAIRO_ANTIALIAS_NONE:
+ render_mode = FT_RENDER_MODE_MONO;
+ break;
+
+ case CAIRO_ANTIALIAS_SUBPIXEL:
+ 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;
+ }
+
+ 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;
+ }
+
+ break;
+
+ case CAIRO_ANTIALIAS_DEFAULT:
+ case CAIRO_ANTIALIAS_GRAY:
+ render_mode = FT_RENDER_MODE_NORMAL;
+ }
FT_Outline_Get_CBox (outline, &cbox);
@@ -1005,20 +1222,22 @@ _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;
+ stride = (width + 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;
@@ -1030,74 +1249,69 @@ _render_glyph_outline (FT_Face face,
return (*surface)->base.status;
} else {
- matrix.xx = matrix.yy = 0x10000L;
- matrix.xy = matrix.yx = 0;
+ 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;
+ 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 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;
- subpixel = TRUE;
- break;
- case CAIRO_SUBPIXEL_ORDER_VRGB:
- case CAIRO_SUBPIXEL_ORDER_VBGR:
- matrix.yy *= 3;
- vmul = 3;
- subpixel = TRUE;
- 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;
}
- FT_Outline_Transform (outline, &matrix);
-
- bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
- bitmap.num_grays = 256;
- stride = (width * hmul + 3) & -4;
+ break;
+ case FT_RENDER_MODE_MONO:
+ case FT_RENDER_MODE_LIGHT:
+ case FT_RENDER_MODE_NORMAL:
+ case FT_RENDER_MODE_MAX:
+ default:
+ break;
}
- bitmap.pitch = stride;
- bitmap.width = width * hmul;
- bitmap.rows = height * vmul;
- bitmap.buffer = calloc (stride, bitmap.rows);
- if (bitmap.buffer == NULL)
+ FT_Library_SetLcdFilter (library, lcd_filter);
+
+ fterror = FT_Render_Glyph (face->glyph, render_mode);
+
+ FT_Library_SetLcdFilter (library, FT_LCD_FILTER_NONE);
+
+ if (fterror != 0)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- FT_Outline_Translate (outline, -cbox.xMin*hmul, -cbox.yMin*vmul);
+ bitmap_size = _compute_xrender_bitmap_size (&bitmap,
+ face->glyph,
+ render_mode);
+ if (bitmap_size < 0)
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- if (FT_Outline_Get_Bitmap (glyphslot->library, outline, &bitmap) != 0) {
- free (bitmap.buffer);
+ 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));
+
+ // NOTE: _get_bitmap_surface will free bitmap.buffer if there is an error
status = _get_bitmap_surface (&bitmap, TRUE, font_options, surface);
if (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,
+ (double)-glyphslot->bitmap_left,
+ (double)+glyphslot->bitmap_top);
+ }
+
return CAIRO_STATUS_SUCCESS;
}
@@ -1283,6 +1497,15 @@ typedef struct _cairo_ft_scaled_font {
const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend;
+/* Fontconfig version older than 2.6 didn't have these options */
+#ifndef FC_LCD_FILTER
+#define FC_LCD_FILTER "lcdfilter"
+#define FC_LCD_NONE 0
+#define FC_LCD_DEFAULT 1
+#define FC_LCD_LIGHT 2
+#define FC_LCD_LEGACY 3
+#endif
+
/* The load flags passed to FT_Load_Glyph control aspects like hinting and
* antialiasing. Here we compute them from the fields of a FcPattern.
*/
@@ -1316,6 +1539,7 @@ _get_pattern_ft_options (FcPattern *pattern, cairo_ft_options_t *ret)
if (antialias) {
cairo_subpixel_order_t subpixel_order;
+ int lcd_filter;
/* disable hinting if requested */
if (FcPatternGetBool (pattern,
@@ -1351,6 +1575,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)
@@ -1451,6 +1694,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;
@@ -1474,11 +1723,11 @@ _cairo_ft_options_merge (cairo_ft_options_t *options,
case CAIRO_SUBPIXEL_ORDER_DEFAULT:
case CAIRO_SUBPIXEL_ORDER_RGB:
case CAIRO_SUBPIXEL_ORDER_BGR:
- load_target |= FT_LOAD_TARGET_LCD;
+ load_target = FT_LOAD_TARGET_LCD;
break;
case CAIRO_SUBPIXEL_ORDER_VRGB:
case CAIRO_SUBPIXEL_ORDER_VBGR:
- load_target |= FT_LOAD_TARGET_LCD_V;
+ load_target = FT_LOAD_TARGET_LCD_V;
break;
}
}
@@ -2423,6 +2672,33 @@ _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;
+ 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-types-private.h b/src/cairo-types-private.h
index 12e1a20..d994d51 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -116,6 +116,7 @@ struct _cairo_array {
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-xcb-surface.c b/src/cairo-xcb-surface.c
index dede00f..9b7eb4b 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -2416,6 +2416,9 @@ _cairo_xcb_surface_emit_glyphs (cairo_xcb_surface_t *dst,
}
}
+ /* We wouldn't want to leak memory, would we? */
+ free(output_glyphs);
+
return CAIRO_STATUS_SUCCESS;
}
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index f670b8a..4234fdb 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -143,6 +143,15 @@ get_integer_default (Display *dpy,
#define FC_LCD_LEGACY 3
#endif
+/* Fontconfig version older than 2.6 didn't have these options */
+#ifndef FC_LCD_FILTER
+#define FC_LCD_FILTER "lcdfilter"
+#define FC_LCD_NONE 0
+#define FC_LCD_DEFAULT 1
+#define FC_LCD_LIGHT 2
+#define FC_LCD_LEGACY 3
+#endif
+
static void
_cairo_xlib_init_screen_font_options (Display *dpy, cairo_xlib_screen_info_t *info)
{
@@ -150,12 +159,21 @@ _cairo_xlib_init_screen_font_options (Display *dpy, cairo_xlib_screen_info_t *in
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 +257,24 @@ _cairo_xlib_init_screen_font_options (Display *dpy, cairo_xlib_screen_info_t *in
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 +287,7 @@ _cairo_xlib_init_screen_font_options (Display *dpy, cairo_xlib_screen_info_t *in
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/cairo.h b/src/cairo.h
index cf4bc05..73b923c 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -1046,6 +1046,26 @@ typedef enum _cairo_subpixel_order {
} cairo_subpixel_order_t;
/**
+ * 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.
+ **/
+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;
+
+/**
* cairo_hint_style_t:
* @CAIRO_HINT_STYLE_DEFAULT: Use the default hint style for
* font backend and target device
@@ -1151,6 +1171,12 @@ cairo_public cairo_subpixel_order_t
cairo_font_options_get_subpixel_order (const cairo_font_options_t *options);
cairo_public void
+cairo_font_options_set_lcd_filter (cairo_font_options_t *options,
+ cairo_lcd_filter_t lcd_filter);
+cairo_public cairo_lcd_filter_t
+cairo_font_options_get_lcd_filter (const cairo_font_options_t *options);
+
+cairo_public void
cairo_font_options_set_hint_style (cairo_font_options_t *options,
cairo_hint_style_t hint_style);
cairo_public cairo_hint_style_t
diff --git a/src/libcairo.map b/src/libcairo.map
new file mode 100644
index 0000000..2c839c1
--- /dev/null
+++ b/src/libcairo.map
@@ -0,0 +1,124 @@
+CAIRO_1.2 {
+ global:
+ cairo_font_face_get_type;
+ cairo_get_group_target;
+ cairo_image_surface_get_data;
+ cairo_image_surface_get_format;
+ cairo_image_surface_get_stride;
+ cairo_new_sub_path;
+ cairo_pattern_get_type;
+ cairo_pdf_surface_set_size;
+ cairo_pop_group;
+ cairo_pop_group_to_source;
+ cairo_ps_surface_dsc_begin_page_setup;
+ cairo_ps_surface_dsc_begin_setup;
+ cairo_ps_surface_dsc_comment;
+ cairo_ps_surface_set_size;
+ cairo_push_group;
+ cairo_push_group_with_content;
+ cairo_scaled_font_get_ctm;
+ cairo_scaled_font_get_font_face;
+ cairo_scaled_font_get_font_matrix;
+ cairo_scaled_font_get_font_options;
+ cairo_scaled_font_get_type;
+ cairo_scaled_font_text_extents;
+ cairo_set_scaled_font;
+ cairo_surface_get_content;
+ cairo_surface_get_device_offset;
+ cairo_surface_get_type;
+ cairo_surface_set_fallback_resolution;
+ cairo_svg_get_versions;
+ cairo_svg_surface_create;
+ cairo_svg_surface_create_for_stream;
+ cairo_svg_surface_restrict_to_version;
+ cairo_svg_version_to_string;
+ cairo_xlib_surface_get_depth;
+ cairo_xlib_surface_get_display;
+ cairo_xlib_surface_get_drawable;
+ cairo_xlib_surface_get_height;
+ cairo_xlib_surface_get_screen;
+ cairo_xlib_surface_get_visual;
+ cairo_xlib_surface_get_width;
+ local:
+ [^c]*;
+};
+
+CAIRO_1.4 {
+ global:
+ cairo_clip_extents;
+ cairo_copy_clip_rectangle_list;
+ cairo_font_face_get_reference_count;
+ cairo_get_dash;
+ cairo_get_dash_count;
+ cairo_get_reference_count;
+ cairo_get_scaled_font;
+ cairo_get_user_data;
+ cairo_pattern_get_color_stop_count;
+ cairo_pattern_get_color_stop_rgba;
+ cairo_pattern_get_linear_points;
+ cairo_pattern_get_radial_circles;
+ cairo_pattern_get_reference_count;
+ cairo_pattern_get_rgba;
+ cairo_pattern_get_surface;
+ cairo_pattern_get_user_data;
+ cairo_pattern_set_user_data;
+ cairo_rectangle_list_destroy;
+ cairo_scaled_font_get_reference_count;
+ cairo_scaled_font_get_user_data;
+ cairo_scaled_font_set_user_data;
+ cairo_set_user_data;
+ cairo_surface_get_reference_count;
+} CAIRO_1.2;
+
+CAIRO_1.6 {
+ global:
+ cairo_format_stride_for_width;
+ cairo_has_current_point;
+ cairo_path_extents;
+ cairo_ps_get_levels;
+ cairo_ps_level_to_string;
+ cairo_ps_surface_get_eps;
+ cairo_ps_surface_restrict_to_level;
+ cairo_ps_surface_set_eps;
+ cairo_surface_copy_page;
+ cairo_surface_show_page;
+ cairo_xlib_surface_get_xrender_format;
+} CAIRO_1.4;
+
+CAIRO_1.7 {
+ global:
+ cairo_font_options_get_lcd_filter;
+ cairo_font_options_set_lcd_filter;
+ cairo_glyph_allocate;
+ cairo_glyph_free;
+ cairo_has_show_text_glyphs;
+ cairo_scaled_font_get_scale_matrix;
+ cairo_scaled_font_text_to_glyphs;
+ cairo_show_text_glyphs;
+ cairo_surface_get_fallback_resolution;
+ cairo_text_cluster_allocate;
+ cairo_text_cluster_free;
+ cairo_toy_font_face_create;
+ cairo_toy_font_face_get_family;
+ cairo_toy_font_face_get_slant;
+ cairo_toy_font_face_get_weight;
+ cairo_user_font_face_create;
+ cairo_user_font_face_get_init_func;
+ cairo_user_font_face_get_render_glyph_func;
+ cairo_user_font_face_get_text_to_glyphs_func;
+ cairo_user_font_face_get_unicode_to_glyph_func;
+ cairo_user_font_face_set_init_func;
+ cairo_user_font_face_set_render_glyph_func;
+ cairo_user_font_face_set_text_to_glyphs_func;
+ cairo_user_font_face_set_unicode_to_glyph_func;
+} CAIRO_1.6;
+
+CAIRO_1.8 {
+ global:
+ cairo_surface_has_show_text_glyphs;
+} CAIRO_1.7;
+
+CAIRO_DIRECTFB {
+ global:
+ cairo_directfb_surface_create;
+};