summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--configure.in14
-rw-r--r--pango/pangocairo-font.c22
3 files changed, 47 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d17f2d70..19574492 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2006-02-06 Behdad Esfahbod <behdad@gnome.org>
+ As cairo 1.2 seems to be delayed infinitely, make all cairo HEAD
+ API that we use conditional, to make a release.
+
+ * configure.in: Depend on cairo 1.0.0 again. Check for
+ cairo_scaled_font_get_*() and cairo_scaled_font_text_extents()
+ availability.
+
+ * pango/pangocairo-font.c: Work around if the above functions are not
+ available.
+
+2006-02-06 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pango-utils.c (pango_matrix_copy, pango_matrix_free): If
NULL is passed to _copy, return NULL with no warning. If NULL is
passed to _free, do nothing with no warning. Docs updated.
diff --git a/configure.in b/configure.in
index cba667cb..73e93547 100644
--- a/configure.in
+++ b/configure.in
@@ -295,7 +295,7 @@ have_cairo_freetype=false
have_cairo_win32=false
have_cairo_atsui=false
-PKG_CHECK_MODULES(CAIRO, cairo >= 1.1.1, have_cairo=true, :)
+PKG_CHECK_MODULES(CAIRO, cairo >= 1.0.0, have_cairo=true, :)
if $have_cairo ; then
pango_save_ldflags=$LDFLAGS
@@ -303,6 +303,18 @@ if $have_cairo ; then
INSTALLED_CAIRO_LIBS=`PKG_CONFIG_DISABLE_UNINSTALLED=yes $PKG_CONFIG --libs cairo`
LDFLAGS="$LDFLAGS $INSTALLED_CAIRO_LIBS"
+ # A couple temporary checks, to not rely on cairo HEAD :(
+ have_cairo_scaled_font_getters=false
+ AC_CHECK_LIB(cairo, cairo_scaled_font_get_ctm, have_cairo_scaled_font_getters=true, :)
+ if $have_cairo_scaled_font_getters; then
+ AC_DEFINE(HAVE_CAIRO_SCALED_FONT_GETTERS, 1, [Whether Cairo has cairo_scaled_font_get_*()])
+ fi
+ have_cairo_scaled_font_text_extents=false
+ AC_CHECK_LIB(cairo, cairo_scaled_font_text_extents, have_cairo_scaled_font_text_extents=true, :)
+ if $have_cairo_scaled_font_text_extents; then
+ AC_DEFINE(HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS, 1, [Whether Cairo has cairo_scaled_font_text_extents()])
+ fi
+
AC_CHECK_LIB(cairo, cairo_surface_write_to_png, have_cairo_png=true, :)
if $have_cairo_png; then
AC_DEFINE(HAVE_CAIRO_PNG, 1, [Whether Cairo has PNG support])
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 99e2d930..ef03d68a 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -133,6 +133,10 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
cairo_font_extents_t font_extents;
PangoFontDescription *mini_desc, *desc;
cairo_scaled_font_t *scaled_font, *scaled_mini_font;
+#ifndef HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS
+ cairo_surface_t *surface;
+ cairo_t *cr;
+#endif
if (!cfont)
return NULL;
@@ -143,6 +147,7 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
scaled_font = _pango_cairo_font_get_scaled_font (cfont);
+#ifdef HAVE_CAIRO_SCALED_FONT_GETTERS
/* prepare for some hinting */
{
cairo_matrix_t ctm;
@@ -159,6 +164,9 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
scale_y = sqrt (x*x + y*y);
scale_y_inv = 1 / scale_y;
}
+#else
+ scale_x = scale_x_inv = scale_y = scale_y_inv = 1.0;
+#endif
/* we hint to the nearest device units */
#define HINT(value, scale, scale_inv) (ceil ((value-1e-5) * scale) * scale_inv)
@@ -214,16 +222,30 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
mini_cfont = (PangoCairoFont *) mini_font;
scaled_mini_font = _pango_cairo_font_get_scaled_font (mini_cfont);
+#ifndef HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS
+ surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1);
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
+ _pango_cairo_font_install (mini_cfont, cr);
+#endif
+
for (i = 0 ; i < 16 ; i++)
{
cairo_text_extents_t extents;
c[0] = hexdigits[i];
+#ifdef HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS
cairo_scaled_font_text_extents (scaled_mini_font, c, &extents);
+#else
+ cairo_text_extents (cr, c, &extents);
+#endif
width = MAX (width, extents.width);
height = MAX (height, extents.height);
}
+#ifndef HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS
+ cairo_destroy (cr);
+#endif
cairo_scaled_font_extents (scaled_font, &font_extents);
hbi = g_slice_new (PangoCairoHexBoxInfo);