diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-12-07 04:20:38 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-12-07 04:20:38 +0000 |
commit | 553dd547c3478c7d72158b45f27f26b6ec6bd015 (patch) | |
tree | fe344df4893e0c0c369086befe97bf9451815296 | |
parent | 5d1c45053a427f89aea2dc33c8cb3bfc4f5c652f (diff) | |
download | pango-553dd547c3478c7d72158b45f27f26b6ec6bd015.tar.gz |
Roughly clip glyphs into the X coordinate area to avoid wrap-around.
Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com>
* pango/pangoxft-font.c (pango_xft_real_render)
pango/pangox.c (pango_x_render): Roughly clip glyphs
into the X coordinate area to avoid wrap-around. (#73199)
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 6 | ||||
-rw-r--r-- | pango/pangox.c | 40 | ||||
-rw-r--r-- | pango/pangoxft-font.c | 26 |
8 files changed, 81 insertions, 21 deletions
@@ -1,3 +1,9 @@ +Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com> + + * pango/pangoxft-font.c (pango_xft_real_render) + pango/pangox.c (pango_x_render): Roughly clip glyphs + into the X coordinate area to avoid wrap-around. (#73199) + Fri Dec 6 17:56:32 2002 Owen Taylor <otaylor@redhat.com> * configure.in: Add missing thai-xft to thai-modules. diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 9a8f2e59..47fd7bba 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,9 @@ +Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com> + + * pango/pangoxft-font.c (pango_xft_real_render) + pango/pangox.c (pango_x_render): Roughly clip glyphs + into the X coordinate area to avoid wrap-around. (#73199) + Fri Dec 6 17:56:32 2002 Owen Taylor <otaylor@redhat.com> * configure.in: Add missing thai-xft to thai-modules. diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index 9a8f2e59..47fd7bba 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,9 @@ +Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com> + + * pango/pangoxft-font.c (pango_xft_real_render) + pango/pangox.c (pango_x_render): Roughly clip glyphs + into the X coordinate area to avoid wrap-around. (#73199) + Fri Dec 6 17:56:32 2002 Owen Taylor <otaylor@redhat.com> * configure.in: Add missing thai-xft to thai-modules. diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 9a8f2e59..47fd7bba 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,9 @@ +Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com> + + * pango/pangoxft-font.c (pango_xft_real_render) + pango/pangox.c (pango_x_render): Roughly clip glyphs + into the X coordinate area to avoid wrap-around. (#73199) + Fri Dec 6 17:56:32 2002 Owen Taylor <otaylor@redhat.com> * configure.in: Add missing thai-xft to thai-modules. diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 9a8f2e59..47fd7bba 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,9 @@ +Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com> + + * pango/pangoxft-font.c (pango_xft_real_render) + pango/pangox.c (pango_x_render): Roughly clip glyphs + into the X coordinate area to avoid wrap-around. (#73199) + Fri Dec 6 17:56:32 2002 Owen Taylor <otaylor@redhat.com> * configure.in: Add missing thai-xft to thai-modules. diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 9a8f2e59..47fd7bba 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,9 @@ +Fri Dec 6 23:07:58 2002 Owen Taylor <otaylor@redhat.com> + + * pango/pangoxft-font.c (pango_xft_real_render) + pango/pangox.c (pango_x_render): Roughly clip glyphs + into the X coordinate area to avoid wrap-around. (#73199) + Fri Dec 6 17:56:32 2002 Owen Taylor <otaylor@redhat.com> * configure.in: Add missing thai-xft to thai-modules. diff --git a/pango/pangox.c b/pango/pangox.c index d64d13fe..5021c9dc 100644 --- a/pango/pangox.c +++ b/pango/pangox.c @@ -491,21 +491,35 @@ pango_x_render (Display *display, for (i=0; i<glyphs->num_glyphs; i++) { - if (glyphs->glyphs[i].glyph & - PANGO_X_UNKNOWN_FLAG) + PangoGlyph glyph = glyphs->glyphs[i].glyph; + int glyph_x = x + PANGO_PIXELS (x_off + glyphs->glyphs[i].geometry.x_offset); + int glyph_y = y + PANGO_PIXELS (glyphs->glyphs[i].geometry.y_offset); + + /* Clip glyphs into the X coordinate range; we really + * want to clip glyphs with an ink rect outside the + * [0,32767] x [0,32767] rectangle but looking up + * the ink rect here would be a noticeable speed hit. + * This is close enough. + */ + if (!(glyph && + glyph_x >= -16384 && glyph_x <= 32767 && + glyph_y >= -16384 && glyph_y <= 32767)) + goto next_glyph; + + if (glyph & PANGO_X_UNKNOWN_FLAG) { PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL); int x1, y1, x2, y2; /* rectangle the character should go inside. */ int baseline; gunichar wc; - x1 = x + (x_off + glyphs->glyphs[i].geometry.x_offset) / PANGO_SCALE; - y1 = y + (glyphs->glyphs[i].geometry.y_offset - metrics->ascent) / PANGO_SCALE; - x2 = x1 + glyphs->glyphs[i].geometry.width / PANGO_SCALE; - y2 = y1 + (metrics->ascent + metrics->descent) / PANGO_SCALE; - baseline = y1 + metrics->ascent / PANGO_SCALE; + x1 = glyph_x; + y1 = glyph_y - PANGO_PIXELS (metrics->ascent); + x2 = x1 + PANGO_PIXELS (glyphs->glyphs[i].geometry.width); + y2 = y1 + PANGO_PIXELS (metrics->ascent + metrics->descent); + baseline = glyph_y; - wc = glyphs->glyphs[i].glyph & (~PANGO_X_UNKNOWN_FLAG); + wc = glyph & (~PANGO_X_UNKNOWN_FLAG); switch (wc) { @@ -576,10 +590,10 @@ pango_x_render (Display *display, pango_font_metrics_unref (metrics); } - else if (glyphs->glyphs[i].glyph) + else { - guint16 index = PANGO_X_GLYPH_INDEX (glyphs->glyphs[i].glyph); - guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyphs->glyphs[i].glyph); + guint16 index = PANGO_X_GLYPH_INDEX (glyph); + guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyph); PangoXSubfontInfo *subfont; XChar2b c; @@ -601,12 +615,12 @@ pango_x_render (Display *display, } XDrawString16 (display, d, gc, - x + (x_off + glyphs->glyphs[i].geometry.x_offset) / PANGO_SCALE, - y + glyphs->glyphs[i].geometry.y_offset / PANGO_SCALE, + glyph_x, glyph_y, &c, 1); } } + next_glyph: x_off += glyphs->glyphs[i].geometry.width; } } diff --git a/pango/pangoxft-font.c b/pango/pangoxft-font.c index b76070c7..edd1c6b2 100644 --- a/pango/pangoxft-font.c +++ b/pango/pangoxft-font.c @@ -275,8 +275,18 @@ pango_xft_real_render (Display *display, for (i=0; i<glyphs->num_glyphs; i++) { PangoGlyph glyph = glyphs->glyphs[i].glyph; - - if (glyph) + int glyph_x = x + PANGO_PIXELS (x_off + glyphs->glyphs[i].geometry.x_offset); + int glyph_y = y + PANGO_PIXELS (glyphs->glyphs[i].geometry.y_offset); + + /* Clip glyphs into the X coordinate range; we really + * want to clip glyphs with an ink rect outside the + * [0,32767] x [0,32767] rectangle but looking up + * the ink rect here would be a noticeable speed hit. + * This is close enough. + */ + if (glyph && + glyph_x >= -16384 && glyph_x <= 32767 && + glyph_y >= -16384 && glyph_y <= 32767) { if (glyph & PANGO_XFT_UNKNOWN_FLAG) { @@ -291,11 +301,11 @@ pango_xft_real_render (Display *display, glyph &= ~PANGO_XFT_UNKNOWN_FLAG; - ys[0] = y + PANGO_PIXELS (glyphs->glyphs[i].geometry.y_offset) - xft_font->ascent + (xft_font->ascent + xft_font->descent - xfont->mini_height * 2 - xfont->mini_pad * 5) / 2; + ys[0] = glyph_y - xft_font->ascent + (xft_font->ascent + xft_font->descent - xfont->mini_height * 2 - xfont->mini_pad * 5) / 2; ys[1] = ys[0] + 2 * xfont->mini_pad + xfont->mini_height; ys[2] = ys[1] + xfont->mini_height + xfont->mini_pad; - xs[0] = x + PANGO_PIXELS (x_off + glyphs->glyphs[i].geometry.x_offset); + xs[0] = glyph_x; xs[1] = xs[0] + 2 * xfont->mini_pad; xs[2] = xs[1] + xfont->mini_width + xfont->mini_pad; @@ -323,13 +333,13 @@ pango_xft_real_render (Display *display, { if (draw) XftDrawString32 (draw, color, xft_font, - x + PANGO_PIXELS (x_off + glyphs->glyphs[i].geometry.x_offset), - y + PANGO_PIXELS (glyphs->glyphs[i].geometry.y_offset), + glyph_x, + glyph_y, &glyph, 1); else XftRenderString32 (display, src_picture, xft_font->u.ft.font, dest_picture, 0, 0, - x + PANGO_PIXELS (x_off + glyphs->glyphs[i].geometry.x_offset), - y + PANGO_PIXELS (glyphs->glyphs[i].geometry.y_offset), + glyph_x, + glyph_y, &glyph, 1); } } |