Index: C:/repository/Qt48/qt/src/opengl/qgl.cpp =================================================================== --- C:/repository/Qt48/qt/src/opengl/qgl.cpp (revision 3159) +++ C:/repository/Qt48/qt/src/opengl/qgl.cpp (revision 3160) @@ -1744,8 +1744,6 @@ workaround_brokenTextureFromPixmap_init = false; workaround_brokenScissor = false; - workaround_brokenAlphaTexSubImage = false; - workaround_brokenAlphaTexSubImage_init = false; for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i) vertexAttributeArraysEnabledState[i] = false; Index: C:/repository/Qt48/qt/src/opengl/qgl_p.h =================================================================== --- C:/repository/Qt48/qt/src/opengl/qgl_p.h (revision 3159) +++ C:/repository/Qt48/qt/src/opengl/qgl_p.h (revision 3160) @@ -429,8 +429,6 @@ uint workaround_brokenTextureFromPixmap_init : 1; uint workaround_brokenScissor : 1; - uint workaround_brokenAlphaTexSubImage : 1; - uint workaround_brokenAlphaTexSubImage_init : 1; #ifndef QT_NO_EGL uint ownsEglContext : 1; Index: C:/repository/Qt48/qt/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp =================================================================== --- C:/repository/Qt48/qt/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp (revision 3158) +++ C:/repository/Qt48/qt/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp (revision 3159) @@ -335,23 +335,25 @@ // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a // multiple of four bytes per line, and most of the glyph shows up correctly in the // texture, which makes me think that this is a driver bug. - // One workaround is to make sure the mask width is a multiple of four bytes, for instance - // by converting it to a format with four bytes per pixel. Another is to copy one line at a - // time. - - if (!ctx->d_ptr->workaround_brokenAlphaTexSubImage_init) { - // don't know which driver versions exhibit this bug, so be conservative for now - const QByteArray versionString(reinterpret_cast(glGetString(GL_VERSION))); - ctx->d_ptr->workaround_brokenAlphaTexSubImage = versionString.indexOf("NVIDIA") >= 0; - ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true; + // The solution to this is to upload larger glyphs with a glyph width of a multiple of 4, + // since QImage contains the padding bytes anyways. We need to fill the padding bytes with 0 + // and afterwards we can upload the glyph mask with a multiple of 4 width. + + // fill the padding bytes with 0 (QImage seems to have 0xff as default padding value) + quint8* data = mask.bits(); + int modulo = maskWidth%4; + int paddingBytes = 0; + if (modulo>0) { + paddingBytes = 4-modulo; + for (int i = 0; i < maskHeight; ++i) { + data += maskWidth; + for (int j = 0;jd_ptr->workaround_brokenAlphaTexSubImage) { - for (int i = 0; i < maskHeight; ++i) - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i)); - } else { - glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); - } + // upload the mask with a glyph width that is the next multiple of 4 + glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth + paddingBytes, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits()); } }