// Fix for 5045936, 5055171. While printing, g is an instance
// of sun.print.ProxyPrintGraphics which extends Graphics.
// So we use a separate buffered image and its graphics is
// always Graphics2D instance
X11GraphicsConfig graphicsConfig = (X11GraphicsConfig)(sb.getEventSource().getGraphicsConfiguration());
buffer = graphicsConfig.createCompatibleImage(width, height);
g2 = buffer.createGraphics();
useBufferedImage = true;
} else {
g2 = (Graphics2D)g;
}