From 82854aa9a0dc637633118b7282fc5bb2c824809c Mon Sep 17 00:00:00 2001 From: asac Date: Mon, 12 Mar 2007 16:37:18 +0100 Subject: [PATCH] bz252033-gtk2-xft-text-clipping-problem Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bug 252033 – gtk2+xft text clipping problem: only first word of line is rendered, rest of text displays on mouseover -> https://bugzilla.mozilla.org/attachment.cgi?id=193199 --- gfx/src/gtk/nsFontMetricsXft.cpp | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gfx/src/gtk/nsFontMetricsXft.cpp b/gfx/src/gtk/nsFontMetricsXft.cpp index 4a79c19..4c8ac2f 100644 --- a/gfx/src/gtk/nsFontMetricsXft.cpp +++ b/gfx/src/gtk/nsFontMetricsXft.cpp @@ -2199,19 +2199,27 @@ void nsAutoDrawSpecBuffer::Flush() { if (mSpecPos) { - // Some Xft libraries will crash if none of the glyphs have any - // area. So before we draw, we scan through the glyphs. If we - // find any that have area, we can draw. - for (PRUint32 i = 0; i < mSpecPos; i++) { - XftGlyphFontSpec *sp = &mSpecBuffer[i]; - XGlyphInfo info; - XftGlyphExtents(GDK_DISPLAY(), sp->font, &sp->glyph, 1, &info); - if (info.width && info.height) { - // If we get here it means we found a drawable glyph. We will - // Draw all the remaining glyphs and then break out of the loop - XftDrawGlyphFontSpec(mDraw, mColor, mSpecBuffer+i, mSpecPos-i); - break; + // There are two Xft problems to work around here: + // 1. Some Xft libraries reportedly crash if none of the + // glyphs have any area. + // 2. Because of an apparent X server bug (see bug 252033), + // a glyph with no area may cause all following glyphs to be + // dropped under some circumstances. + // For this reason, we manually ship out blocks of glyphs with + // area and skip blocks of glyphs with no area. + PRUint32 start = 0; + while (start < mSpecPos) { + PRUint32 i; + for (i = start; i < mSpecPos; i++) { + XftGlyphFontSpec *sp = &mSpecBuffer[i]; + XGlyphInfo info; + XftGlyphExtents(GDK_DISPLAY(), sp->font, &sp->glyph, 1, &info); + if (!info.width || !info.height) + break; } + if (i > start) + XftDrawGlyphFontSpec(mDraw, mColor, mSpecBuffer+start, i-start); + start = i + 1; } mSpecPos = 0; } -- 1.4.4.4