From cd7abd927fb31b4d797c2504428ec498bcfa1da4 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Thu, 25 Apr 2013 10:14:24 -0700 Subject: [PATCH] 8009199: Printed text become garbage on Mac OSX Reviewed-by: bae, prr --- jdk/src/macosx/native/sun/awt/CTextPipe.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jdk/src/macosx/native/sun/awt/CTextPipe.m b/jdk/src/macosx/native/sun/awt/CTextPipe.m index 578bf9ca0e3..d9bf48afd92 100644 --- a/jdk/src/macosx/native/sun/awt/CTextPipe.m +++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m @@ -143,6 +143,8 @@ void JavaCT_DrawGlyphVector 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 @@ void JavaCT_DrawGlyphVector 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