summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-12-10 08:31:33 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-12-10 08:31:33 +0000
commitf4fad0c741636d017aefd76d58e271466696cc6f (patch)
tree2e77cb9df99173cd841609f5ccdb4a40136dcd21 /pango/fonts.c
parented7f7ab40893d20bab5a221cc95cfcba965cd93e (diff)
downloadpango-f4fad0c741636d017aefd76d58e271466696cc6f.tar.gz
Bug 478914 – Use something invalid instead of '?' when validating input
2007-12-10 Behdad Esfahbod <behdad@gnome.org> Bug 478914 – Use something invalid instead of '?' when validating input text * pango/pango-layout.c (pango_layout_set_text): Set invalid input bytes to -1, which gives a unichar value of -1, and eventually a glyph value of -1, aka PANGO_GLYPH_INVALID_INPUT. * pango/fonts.c (pango_font_get_glyph_extents), (pango_font_get_metrics), (pango_font_get_font_map): * pango/modules.c (build_map): * pango/pango-context.c (get_script), (get_shaper_and_font), (string_from_script), (itemize_state_process_run): * pango/pango-coverage.c (pango_coverage_get): * pango/pango-impl-utils.h: * pango/pango-utils.c: * pango/pangocairo-font.c (pango_cairo_font_get_scaled_font), (_pango_cairo_font_private_get_hex_box_info), (_pango_cairo_font_private_get_glyph_extents_missing): * pango/pangocairo-private.h: * pango/pangocairo-render.c (_pango_cairo_renderer_draw_frame), (_pango_cairo_renderer_draw_box_glyph), (_pango_cairo_renderer_draw_unknown_glyph): * pango/pangofc-fontmap.c (pango_fc_font_map_get_patterns): * pango/pangoft2-private.h: * pango/pangoft2-render.c (pango_ft2_font_render_box_glyph), (pango_ft2_font_render_glyph), (pango_ft2_renderer_draw_glyph): * pango/pangoft2.c (pango_ft2_font_get_face), (pango_ft2_font_get_glyph_extents): * pango/pangox.c (pango_x_find_subfont), (pango_x_render): * pango/pangoxft-font.c (_pango_xft_font_get_mini_font), (get_glyph_extents_missing), (pango_xft_font_get_font): * pango/pangoxft-private.h: * pango/pangoxft-render.c (get_total_matrix), (draw_box), (_pango_xft_renderer_draw_box_glyph), (_pango_xft_renderer_draw_unknown_glyph), (pango_xft_renderer_draw_glyphs): * pango/shape.c (pango_shape): Render PANGO_GLYPH_INVALID_INPUT to a single-width box with a cross inside. Also cleanup spewed warnings and warn at the source, where we fail to find a shaper, instead of at every location that we see a NULL font. * pango/pango-font.h: * docs/pango-sections.txt: * docs/tmpl/glyphs.sgml: New public macro: PANGO_GLYPH_INVALID_INPUT svn path=/trunk/; revision=2519
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index c60c602d..56dc4177 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -29,8 +29,6 @@
#include "pango-fontmap.h"
#include "pango-impl-utils.h"
-static const char bad_font_warning[] = "%s called with null font argument, expect ugly output";
-
struct _PangoFontDescription
{
char *family_name;
@@ -1314,6 +1312,9 @@ pango_font_find_shaper (PangoFont *font,
* PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert
* from the extents rectangle to more traditional font metrics. The units
* of the rectangles are in 1/PANGO_SCALE of a device unit.
+ *
+ * If @font is %NULL, this function gracefully sets some sane values in the
+ * output variables and returns.
**/
void
pango_font_get_glyph_extents (PangoFont *font,
@@ -1323,12 +1324,6 @@ pango_font_get_glyph_extents (PangoFont *font,
{
if (G_UNLIKELY (!font))
{
-
- if (!_pango_warning_history.get_glyph_extents)
- {
- _pango_warning_history.get_glyph_extents = TRUE;
- g_warning (bad_font_warning, "pango_font_get_glyph_extents");
- }
if (ink_rect)
{
ink_rect->x = PANGO_SCALE;
@@ -1361,6 +1356,9 @@ pango_font_get_glyph_extents (PangoFont *font,
* be provided to indicate that the metrics should be retrieved that
* correspond to the script(s) used by that language.
*
+ * If @font is %NULL, this function gracefully sets some sane values in the
+ * output variables and returns.
+ *
* Return value: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
* when finished using the object.
**/
@@ -1370,14 +1368,7 @@ pango_font_get_metrics (PangoFont *font,
{
if (G_UNLIKELY (!font))
{
- PangoFontMetrics *metrics;
-
- if (!_pango_warning_history.get_metrics)
- {
- _pango_warning_history.get_metrics = TRUE;
- g_warning (bad_font_warning, "pango_font_get_metrics");
- }
- metrics = pango_font_metrics_new ();
+ PangoFontMetrics *metrics = pango_font_metrics_new ();
metrics->ascent = PANGO_SCALE * PANGO_UNKNOWN_GLYPH_HEIGHT;
metrics->descent = 0;
@@ -1400,7 +1391,7 @@ pango_font_get_metrics (PangoFont *font,
*
* Gets the font map for which the font was created.
*
- * Return value: the #PangoFontMap for the font
+ * Return value: the #PangoFontMap for the font, or %NULL if @font is %NULL.
*
* Since: 1.10
**/
@@ -1408,15 +1399,7 @@ PangoFontMap *
pango_font_get_font_map (PangoFont *font)
{
if (G_UNLIKELY (!font))
- {
-
- if (!_pango_warning_history.get_font_map)
- {
- _pango_warning_history.get_font_map = TRUE;
- g_warning (bad_font_warning, "pango_font_get_font_map");
- }
- return NULL;
- }
+ return NULL;
if (PANGO_FONT_GET_CLASS (font)->get_font_map)
return PANGO_FONT_GET_CLASS (font)->get_font_map (font);