7158350: [macosx] Strange results of SwingUIText printing
authorjgodinez
Tue, 25 Sep 2012 09:18:27 -0700
changeset 13983 0c34ee8d36fc
parent 13769 ba52da5186ad
child 13984 390e11b8af80
7158350: [macosx] Strange results of SwingUIText printing Reviewed-by: bae, prr
jdk/src/macosx/native/sun/awt/CTextPipe.m
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Mon Sep 17 13:44:07 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Tue Sep 25 09:18:27 2012 -0700
@@ -142,8 +142,11 @@
     // get our baseline transform and font
     CGContextRef cgRef = qsdo->cgRef;
     CGAffineTransform ctmText = CGContextGetTextMatrix(cgRef);
-    //CGFontRef cgFont = CGContextGetFont(cgRef);
 
+    /* Save and restore of graphics context is done before the iteration.  
+       This seems to work using our test case (see bug ID 7158350) so we are restoring it at
+       the end of the for loop.  If we find out that save/restore outside the loop
+       doesn't work on all cases then we will move the Save/Restore inside the loop.*/
     CGContextSaveGState(cgRef);
     CGAffineTransform invTx = CGAffineTransformInvert(strike->fTx);
 
@@ -210,13 +213,9 @@
         pt.x += advances[i].width;
         pt.y += advances[i].height;
 
-        // reset the font on the context after striking a unicode with CoreText
-        if (uniChar != 0)
-        {
-           // CGContextSetFont(cgRef, cgFont);
-            CGContextSaveGState(cgRef);
-        }
     }
+    // reset the font on the context after striking a unicode with CoreText
+    CGContextRestoreGState(cgRef);
 }
 
 // Using the Quartz Surface Data context, draw a hot-substituted character run