diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-02-03 02:46:17 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-02-03 02:46:17 +0000 |
commit | 6c9e853b93be4c01027e625427787e38be9b99f3 (patch) | |
tree | 9b1f07249ff96f43ce9f8af61613e067e0e1ea74 /pango/pangocairo-atsuifont.c | |
parent | b1e264aa208e43a3d98aa2f985a0eaafdb328bb8 (diff) | |
download | pango-6c9e853b93be4c01027e625427787e38be9b99f3.tar.gz |
Finish the 'glyph 0' work of this morning: PANGO_GLYPH_NULL that I
2006-02-02 Behdad Esfahbod <behdad@gnome.org>
Finish the 'glyph 0' work of this morning:
PANGO_GLYPH_NULL that I introduced is renamed to
PANGO_GLYPH_EMPTY. It means, no rendering should
be performed. The backends however, still return
0 if a glyph is not found. The modules then are
free to replace this 0 glyph with an unknown
character.
* modules/arabic/arabic-fc.c, modules/basic/basic-atsui.c,
modules/basic/basic-fc.c, modules/basic/basic-win32.c,
modules/basic/basic-x.c, modules/hangul/hangul-fc.c,
modules/hebrew/hebrew-fc.c, modules/indic/indic-fc.c,
modules/khmer/khmer-fc.c, modules/syriac/syriac-fc.c,
modules/thai/thai-fc.c, modules/tibetan/tibetan-fc.c,
pango/pangox.c, pango/pangowin32.c:
Adapt to above change. Backends return 0 if glyph not
found.
* pango/fonts.c (pango_font_get_glyph_extents): If font
is not usable (!PANGO_IS_FONT (font)), return the generic
UNKNOWN_GLYPH metrics. This is used when your backends
are misconfigured and you don't find *any* font at all.
* pango/pango-engince.c: Add unknown glyphs in fallback
shaper, instead of empty glyphs.
* pango/shape.c: Call the fall-back shaper if shaper
fails, instead of generating a dummy glyph string ourselves.
* pango/pango-layout.c (imposed_shape, shape_tab): Use
PANGO_GLYPH_EMPTY instead of glyph 0.
* pango/pango-renderer.c (pango_renderer_draw_glyph): No-op on
PANGO_GLYPH_EMPTY instead of glyph 0.
* pango/pangocairo-atsuifont.c, pango/pangocairo-win32font.c,
pango/pangocairo-fcfont.c, pango/pangocairo-font.c,
pango/pangocairo-private.h: install_font returns a boolean now.
* pango/pangocairo-render.c, pango/pangoxft-render.c: Handle font
and hex-box failures more gracefully by drawing a generic
unknown-box glyph.
* pango/pangoft2.c, pango/pangoft2-render.c: Draw the generic
unknown-box glyph here too. For unknown glyphs though, if
the font is TTF (FT_IS_SFNT), use the zero-indexed glyph,
otherwise, draw a box of proper size.
Diffstat (limited to 'pango/pangocairo-atsuifont.c')
-rw-r--r-- | pango/pangocairo-atsuifont.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/pango/pangocairo-atsuifont.c b/pango/pangocairo-atsuifont.c index e4d0d183..fbb74683 100644 --- a/pango/pangocairo-atsuifont.c +++ b/pango/pangocairo-atsuifont.c @@ -67,7 +67,7 @@ pango_cairo_atsui_font_get_atsu_font_id (PangoCairoATSUIFont *cafont) return cafont->font_id; } -static void +static gboolean pango_cairo_atsui_font_install (PangoCairoFont *font, cairo_t *cr) { @@ -78,6 +78,8 @@ pango_cairo_atsui_font_install (PangoCairoFont *font, cairo_set_font_matrix (cr, &cafont->font_matrix); cairo_set_font_options (cr, cafont->options); + + return TRUE; } static cairo_font_face_t * @@ -142,36 +144,53 @@ pango_cairo_atsui_font_get_glyph_extents (PangoFont *font, PangoRectangle *logical_rect) { cairo_scaled_font_t *scaled_font; + cairo_font_extents_t font_extents; cairo_text_extents_t extents; cairo_glyph_t cairo_glyph; scaled_font = pango_cairo_atsui_font_get_scaled_font (PANGO_CAIRO_FONT (font)); + if (logical_rect) + cairo_scaled_font_extents (scaled_font, &font_extents); + cairo_glyph.index = glyph; cairo_glyph.x = 0; cairo_glyph.y = 0; - cairo_scaled_font_glyph_extents (scaled_font, - &cairo_glyph, 1, &extents); - - if (ink_rect) + if (glyph != PANGO_GLYPH_EMPTY) { - ink_rect->x = extents.x_bearing * PANGO_SCALE; - ink_rect->y = extents.y_bearing * PANGO_SCALE; - ink_rect->width = extents.width * PANGO_SCALE; - ink_rect->height = extents.height * PANGO_SCALE; + cairo_scaled_font_glyph_extents (scaled_font, + &cairo_glyph, 1, &extents); + + if (ink_rect) + { + ink_rect->x = extents.x_bearing * PANGO_SCALE; + ink_rect->y = extents.y_bearing * PANGO_SCALE; + ink_rect->width = extents.width * PANGO_SCALE; + ink_rect->height = extents.height * PANGO_SCALE; + } + + if (logical_rect) + { + logical_rect->x = 0; + logical_rect->y = - font_extents.ascent * PANGO_SCALE; + logical_rect->width = extents.x_advance * PANGO_SCALE; + logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE; + } } - - if (logical_rect) + else { - cairo_font_extents_t font_extents; - - cairo_scaled_font_extents (scaled_font, &font_extents); - - logical_rect->x = 0; - logical_rect->y = - font_extents.ascent * PANGO_SCALE; - logical_rect->width = extents.x_advance * PANGO_SCALE; - logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE; + if (ink_rect) + { + ink_rect->x = ink_rect->y = ink_rect->width = ink_rect->height = 0; + } + if (logical_rect) + { + logical_rect->x = 0; + logical_rect->y = - font_extents.ascent * PANGO_SCALE; + logical_rect->width = 0; + logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE; + } } } |