summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-04-29 23:09:12 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-04-29 23:09:12 +0000
commit29b48d2171562fb43b3c9ffc86e1904aff462d86 (patch)
tree5bd5fe3035cb7b77d39f9e6bddc3ca09989cc313
parentd52296311614adf06c07389e34fa2bd69dbc343a (diff)
downloadpango-29b48d2171562fb43b3c9ffc86e1904aff462d86.tar.gz
Require cairo >= 1.1.2. Also pass -no-undefined on all systems.
2006-04-29 Behdad Esfahbod <behdad@gnome.org> * configure.in: Require cairo >= 1.1.2. Also pass -no-undefined on * all systems. * pango/pangocairo-font.c (_pango_cairo_font_get_hex_box_info): Fix hexbox info to respect absolute sizes and no metrics hinting settings.
-rw-r--r--ChangeLog8
-rw-r--r--configure.in50
-rw-r--r--pango/pangocairo-font.c148
3 files changed, 118 insertions, 88 deletions
diff --git a/ChangeLog b/ChangeLog
index 49a710de..3bb66718 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2006-04-29 Behdad Esfahbod <behdad@gnome.org>
+ * configure.in: Require cairo >= 1.1.2. Also pass -no-undefined on all
+ systems.
+
+ * pango/pangocairo-font.c (_pango_cairo_font_get_hex_box_info): Fix
+ hexbox info to respect absolute sizes and no metrics hinting settings.
+
+2006-04-29 Behdad Esfahbod <behdad@gnome.org>
+
Bug 329664 – Move gunichar_to_glyph cache from PangoCairoFcFont to
PangoFcFont
Patch from LingNing Zhang.
diff --git a/configure.in b/configure.in
index 5658262a..bfd6f7b2 100644
--- a/configure.in
+++ b/configure.in
@@ -290,12 +290,14 @@ AC_CHECK_HEADER(Carbon/Carbon.h, [have_atsui=true], [have_atsui=true])
#
have_cairo=false
have_cairo_png=false
+have_cairo_ps=false
+have_cairo_pdf=false
have_cairo_xlib=false
have_cairo_freetype=false
have_cairo_win32=false
have_cairo_atsui=false
-PKG_CHECK_MODULES(CAIRO, cairo >= 1.0.0, have_cairo=true, :)
+PKG_CHECK_MODULES(CAIRO, cairo >= 1.1.2, have_cairo=true, :)
if $have_cairo ; then
pango_save_ldflags=$LDFLAGS
@@ -303,47 +305,54 @@ 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])
fi
+
+ AC_CHECK_LIB(cairo, cairo_ps_surface_create, have_cairo_ps=true, :)
+ if $have_cairo_ps; then
+ AC_DEFINE(HAVE_CAIRO_PS, 1, [Whether Cairo has PS support])
+ fi
+
+ AC_CHECK_LIB(cairo, cairo_pdf_surface_create, have_cairo_pdf=true, :)
+ if $have_cairo_pdf; then
+ AC_DEFINE(HAVE_CAIRO_PDF, 1, [Whether Cairo has PDF support])
+ fi
+
AC_CHECK_LIB(cairo, cairo_xlib_surface_create, have_cairo_xlib=true, :)
if $have_cairo_xlib; then
AC_DEFINE(HAVE_CAIRO_XLIB, 1, [Whether Cairo has Xlib support])
fi
+
have_cairo=false
+
AC_CHECK_LIB(cairo, cairo_win32_scaled_font_select_font, have_cairo_win32=true, :)
if $have_cairo_win32 && $have_win32; then
AC_DEFINE(HAVE_CAIRO_WIN32, 1, [Whether Cairo uses the Win32 GDI for fonts])
have_cairo=true
fi
+
AC_CHECK_LIB(cairo, cairo_ft_scaled_font_lock_face, have_cairo_freetype=true, :)
if $have_cairo_freetype && $have_freetype ; then
AC_DEFINE(HAVE_CAIRO_FREETYPE, 1, [Whether Cairo uses FreeType for fonts])
have_cairo=true
fi
+
AC_CHECK_LIB(cairo, cairo_atsui_font_face_create_for_atsu_font_id, have_cairo_atsui=true, :)
if $have_cairo_atsui && $have_atsui ; then
AC_DEFINE(HAVE_CAIRO_ATSUI, 1, [Whether Cairo uses ATSUI for fonts])
have_cairo=true
fi
+
LDFLAGS=$pango_save_ldflags
fi
AM_CONDITIONAL(HAVE_CAIRO, $have_cairo)
AM_CONDITIONAL(HAVE_CAIRO_PNG, $have_cairo_png)
+AM_CONDITIONAL(HAVE_CAIRO_PS, $have_cairo_ps)
+AM_CONDITIONAL(HAVE_CAIRO_PDF, $have_cairo_pdf)
AM_CONDITIONAL(HAVE_CAIRO_XLIB, $have_cairo_xlib)
AM_CONDITIONAL(HAVE_CAIRO_WIN32, $have_cairo_win32 && $have_win32)
AM_CONDITIONAL(HAVE_CAIRO_FREETYPE, $have_cairo_freetype && $have_freetype)
@@ -586,15 +595,16 @@ dnl ********************************************************
# Note that -module isn't included here since automake needs to see it to know
# that something like pango-arabic-fc.la is a valid libtool archive
#
-if test "$pango_os_win32" != yes; then
- # libtool option to control which symbols are exported
- # right now, symbols starting with _ are not exported
- LIBRARY_LIBTOOL_OPTIONS="-version-info $LT_VERSION_INFO "'-export-symbols-regex "^pango_.*"'
- MODULE_LIBTOOL_OPTIONS="-export-dynamic -avoid-version "'-export-symbols-regex "^script_engine_.*"'
-else
+LIBRARY_LIBTOOL_OPTIONS="-version-info $LT_VERSION_INFO -no-undefined"
+MODULE_LIBTOOL_OPTIONS="-export-dynamic -avoid-version -no-undefined"
+if test "$pango_os_win32" = yes; then
# We currently use .def files on Windows
- LIBRARY_LIBTOOL_OPTIONS="-version-info $LT_VERSION_INFO -no-undefined"
- MODULE_LIBTOOL_OPTIONS="-export-dynamic -avoid-version -no-undefined"
+ true
+else
+ # libtool option to control which symbols are exported
+ # right now, symbols starting with '_' are not exported
+ LIBRARY_LIBTOOL_OPTIONS="$LIBRARY_LIBTOOL_OPTIONS "'-export-symbols-regex "^pango_.*"'
+ MODULE_LIBTOOL_OPTIONS="$MODULE_LIBTOOL_OPTIONS"'-export-symbols-regex "^script_engine_.*"'
fi
AC_SUBST(LIBRARY_LIBTOOL_OPTIONS)
AC_SUBST(MODULE_LIBTOOL_OPTIONS)
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index bc5e6057..878e3ba4 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -123,21 +123,18 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
/* for metrics hinting */
double scale_x, scale_x_inv, scale_y, scale_y_inv;
+ gboolean is_hinted;
int i;
int rows;
double pad;
double width = 0;
double height = 0;
+ cairo_font_options_t *font_options;
cairo_font_extents_t font_extents;
- PangoFontDescription *mini_desc, *desc;
- cairo_scaled_font_t *scaled_font;
-#ifdef HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS
- cairo_scaled_font_t *scaled_mini_font;
-#else
- cairo_surface_t *surface;
- cairo_t *cr;
-#endif
+ double size, mini_size;
+ PangoFontDescription *desc, *mini_desc;
+ cairo_scaled_font_t *scaled_font, *scaled_mini_font;
if (!cfont)
return NULL;
@@ -153,26 +150,27 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
return NULL;
}
-#ifdef HAVE_CAIRO_SCALED_FONT_GETTERS
- /* prepare for some hinting */
- {
- cairo_matrix_t ctm;
- double x, y;
- cairo_scaled_font_get_ctm (scaled_font, &ctm);
-
- x = 1.; y = 0.;
- cairo_matrix_transform_distance (&ctm, &x, &y);
- scale_x = sqrt (x*x + y*y);
- scale_x_inv = 1 / scale_x;
-
- x = 0.; y = 1.;
- cairo_matrix_transform_distance (&ctm, &x, &y);
- 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
+ font_options = cairo_font_options_create ();
+ cairo_scaled_font_get_font_options (scaled_font, font_options);
+ is_hinted = (cairo_font_options_get_hint_metrics(font_options) != CAIRO_HINT_METRICS_OFF);
+
+ if (is_hinted)
+ {
+ /* prepare for some hinting */
+ cairo_matrix_t ctm;
+ double x, y;
+ cairo_scaled_font_get_ctm (scaled_font, &ctm);
+
+ x = 1.; y = 0.;
+ cairo_matrix_transform_distance (&ctm, &x, &y);
+ scale_x = sqrt (x*x + y*y);
+ scale_x_inv = 1 / scale_x;
+
+ x = 0.; y = 1.;
+ cairo_matrix_transform_distance (&ctm, &x, &y);
+ scale_y = sqrt (x*x + y*y);
+ scale_y_inv = 1 / scale_y;
+ }
/* we hint to the nearest device units */
#define HINT(value, scale, scale_inv) (ceil ((value-1e-5) * scale) * scale_inv)
@@ -181,94 +179,108 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
/* create mini_font description */
{
- double size, mini_size;
+ PangoContext *context;
+ PangoFontMap *fontmap;
+
+ fontmap = pango_font_get_font_map ((PangoFont *)cfont);
desc = pango_font_describe ((PangoFont *)cfont);
size = pango_font_description_get_size (desc) / (1.*PANGO_SCALE);
+ if (pango_font_description_get_size_is_absolute (desc))
+ {
+ int dpi = pango_cairo_font_map_get_resolution (PANGO_CAIRO_FONT_MAP (fontmap));
+ size = size * 72. / dpi;
+ }
mini_desc = pango_font_description_new ();
pango_font_description_set_family_static (mini_desc, "monospace");
- /* TODO: The stuff here should give a shit to whether it's
- * absolute size or not. */
+
rows = 2;
- mini_size = HINT_Y (size / 2.4);
+ mini_size = size / 2.4;
+ if (is_hinted)
+ {
+ mini_size = HINT_Y (mini_size);
+ }
+
if (mini_size < 5.0)
{
- rows = 1;
- mini_size = MIN (size, 5.0);
+ rows = 1;
+ mini_size = MIN (MAX (size - 1, 0), 5.0);
}
- if (pango_font_description_get_size_is_absolute (desc))
- pango_font_description_set_absolute_size (mini_desc, mini_size * PANGO_SCALE);
- else
- pango_font_description_set_size (mini_desc, mini_size * PANGO_SCALE);
+ pango_font_description_set_size (mini_desc, mini_size * PANGO_SCALE);
- pango_font_description_free (desc);
- }
- /* load mini_font */
- {
- PangoContext *context;
- PangoFontMap *fontmap;
+ /* load mini_font */
- fontmap = pango_font_get_font_map ((PangoFont *)cfont);
- g_assert (fontmap);
context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
pango_context_set_language (context, pango_language_from_string ("en"));
+ pango_cairo_context_set_font_options (context, font_options);
mini_font = pango_font_map_load_font (fontmap, context, mini_desc);
pango_font_description_free (mini_desc);
+ pango_font_description_free (desc);
g_object_unref (context);
g_object_unref (fontmap);
}
+ cairo_font_options_destroy (font_options);
- mini_cfont = (PangoCairoFont *) mini_font;
-#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
+ mini_cfont = (PangoCairoFont *) mini_font;
+ scaled_mini_font = _pango_cairo_font_get_scaled_font (mini_cfont);
for (i = 0 ; i < 16 ; i++)
{
cairo_text_extents_t extents;
c[0] = hexdigits[i];
-#ifdef HAVE_CAIRO_SCALED_FONT_TEXT_EXTENTS
- scaled_mini_font = _pango_cairo_font_get_scaled_font (mini_cfont);
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);
+ pad = (font_extents.ascent + font_extents.descent) / 43;
+ pad = MIN (pad, mini_size);
hbi = g_slice_new (PangoCairoHexBoxInfo);
hbi->font = mini_font;
hbi->rows = rows;
- hbi->digit_width = HINT_X (width);
- hbi->digit_height = HINT_Y (height);
+ hbi->digit_width = width;
+ hbi->digit_height = height;
+
+ hbi->pad_x = pad;
+ hbi->pad_y = pad;
+
+ if (is_hinted)
+ {
+ hbi->digit_width = HINT_X (hbi->digit_width);
+ hbi->digit_height = HINT_Y (hbi->digit_height);
+ hbi->pad_x = HINT_X (hbi->pad_x);
+ hbi->pad_y = HINT_Y (hbi->pad_y);
+ }
- pad = (font_extents.ascent + font_extents.descent) / 43;
- hbi->pad_x = HINT_X (pad);
- hbi->pad_y = HINT_Y (pad);
hbi->line_width = MIN (hbi->pad_x, hbi->pad_y);
hbi->box_height = 3 * hbi->pad_y + rows * (hbi->pad_y + hbi->digit_height);
- hbi->box_descent = HINT_Y (font_extents.descent -
- (font_extents.ascent + font_extents.descent - hbi->box_height) / 2);
+
+ if (rows == 1)
+ {
+ hbi->box_descent = hbi->pad_y;
+ }
+ else
+ {
+ hbi->box_descent = font_extents.descent * hbi->box_height /
+ (font_extents.ascent + font_extents.descent);
+ }
+ if (is_hinted)
+ {
+ hbi->box_descent = HINT_Y (hbi->box_descent);
+ }
g_object_set_data_full (G_OBJECT (cfont), "hex_box_info", hbi, (GDestroyNotify)_pango_cairo_hex_box_info_destroy);