[cairo-commit] boilerplate/Makefile.win32.features build/configure.ac.features build/Makefile.win32.features build/Makefile.win32.features-h configure.ac doc/public src/cairo-ft-font.c src/cairo-ft.h src/cairo-os2-surface.c src/cairo-path-fixed.c src/cairo-scaled-font.c src/cairo-xlib-display.c src/cairo-xlib-screen.c src/Makefile.win32.features
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Mar 16 21:58:49 PDT 2009
boilerplate/Makefile.win32.features | 10 ++++++++
build/Makefile.win32.features | 1
build/Makefile.win32.features-h | 3 ++
build/configure.ac.features | 1
configure.ac | 26 ++++++++++++++-------
doc/public/cairo-sections.txt | 1
doc/public/tmpl/cairo-ft.sgml | 9 +++++++
doc/public/tmpl/cairo-status.sgml | 2 -
src/Makefile.win32.features | 14 +++++++++++
src/cairo-ft-font.c | 43 ++++++++++++++++++++++++++++++------
src/cairo-ft.h | 23 ++++++++++++-------
src/cairo-os2-surface.c | 6 +++--
src/cairo-path-fixed.c | 2 -
src/cairo-scaled-font.c | 4 +--
src/cairo-xlib-display.c | 2 -
src/cairo-xlib-screen.c | 23 ++++++++-----------
16 files changed, 125 insertions(+), 45 deletions(-)
New commits:
commit 3ec94f9b5917b8f71304c982bd153e5a810f3b12
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 17 00:53:30 2009 -0400
Support compiling without fontconfig
Adds a new, fake, fontconfig font backend. Fontconfig can be disabled
using --disable-fc, in which case the toy text API wont find fonts and
the internal font will always be used.
Also defines the feature macro CAIRO_HAS_FC_FONT. The two fontconfig-specific
functions in cairo-ft.h depend on that macro now.
diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index f5ee452..d6d5065 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -169,6 +169,16 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_ft_private)
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_ft_sources)
endif
+supported_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers)
+all_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers)
+all_cairo_boilerplate_private += $(cairo_boilerplate_fc_private)
+all_cairo_boilerplate_sources += $(cairo_boilerplate_fc_sources)
+ifeq ($(CAIRO_HAS_FC_FONT),1)
+enabled_cairo_boilerplate_headers += $(cairo_boilerplate_fc_headers)
+enabled_cairo_boilerplate_private += $(cairo_boilerplate_fc_private)
+enabled_cairo_boilerplate_sources += $(cairo_boilerplate_fc_sources)
+endif
+
supported_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
all_cairo_boilerplate_headers += $(cairo_boilerplate_ps_headers)
all_cairo_boilerplate_private += $(cairo_boilerplate_ps_private)
diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features
index f90a6ee..764639c 100644
--- a/build/Makefile.win32.features
+++ b/build/Makefile.win32.features
@@ -15,6 +15,7 @@ CAIRO_HAS_GLITZ_SURFACE=0
CAIRO_HAS_DIRECTFB_SURFACE=0
CAIRO_HAS_SCRIPT_SURFACE=0
CAIRO_HAS_FT_FONT=0
+CAIRO_HAS_FC_FONT=0
CAIRO_HAS_PS_SURFACE=1
CAIRO_HAS_PDF_SURFACE=1
CAIRO_HAS_SVG_SURFACE=1
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index a468e30..dcefdbc 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -50,6 +50,9 @@ endif
ifeq ($(CAIRO_HAS_FT_FONT),1)
@echo "#define CAIRO_HAS_FT_FONT 1" >> src/cairo-features.h
endif
+ifeq ($(CAIRO_HAS_FC_FONT),1)
+ @echo "#define CAIRO_HAS_FC_FONT 1" >> src/cairo-features.h
+endif
ifeq ($(CAIRO_HAS_PS_SURFACE),1)
@echo "#define CAIRO_HAS_PS_SURFACE 1" >> src/cairo-features.h
endif
diff --git a/build/configure.ac.features b/build/configure.ac.features
index 26dbfb1..2d5fb8a 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -379,6 +379,7 @@ AC_DEFUN([CAIRO_REPORT],
echo "The following font backends:"
echo " User: yes (always builtin)"
echo " FreeType: $use_ft"
+ echo " Fontconfig: $use_fc"
echo " Win32: $use_win32_font"
echo " Quartz: $use_quartz_font"
echo ""
diff --git a/configure.ac b/configure.ac
index 48b61b2..d0b6926 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,13 +259,6 @@ FREETYPE_MIN_RELEASE=2.1.9
FREETYPE_MIN_VERSION=9.7.3
CAIRO_ENABLE_FONT_BACKEND(ft, FreeType, auto, [
- ft_REQUIRES="fontconfig"
- PKG_CHECK_MODULES(FONTCONFIG, $ft_REQUIRES,,
- [AC_MSG_RESULT(no); use_ft="no (requires $ft_REQUIRES)"])
-
- if test "x$use_ft" = "xyes"; then
-
- CAIRO_CHECK_FUNCS_WITH_FLAGS(FcFini, [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS])
PKG_CHECK_MODULES(FREETYPE, freetype2 >= $FREETYPE_MIN_VERSION,
[freetype_pkgconfig=yes],
@@ -293,9 +286,20 @@ CAIRO_ENABLE_FONT_BACKEND(ft, FreeType, auto, [
use_ft="no ($FREETYPE_VERSION found; version $FREETYPE_MIN_VERSION from release $FREETYPE_MIN_RELEASE required)"])
fi
fi
+
+ ft_CFLAGS="$FREETYPE_CFLAGS"
+ ft_LIBS="$FREETYPE_LIBS"
+])
+
+CAIRO_ENABLE_FONT_BACKEND(fc, Fontconfig, auto, [
+ use_fc=$use_ft
+ if test "x$use_fc" = "xyes"; then
+ fc_REQUIRES="fontconfig"
+ PKG_CHECK_MODULES(FONTCONFIG, $fc_REQUIRES,,
+ [AC_MSG_RESULT(no); use_fc="no (requires $fc_REQUIRES)"])
fi
- ft_CFLAGS="$FREETYPE_CFLAGS $FONTCONFIG_CFLAGS"
- ft_LIBS="$FREETYPE_LIBS $FONTCONFIG_LIBS"
+ fc_CFLAGS="$FONTCONFIG_CFLAGS"
+ fc_LIBS="$FONTCONFIG_LIBS"
])
if test "x$use_ft" = "xyes"; then
@@ -317,6 +321,10 @@ if test "x$use_ft" = "xyes"; then
CFLAGS="$_save_cflags"
fi
+if test "x$use_fc" = "xyes"; then
+ CAIRO_CHECK_FUNCS_WITH_FLAGS(FcFini, [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS])
+fi
+
dnl ===========================================================================
AC_ARG_ENABLE(pthread,
diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index bb64cd6..ff89db7 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -2,6 +2,7 @@
<FILE>cairo-ft</FILE>
<TITLE>ft-font</TITLE>
CAIRO_HAS_FT_FONT
+CAIRO_HAS_FC_FONT
cairo_ft_font_face_create_for_ft_face
cairo_ft_font_face_create_for_pattern
cairo_ft_font_options_substitute
diff --git a/doc/public/tmpl/cairo-ft.sgml b/doc/public/tmpl/cairo-ft.sgml
index 68a3fd4..307d632 100644
--- a/doc/public/tmpl/cairo-ft.sgml
+++ b/doc/public/tmpl/cairo-ft.sgml
@@ -28,6 +28,15 @@ This macro can be used to conditionally compile backend-specific code.
+<!-- ##### MACRO CAIRO_HAS_FC_FONT ##### -->
+<para>
+Defined if the Fontconfig-specific functions of the FreeType font backend
+are available.
+This macro can be used to conditionally compile backend-specific code.
+</para>
+
+
+
<!-- ##### FUNCTION cairo_ft_font_face_create_for_ft_face ##### -->
<para>
diff --git a/doc/public/tmpl/cairo-status.sgml b/doc/public/tmpl/cairo-status.sgml
index 16b67d2..d2636c6 100644
--- a/doc/public/tmpl/cairo-status.sgml
+++ b/doc/public/tmpl/cairo-status.sgml
@@ -70,7 +70,7 @@ code is required before or after each individual cairo function call.
@CAIRO_STATUS_INVALID_CLUSTERS:
@CAIRO_STATUS_INVALID_SLANT:
@CAIRO_STATUS_INVALID_WEIGHT:
- at CAIRO_STATUS_INVALID_SIZE:
+ at CAIRO_STATUS_INVALID_SIZE:
<!-- ##### FUNCTION cairo_status_to_string ##### -->
<para>
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index 94815d3..bed181f 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -231,6 +231,20 @@ ifeq ($(CAIRO_HAS_FT_FONT),1)
enabled_cairo_pkgconf += cairo-ft.pc
endif
+supported_cairo_headers += $(cairo_fc_headers)
+all_cairo_headers += $(cairo_fc_headers)
+all_cairo_private += $(cairo_fc_private)
+all_cairo_sources += $(cairo_fc_sources)
+ifeq ($(CAIRO_HAS_FC_FONT),1)
+enabled_cairo_headers += $(cairo_fc_headers)
+enabled_cairo_private += $(cairo_fc_private)
+enabled_cairo_sources += $(cairo_fc_sources)
+endif
+all_cairo_pkgconf += cairo-fc.pc
+ifeq ($(CAIRO_HAS_FC_FONT),1)
+enabled_cairo_pkgconf += cairo-fc.pc
+endif
+
supported_cairo_headers += $(cairo_ps_headers)
all_cairo_headers += $(cairo_ps_headers)
all_cairo_private += $(cairo_ps_private)
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index ec6041a..3cfe344 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -45,8 +45,10 @@
#include <float.h>
+#if CAIRO_HAS_FC_FONT
#include <fontconfig/fontconfig.h>
#include <fontconfig/fcfreetype.h>
+#endif
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -117,10 +119,6 @@ _cairo_ft_unscaled_font_keys_equal (const void *key_a,
static void
_cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled);
-static cairo_status_t
-_cairo_ft_font_options_substitute (const cairo_font_options_t *options,
- FcPattern *pattern);
-
typedef enum _cairo_ft_extra_flags {
CAIRO_FT_OPTIONS_HINT_METRICS = (1 << 0),
CAIRO_FT_OPTIONS_EMBOLDEN = (1 << 1)
@@ -139,11 +137,18 @@ struct _cairo_ft_font_face {
cairo_ft_options_t ft_options;
cairo_ft_font_face_t *next;
+#if CAIRO_HAS_FC_FONT
FcPattern *pattern; /* if pattern is set, the above fields will be NULL */
+#endif
};
static const cairo_unscaled_font_backend_t cairo_ft_unscaled_font_backend;
+#if CAIRO_HAS_FC_FONT
+static cairo_status_t
+_cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+ FcPattern *pattern);
+
static cairo_status_t
_cairo_ft_resolve_pattern (FcPattern *pattern,
const cairo_matrix_t *font_matrix,
@@ -152,6 +157,7 @@ _cairo_ft_resolve_pattern (FcPattern *pattern,
cairo_ft_unscaled_font_t **unscaled,
cairo_ft_options_t *ft_options);
+#endif
/*
* We maintain a hash table to map file/id => #cairo_ft_unscaled_font_t.
@@ -465,6 +471,7 @@ UNWIND:
}
+#if CAIRO_HAS_FC_FONT
static cairo_ft_unscaled_font_t *
_cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern)
{
@@ -486,6 +493,7 @@ _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern)
DONE:
return _cairo_ft_unscaled_font_create_internal (font_face != NULL, filename, id, font_face);
}
+#endif
static cairo_ft_unscaled_font_t *
_cairo_ft_unscaled_font_create_from_face (FT_Face face)
@@ -1291,6 +1299,7 @@ typedef struct _cairo_ft_scaled_font {
static const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend;
+#if CAIRO_HAS_FC_FONT
/* The load flags passed to FT_Load_Glyph control aspects like hinting and
* antialiasing. Here we compute them from the fields of a FcPattern.
*/
@@ -1426,6 +1435,7 @@ _get_pattern_ft_options (FcPattern *pattern, cairo_ft_options_t *ret)
*ret = ft_options;
}
+#endif
static void
_cairo_ft_options_merge (cairo_ft_options_t *options,
@@ -2044,9 +2054,11 @@ _cairo_ft_ucs4_to_index (void *abstract_font,
if (!face)
return 0;
- /* If making this compile without fontconfig, use:
- * index = FT_Get_Char_Index (face, ucs4); */
+#if CAIRO_HAS_FC_FONT
index = FcFreeTypeCharIndex (face, ucs4);
+#else
+ index = FT_Get_Char_Index (face, ucs4);
+#endif
_cairo_ft_unscaled_font_unlock_face (unscaled);
return index;
@@ -2125,6 +2137,7 @@ static const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend = {
/* #cairo_ft_font_face_t */
+#if CAIRO_HAS_FC_FONT
static cairo_status_t
_cairo_ft_font_face_create_for_pattern (FcPattern *pattern,
cairo_font_face_t **out);
@@ -2191,6 +2204,7 @@ _cairo_ft_font_face_create_for_toy (cairo_toy_font_face_t *toy_face,
return status;
}
+#endif
static void
_cairo_ft_font_face_destroy (void *abstract_face)
@@ -2249,8 +2263,10 @@ _cairo_ft_font_face_destroy (void *abstract_face)
font_face->unscaled = NULL;
}
+#if CAIRO_HAS_FC_FONT
if (font_face->pattern)
FcPatternDestroy (font_face->pattern);
+#endif
}
static cairo_status_t
@@ -2274,6 +2290,7 @@ _cairo_ft_font_face_scaled_font_create (void *abstract_face,
* flags and ignore the options.
*/
+#if CAIRO_HAS_FC_FONT
/* If we have an unresolved pattern, resolve it and create
* unscaled font. Otherwise, use the ones stored in font_face.
*/
@@ -2295,7 +2312,9 @@ _cairo_ft_font_face_scaled_font_create (void *abstract_face,
return CAIRO_STATUS_SUCCESS;
}
- } else {
+ } else
+#endif
+ {
unscaled = font_face->unscaled;
ft_options = font_face->ft_options;
}
@@ -2309,11 +2328,16 @@ _cairo_ft_font_face_scaled_font_create (void *abstract_face,
const cairo_font_face_backend_t _cairo_ft_font_face_backend = {
CAIRO_FONT_TYPE_FT,
+#if CAIRO_HAS_FC_FONT
_cairo_ft_font_face_create_for_toy,
+#else
+ NULL,
+#endif
_cairo_ft_font_face_destroy,
_cairo_ft_font_face_scaled_font_create
};
+#if CAIRO_HAS_FC_FONT
static cairo_status_t
_cairo_ft_font_face_create_for_pattern (FcPattern *pattern,
cairo_font_face_t **out)
@@ -2338,6 +2362,7 @@ _cairo_ft_font_face_create_for_pattern (FcPattern *pattern,
*out = &font_face->base;
return CAIRO_STATUS_SUCCESS;
}
+#endif
static cairo_font_face_t *
_cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
@@ -2378,7 +2403,9 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
font_face->next = unscaled->faces;
unscaled->faces = font_face;
+#if CAIRO_HAS_FC_FONT
font_face->pattern = NULL;
+#endif
_cairo_font_face_init (&font_face->base, &_cairo_ft_font_face_backend);
@@ -2387,6 +2414,7 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
/* implement the platform-specific interface */
+#if CAIRO_HAS_FC_FONT
static cairo_status_t
_cairo_ft_font_options_substitute (const cairo_font_options_t *options,
FcPattern *pattern)
@@ -2633,6 +2661,7 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
return font_face;
}
+#endif
/**
* cairo_ft_font_face_create_for_ft_face:
diff --git a/src/cairo-ft.h b/src/cairo-ft.h
index 91e2db8..b7178d3 100644
--- a/src/cairo-ft.h
+++ b/src/cairo-ft.h
@@ -43,18 +43,14 @@
/* Fontconfig/Freetype platform-specific font interface */
-#include <fontconfig/fontconfig.h>
#include <ft2build.h>
#include FT_FREETYPE_H
-CAIRO_BEGIN_DECLS
-
-cairo_public cairo_font_face_t *
-cairo_ft_font_face_create_for_pattern (FcPattern *pattern);
+#if CAIRO_HAS_FC_FONT
+#include <fontconfig/fontconfig.h>
+#endif
-cairo_public void
-cairo_ft_font_options_substitute (const cairo_font_options_t *options,
- FcPattern *pattern);
+CAIRO_BEGIN_DECLS
cairo_public cairo_font_face_t *
cairo_ft_font_face_create_for_ft_face (FT_Face face,
@@ -66,6 +62,17 @@ cairo_ft_scaled_font_lock_face (cairo_scaled_font_t *scaled_font);
cairo_public void
cairo_ft_scaled_font_unlock_face (cairo_scaled_font_t *scaled_font);
+#if CAIRO_HAS_FC_FONT
+
+cairo_public cairo_font_face_t *
+cairo_ft_font_face_create_for_pattern (FcPattern *pattern);
+
+cairo_public void
+cairo_ft_font_options_substitute (const cairo_font_options_t *options,
+ FcPattern *pattern);
+
+#endif
+
CAIRO_END_DECLS
#else /* CAIRO_HAS_FT_FONT */
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index fa678bd..82bab3b 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -39,7 +39,9 @@
#include "cairo-os2-private.h"
+#if CAIRO_HAS_FC_FONT
#include <fontconfig/fontconfig.h>
+#endif
#include <float.h>
#ifdef BUILD_CAIRO_DLL
@@ -101,7 +103,7 @@ cairo_os2_init (void)
DisableFPUException ();
-#if CAIRO_HAS_FT_FONT
+#if CAIRO_HAS_FC_FONT
/* Initialize FontConfig */
FcInit ();
#endif
@@ -132,7 +134,7 @@ cairo_os2_fini (void)
cairo_debug_reset_static_data ();
-#if CAIRO_HAS_FT_FONT
+#if CAIRO_HAS_FC_FONT
# if HAVE_FCFINI
/* Uninitialize FontConfig */
FcFini ();
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 41096f1..a90c317 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -1240,7 +1240,7 @@ _cprt_move_to (void *closure,
return CAIRO_INT_STATUS_UNSUPPORTED;
}
-/**
+/*
* Check whether the given path is representable as a region.
* That is, if the path contains only axis aligned lines between
* integer coordinates in device space.
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 9acfc43..249ab6c 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2719,8 +2719,8 @@ slim_hidden_def (cairo_scaled_font_get_font_matrix);
*
* Stores the CTM with which @scaled_font was created into @ctm.
* Note that the translation offsets (x0, y0) of the CTM are ignored
- * by cairo_scaled_font_create(). So, the matrix this function
- * returns always has 0,0 as x0,y0.
+ * by cairo_scaled_font_create(). So, the matrix this
+ * function returns always has 0,0 as x0,y0.
*
* Since: 1.2
**/
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index e85174b..af244ab 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -38,8 +38,6 @@
#include "cairo-xlib-private.h"
#include "cairo-xlib-xrender-private.h"
-#include <fontconfig/fontconfig.h>
-
#include <X11/Xlibint.h> /* For XESetCloseDisplay */
typedef int (*cairo_xlib_error_func_t) (Display *display,
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index 3b1ae2e..8f1e949 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -112,7 +112,7 @@ get_integer_default (Display *dpy,
v = XGetDefault (dpy, "Xft", option);
if (v) {
-#if CAIRO_HAS_FT_FONT
+#if CAIRO_HAS_FC_FONT
if (FcNameConstant ((FcChar8 *) v, value))
return TRUE;
#endif
@@ -125,7 +125,15 @@ get_integer_default (Display *dpy,
return FALSE;
}
-/* Old versions of fontconfig didn't have these options */
+#ifndef FC_RGBA_UNKNOWN
+#define FC_RGBA_UNKNOWN 0
+#define FC_RGBA_RGB 1
+#define FC_RGBA_BGR 2
+#define FC_RGBA_VRGB 3
+#define FC_RGBA_VBGR 4
+#define FC_RGBA_NONE 5
+#endif
+
#ifndef FC_HINT_NONE
#define FC_HINT_NONE 0
#define FC_HINT_SLIGHT 1
@@ -133,17 +141,6 @@ get_integer_default (Display *dpy,
#define FC_HINT_FULL 3
#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
static void
_cairo_xlib_init_screen_font_options (Display *dpy,
More information about the cairo-commit
mailing list