changeset 6619:3bd0d3ec8839

8009199: Printed text become garbage on Mac OSX Reviewed-by: prr, bae
author jgodinez
date Fri, 07 Jun 2013 10:58:51 -0700
parents 504928f651c7
children a27ef05ab815
files src/macosx/native/sun/awt/CTextPipe.m
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/CTextPipe.m	Fri Jun 07 10:55:03 2013 -0700
+++ b/src/macosx/native/sun/awt/CTextPipe.m	Fri Jun 07 10:58:51 2013 -0700
@@ -139,6 +139,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
@@ -171,10 +173,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