7183516: [macosx]Can't print-out the defined fonts for PrintFont_2D and AntialiasTableTest.
authorjgodinez
Mon, 10 Sep 2012 10:07:10 -0700
changeset 13766 0e523a5ed1af
parent 13646 e7ffcc2eb5fc
child 13767 5ea857776c3f
7183516: [macosx]Can't print-out the defined fonts for PrintFont_2D and AntialiasTableTest. Reviewed-by: bae, prr
jdk/src/macosx/native/sun/awt/CTextPipe.m
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Wed Sep 05 13:50:00 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Mon Sep 10 10:07:10 2012 -0700
@@ -235,9 +235,22 @@
     CGContextSetTextMatrix(cgRef, CGAffineTransformIdentity); // resets the damage from CoreText
 
     NSString *string = [NSString stringWithCharacters:chars length:length];
+    /*
+       The calls below were used previously but for unknown reason did not 
+       render using the right font (see bug 7183516) when attribString is not 
+       initialized with font dictionary attributes.  It seems that "options" 
+       in CTTypesetterCreateWithAttributedStringAndOptions which contains the 
+       font dictionary is ignored.
+
     NSAttributedString *attribString = [[NSAttributedString alloc] initWithString:string];
 
     CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedStringAndOptions((CFAttributedStringRef) attribString, (CFDictionaryRef) ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle)));
+    */
+    NSAttributedString *attribString = [[NSAttributedString alloc]
+        initWithString:string
+        attributes:ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))];
+    
+    CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedString((CFAttributedStringRef) attribString);
 
     CFRange range = {0, length};
     CTLineRef lineRef = CTTypesetterCreateLine(typeSetterRef, range);