Index: unx/source/gdi/salgdi3.cxx
===================================================================
RCS file: /cvs/gsl/vcl/unx/source/gdi/salgdi3.cxx,v
retrieving revision 1.143
diff -u -3 -p -u -w -r1.143 salgdi3.cxx
--- vcl/unx/source/gdi/salgdi3.cxx	21 Dec 2006 12:05:00 -0000	1.143
+++ vcl/unx/source/gdi/salgdi3.cxx	8 Feb 2007 15:18:55 -0000
@@ -737,16 +737,33 @@ ConvertTextItem16( XTextItem16* pTextIte
 void X11SalGraphics::DrawServerAAFontString( const ServerFontLayout& rLayout )
 {
     Display* pDisplay = GetXDisplay();
-    Visual* pVisual = GetDisplay()->GetVisual( m_nScreen ).GetVisual();
-    X11GlyphPeer& rGlyphPeer = X11GlyphCache::GetInstance().GetPeer();
     XRenderPeer& rRenderPeer = XRenderPeer::GetInstance();
-    XRenderPictFormat* pVisualFormat = rRenderPeer.FindVisualFormat( pVisual );
+    XRenderPictFormat* pVisualFormat = NULL;
 
-    // create xrender Picture for font foreground
-    int nVisualDepth = pVisualFormat ? pVisualFormat->depth : GetDisplay()->GetVisual(m_nScreen).GetDepth();
+    // find a XRenderPictFormat compatible with the Drawable
+    if( GetXRenderFormat() )
+    {
+        pVisualFormat = (XRenderPictFormat*)GetXRenderFormat();
+    }
+    else
+    {
+	Visual* pVisual = GetDisplay()->GetVisual( m_nScreen ).GetVisual();
+        pVisualFormat = rRenderPeer.FindVisualFormat( pVisual );
+        // cache the XRenderPictFormat
+        SetXRenderFormat( (void*)pVisualFormat );
+    }
+
+    DBG_ASSERT( pVisualFormat!=NULL, "no matching XRenderPictFormat for text" );
+    if( !pVisualFormat )
+	    return;
+    
+    // get a XRenderPicture for the font foreground
+    const int nVisualDepth = pVisualFormat->depth;
     SalDisplay::RenderEntry& rEntry = GetDisplay()->GetRenderEntries( m_nScreen )[ nVisualDepth ];
     if( !rEntry.m_aPicture )
     {
+        // create and cache XRenderPicture for the font foreground
+#ifdef DEBUG
         int iDummy;
         unsigned uDummy;
         XLIB_Window wDummy;
@@ -754,6 +771,8 @@ void X11SalGraphics::DrawServerAAFontStr
         ::XGetGeometry( pDisplay, hDrawable_, &wDummy, &iDummy, &iDummy,
                       &uDummy, &uDummy, &uDummy, &nDrawDepth );
         DBG_ASSERT( static_cast<unsigned>(nVisualDepth) == nDrawDepth, "depth messed up for XRender" );
+#endif
+
         rEntry.m_aPixmap = ::XCreatePixmap( pDisplay, hDrawable_, 1, 1, nVisualDepth );
 
         XRenderPictureAttributes aAttr;
@@ -783,6 +802,7 @@ void X11SalGraphics::DrawServerAAFontStr
         rRenderPeer.SetPictureClipRegion( aDst, pClipRegion_ );
 
     ServerFont& rFont = rLayout.GetServerFont();
+    X11GlyphPeer& rGlyphPeer = X11GlyphCache::GetInstance().GetPeer();
     GlyphSet aGlyphSet = rGlyphPeer.GetGlyphSet( rFont, m_nScreen );
 
     Point aPos;
