changeset 17139:03ba8665f3e3

8009199: Printed text become garbage on Mac OSX Reviewed-by: bae, prr
author jgodinez
date Thu, 25 Apr 2013 10:14:24 -0700
parents 84be5bed2ea1
children d7bd09ae1752
files jdk/src/macosx/native/sun/awt/CTextPipe.m
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Tue Apr 23 09:28:19 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Thu Apr 25 10:14:24 2013 -0700
@@ -143,6 +143,8 @@
     CGContextRef cgRef = qsdo->cgRef;
     CGAffineTransform ctmText = CGContextGetTextMatrix(cgRef);
 
+    BOOL saved = false;
+
     /* 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
@@ -175,10 +177,19 @@
                 CFRelease(fallback);
 
                 if (cgFallback) {
+                    if (!saved) {
+                        CGContextSaveGState(cgRef);
+                        saved = true;
+                    }
                     CGContextSetFont(cgRef, cgFallback);
                     CFRelease(cgFallback);
                 }
             }
+        } else {
+            if (saved) {
+                CGContextRestoreGState(cgRef);
+                saved = false;
+            }
         }
 
         // if we have per-glyph transformations