[cairo] Request: Separate FreeType and Fontconfig

Jeff Muizelaar jeff at infidigm.net
Mon Mar 9 06:21:06 PDT 2009


On Mon, Mar 09, 2009 at 12:44:26PM +0200, Vladimir Vukicevic wrote:
> We're using freetype without fontconfig in Mozilla on some platforms, 
> though this is based on an older version of cairo (we'll be upgrading 
> soon) -- the patch is pretty straightforward though.
> 
> http://hg.mozilla.org/mozilla-central/file/50169589cc51/gfx/cairo/wince-fontconfig.patch

And attached is a version of that patch updated to the current version of
cairo.

-Jeff
-------------- next part --------------
commit 7ae514e2aa29cb313ccec98310628f87e744f797
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Fri Feb 27 12:35:14 2009 -0500

    bug 462908; fixes required to compile for windows ce. Also allows for building without fontconfig

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 5be0aaf..545263c 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -45,8 +45,10 @@
 
 #include <float.h>
 
+#ifndef CAIRO_DISABLE_FONTCONFIG
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcfreetype.h>
+#endif
 
 #include <ft2build.h>
 #include FT_FREETYPE_H
@@ -121,9 +123,11 @@ _cairo_ft_unscaled_font_keys_equal (const void *key_a,
 static void
 _cairo_ft_unscaled_font_fini (cairo_ft_unscaled_font_t *unscaled);
 
+#ifndef CAIRO_DISABLE_FONTCONFIG
 static cairo_status_t
 _cairo_ft_font_options_substitute (const cairo_font_options_t *options,
 				   FcPattern                  *pattern);
+#endif
 
 typedef enum _cairo_ft_extra_flags {
     CAIRO_FT_OPTIONS_HINT_METRICS = (1 << 0),
@@ -468,7 +472,7 @@ UNWIND:
     return NULL;
 }
 
-
+#ifndef CAIRO_DISABLE_FONTCONFIG
 static cairo_ft_unscaled_font_t *
 _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern)
 {
@@ -490,6 +494,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)
@@ -1297,6 +1302,7 @@ typedef struct _cairo_ft_scaled_font {
 
 static const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend;
 
+#ifndef CAIRO_DISABLE_FONTCONFIG
 /* The load flags passed to FT_Load_Glyph control aspects like hinting and
  * antialiasing. Here we compute them from the fields of a FcPattern.
  */
@@ -1432,6 +1438,7 @@ _get_pattern_ft_options (FcPattern *pattern, cairo_ft_options_t *ret)
 
     *ret = ft_options;
 }
+#endif /* CAIRO_DISABLE_FONTCONFIG */
 
 static void
 _cairo_ft_options_merge (cairo_ft_options_t *options,
@@ -2050,10 +2057,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); */
+#ifdef CAIRO_DISABLE_FONTCONFIG
+    index = FT_Get_Char_Index (face, ucs4); 
+#else
     index = FcFreeTypeCharIndex (face, ucs4);
-
+#endif
     _cairo_ft_unscaled_font_unlock_face (unscaled);
     return index;
 }
@@ -2139,6 +2147,7 @@ static cairo_status_t
 _cairo_ft_font_face_create_for_toy (cairo_toy_font_face_t   *toy_face,
 				    cairo_font_face_t      **font_face)
 {
+#ifndef CARIO_DISABLE_FONTCONFIG
     FcPattern *pattern;
     int fcslant;
     int fcweight;
@@ -2196,6 +2205,9 @@ _cairo_ft_font_face_create_for_toy (cairo_toy_font_face_t   *toy_face,
     FcPatternDestroy (pattern);
 
     return status;
+#else
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+#endif /* CAIRO_DISABLE_FONTCONFIG */
 }
 
 static void
@@ -2391,6 +2403,7 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
     return &font_face->base;
 }
 
+#ifndef CAIRO_DISABLE_FONTCONFIG
 /* implement the platform-specific interface */
 
 static cairo_status_t
@@ -2639,6 +2652,7 @@ cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
 
     return font_face;
 }
+#endif /* CAIRO_DISABLE_FONTCONFIG */
 
 /**
  * cairo_ft_font_face_create_for_ft_face:
diff --git a/src/cairo-ft.h b/src/cairo-ft.h
index 91e2db8..ddc763e 100644
--- a/src/cairo-ft.h
+++ b/src/cairo-ft.h
@@ -43,18 +43,22 @@
 
 /* Fontconfig/Freetype platform-specific font interface */
 
+#ifndef CAIRO_DISABLE_FONTCONFIG
 #include <fontconfig/fontconfig.h>
+#endif
 #include <ft2build.h>
 #include FT_FREETYPE_H
 
 CAIRO_BEGIN_DECLS
 
+#ifndef CAIRO_DISABLE_FONTCONFIG
 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_public cairo_font_face_t *
 cairo_ft_font_face_create_for_ft_face (FT_Face         face,


More information about the cairo mailing list