summaryrefslogtreecommitdiff
path: root/pango/pangox.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-12-07 04:21:10 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-12-07 04:21:10 +0000
commit5aa7dd3136efec76b577b65cbc6962728f3f66bf (patch)
treebede1a2ae813b6bda2b771053142a2ad150f0193 /pango/pangox.c
parent15fd900199bde756a7d3779549c24e971919e4da (diff)
downloadpango-5aa7dd3136efec76b577b65cbc6962728f3f66bf.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)
Diffstat (limited to 'pango/pangox.c')
-rw-r--r--pango/pangox.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/pango/pangox.c b/pango/pangox.c
index d45f9780..cca2e278 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;
}
}