diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2007-12-10 08:31:33 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2007-12-10 08:31:33 +0000 |
commit | f4fad0c741636d017aefd76d58e271466696cc6f (patch) | |
tree | 2e77cb9df99173cd841609f5ccdb4a40136dcd21 /pango/pangoft2.c | |
parent | ed7f7ab40893d20bab5a221cc95cfcba965cd93e (diff) | |
download | pango-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/pangoft2.c')
-rw-r--r-- | pango/pangoft2.c | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/pango/pangoft2.c b/pango/pangoft2.c index f2d85af9..ff3ca319 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -33,8 +33,6 @@ #include "pangofc-fontmap.h" #include "pangofc-private.h" -PangoFT2WarningHistory _pango_ft2_warning_history = { FALSE }; - /* for compatibility with older freetype versions */ #ifndef FT_LOAD_TARGET_MONO #define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME @@ -161,7 +159,8 @@ set_transform (PangoFT2Font *ft2font) * face from pango_fc_font_lock_face() you must call * pango_fc_font_unlock_face(). * - * Return value: a pointer to a <type>FT_Face</type> structure, with the size set correctly + * Return value: a pointer to a <type>FT_Face</type> structure, with the size set correctly, + * or %NULL if @font is %NULL. **/ FT_Face pango_ft2_font_get_face (PangoFont *font) @@ -175,15 +174,8 @@ pango_ft2_font_get_face (PangoFont *font) int hintstyle; int id; - if (G_UNLIKELY (!PANGO_FT2_IS_FONT (font))) - { - if (!_pango_ft2_warning_history.get_face) - { - _pango_ft2_warning_history.get_face = TRUE; - g_warning ("pango_ft2_font_get_face called with bad font, expect ugly output"); - } - return NULL; - } + if (G_UNLIKELY (!font)) + return NULL; pattern = fcfont->font_pattern; @@ -336,40 +328,35 @@ pango_ft2_font_get_glyph_extents (PangoFont *font, if (glyph & PANGO_GLYPH_UNKNOWN_FLAG) { - glyph = pango_ft2_get_unknown_glyph (font); - if (glyph == PANGO_GLYPH_EMPTY) - { - /* No unknown glyph found for the font, draw a box */ - PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL); + PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL); - if (metrics) + if (metrics) + { + if (ink_rect) { - if (ink_rect) - { - ink_rect->x = PANGO_SCALE; - ink_rect->width = metrics->approximate_char_width - 2 * PANGO_SCALE; - ink_rect->y = - (metrics->ascent - PANGO_SCALE); - ink_rect->height = metrics->ascent + metrics->descent - 2 * PANGO_SCALE; - } - if (logical_rect) - { - logical_rect->x = 0; - logical_rect->width = metrics->approximate_char_width; - logical_rect->y = -metrics->ascent; - logical_rect->height = metrics->ascent + metrics->descent; - } - - pango_font_metrics_unref (metrics); + ink_rect->x = PANGO_SCALE; + ink_rect->width = metrics->approximate_char_width - 2 * PANGO_SCALE; + ink_rect->y = - (metrics->ascent - PANGO_SCALE); + ink_rect->height = metrics->ascent + metrics->descent - 2 * PANGO_SCALE; } - else + if (logical_rect) { - if (ink_rect) - ink_rect->x = ink_rect->y = ink_rect->height = ink_rect->width = 0; - if (logical_rect) - logical_rect->x = logical_rect->y = logical_rect->height = logical_rect->width = 0; + logical_rect->x = 0; + logical_rect->width = metrics->approximate_char_width; + logical_rect->y = -metrics->ascent; + logical_rect->height = metrics->ascent + metrics->descent; } - return; + + pango_font_metrics_unref (metrics); + } + else + { + if (ink_rect) + ink_rect->x = ink_rect->y = ink_rect->height = ink_rect->width = 0; + if (logical_rect) + logical_rect->x = logical_rect->y = logical_rect->height = logical_rect->width = 0; } + return; } info = pango_ft2_font_get_glyph_info (font, glyph, TRUE); |