Browse Source

libcairodriver: enable Cairo with and without Fontconfig (#1697)

Changes with Cairo 1.10, lead to three different situations to account to regarding
Fontconfig support:

- Cairo <1.10 has Fontconfig as a requirement (no CAIRO_HAS_FC_FONT)
- Cairo => 1.10 compiled with Fontconfig (CAIRO_HAS_FC_FONT is defined)
- Cairo => 1.10 compiled without Fontconfig (CAIRO_HAS_FC_FONT is not defined)

This updates to take all cases into consideration.
nilason 3 years ago
parent
commit
5a97bbe77f
1 changed files with 9 additions and 4 deletions
  1. 9 4
      lib/cairodriver/text.c

+ 9 - 4
lib/cairodriver/text.c

@@ -17,8 +17,13 @@
 
 
 #if CAIRO_HAS_FT_FONT
 #if CAIRO_HAS_FT_FONT
 #include <cairo-ft.h>
 #include <cairo-ft.h>
+#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1,10,0) || defined(CAIRO_HAS_FC_FONT)
+#define USE_FONTCONFIG 1
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fontconfig.h>
+#else
+#define USE_FONTCONFIG 0
 #endif
 #endif
+#endif /* CAIRO_HAS_FT_FONT */
 
 
 #ifdef HAVE_ICONV_H
 #ifdef HAVE_ICONV_H
 #include <iconv.h>
 #include <iconv.h>
@@ -170,7 +175,7 @@ static void set_font_toy(const char *name)
     G_free(font);
     G_free(font);
 }
 }
 
 
-#if CAIRO_HAS_FT_FONT
+#if USE_FONTCONFIG
 
 
 static void fc_init(void)
 static void fc_init(void)
 {
 {
@@ -281,7 +286,7 @@ static int is_toy_font(const char *name)
 */
 */
 void Cairo_set_font(const char *name)
 void Cairo_set_font(const char *name)
 {
 {
-#if CAIRO_HAS_FT_FONT
+#if USE_FONTCONFIG
     if (is_toy_font(name))
     if (is_toy_font(name))
 	set_font_toy(name);
 	set_font_toy(name);
     else
     else
@@ -322,7 +327,7 @@ static void font_list_toy(char ***list, int *count, int verbose)
 void Cairo_font_list(char ***list, int *count)
 void Cairo_font_list(char ***list, int *count)
 {
 {
     font_list_toy(list, count, 0);
     font_list_toy(list, count, 0);
-#if CAIRO_HAS_FT_FONT
+#if USE_FONTCONFIG
     font_list_fc(list, count, 0);
     font_list_fc(list, count, 0);
 #endif
 #endif
 }
 }
@@ -336,7 +341,7 @@ void Cairo_font_list(char ***list, int *count)
 void Cairo_font_info(char ***list, int *count)
 void Cairo_font_info(char ***list, int *count)
 {
 {
     font_list_toy(list, count, 1);
     font_list_toy(list, count, 1);
-#if CAIRO_HAS_FT_FONT
+#if USE_FONTCONFIG
     font_list_fc(list, count, 1);
     font_list_fc(list, count, 1);
 #endif
 #endif
 }
 }