diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-01-31 00:44:04 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-01-31 00:44:04 +0000 |
commit | 4c64086f6cee60fb5275b8fabf2a465212ab8420 (patch) | |
tree | d8bcf6e7ba91e91a8c8e7009a828c0c53d91cfc5 /pango/fonts.c | |
parent | 71f0113fe55447c026fb00115c552a8762bf9e91 (diff) | |
download | pango-4c64086f6cee60fb5275b8fabf2a465212ab8420.tar.gz |
Improve error handling in high-frequency functions: Only warn once.
2006-01-30 Behdad Esfahbod <behdad@gnome.org>
* pango/shape.c (pango_shape):
* pango/fonts.c (pango_font_get_glyph_extents):
* pango/pangocairo-font.c (_pango_cairo_font_install):
Improve error handling in high-frequency functions: Only warn
once.
* pango-impl-utils.h, pangoutils.h:
* pangocairo-private.h, pangocairo-font.c:
Add machinery for above: _pango_warning_history and
_pango_cairo_warning_history.
Diffstat (limited to 'pango/fonts.c')
-rw-r--r-- | pango/fonts.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index 2142d58b..4835a198 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -24,6 +24,7 @@ #include <math.h> #include <string.h> +#include "pango-impl-utils.h" #include "pango-types.h" #include "pango-font.h" #include "pango-fontmap.h" @@ -1163,7 +1164,30 @@ pango_font_get_glyph_extents (PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect) { - g_return_if_fail (font != NULL); + if (G_UNLIKELY (font == NULL)) + { + + if (!_pango_warning_history.get_glyph_extents) + { + _pango_warning_history.get_glyph_extents = TRUE; + g_critical ("pango_font_get_glyph_extents called with font == NULL, expect ugly output"); + } + if (ink_rect) + { + ink_rect->x = 0; + ink_rect->y = 0; + ink_rect->height = 12 * PANGO_SCALE; + ink_rect->width = 12 * PANGO_SCALE; + } + if (logical_rect) + { + logical_rect->x = 0; + logical_rect->y = 0; + logical_rect->height = 12 * PANGO_SCALE; + logical_rect->width = 12 * PANGO_SCALE; + } + return; + } PANGO_FONT_GET_CLASS (font)->get_glyph_extents (font, glyph, ink_rect, logical_rect); } |