218 // Using the Quartz Surface Data context, draw a hot-substituted character run 219 void JavaCT_DrawTextUsingQSD(JNIEnv *env, const QuartzSDOps *qsdo, const AWTStrike *strike, const jchar *chars, const jsize length) 220 { 221 CGContextRef cgRef = qsdo->cgRef; 222 223 AWTFont *awtFont = strike->fAWTFont; 224 CGFloat ptSize = strike->fSize; 225 CGAffineTransform tx = strike->fFontTx; 226 227 NSFont *nsFont = [NSFont fontWithName:[awtFont->fFont fontName] size:ptSize]; 228 229 if (ptSize != 0) { 230 CGFloat invScale = 1 / ptSize; 231 tx = CGAffineTransformConcat(tx, CGAffineTransformMakeScale(invScale, invScale)); 232 CGContextConcatCTM(cgRef, tx); 233 } 234 235 CGContextSetTextMatrix(cgRef, CGAffineTransformIdentity); // resets the damage from CoreText 236 237 NSString *string = [NSString stringWithCharacters:chars length:length]; 238 NSAttributedString *attribString = [[NSAttributedString alloc] initWithString:string]; 239 240 CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedStringAndOptions((CFAttributedStringRef) attribString, (CFDictionaryRef) ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))); 241 242 CFRange range = {0, length}; 243 CTLineRef lineRef = CTTypesetterCreateLine(typeSetterRef, range); 244 245 CTLineDraw(lineRef, cgRef); 246 247 [attribString release]; 248 CFRelease(lineRef); 249 CFRelease(typeSetterRef); 250 } 251 252 253 /*---------------------- 254 DrawTextContext is the funnel for all of our CoreText drawing. 255 All three JNI apis call through this method. 256 ----------------------*/ 257 static void DrawTextContext 258 (JNIEnv *env, QuartzSDOps *qsdo, const AWTStrike *strike, const jchar *chars, const jsize length, const jdouble x, const jdouble y) 259 { 260 if (length == 0) | 218 // Using the Quartz Surface Data context, draw a hot-substituted character run 219 void JavaCT_DrawTextUsingQSD(JNIEnv *env, const QuartzSDOps *qsdo, const AWTStrike *strike, const jchar *chars, const jsize length) 220 { 221 CGContextRef cgRef = qsdo->cgRef; 222 223 AWTFont *awtFont = strike->fAWTFont; 224 CGFloat ptSize = strike->fSize; 225 CGAffineTransform tx = strike->fFontTx; 226 227 NSFont *nsFont = [NSFont fontWithName:[awtFont->fFont fontName] size:ptSize]; 228 229 if (ptSize != 0) { 230 CGFloat invScale = 1 / ptSize; 231 tx = CGAffineTransformConcat(tx, CGAffineTransformMakeScale(invScale, invScale)); 232 CGContextConcatCTM(cgRef, tx); 233 } 234 235 CGContextSetTextMatrix(cgRef, CGAffineTransformIdentity); // resets the damage from CoreText 236 237 NSString *string = [NSString stringWithCharacters:chars length:length]; 238 /* 239 The calls below were used previously but for unknown reason did not 240 render using the right font (see bug 7183516) when attribString is not 241 initialized with font dictionary attributes. It seems that "options" 242 in CTTypesetterCreateWithAttributedStringAndOptions which contains the 243 font dictionary is ignored. 244 245 NSAttributedString *attribString = [[NSAttributedString alloc] initWithString:string]; 246 247 CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedStringAndOptions((CFAttributedStringRef) attribString, (CFDictionaryRef) ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))); 248 */ 249 NSAttributedString *attribString = [[NSAttributedString alloc] 250 initWithString:string 251 attributes:ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))]; 252 253 CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedString((CFAttributedStringRef) attribString); 254 255 CFRange range = {0, length}; 256 CTLineRef lineRef = CTTypesetterCreateLine(typeSetterRef, range); 257 258 CTLineDraw(lineRef, cgRef); 259 260 [attribString release]; 261 CFRelease(lineRef); 262 CFRelease(typeSetterRef); 263 } 264 265 266 /*---------------------- 267 DrawTextContext is the funnel for all of our CoreText drawing. 268 All three JNI apis call through this method. 269 ----------------------*/ 270 static void DrawTextContext 271 (JNIEnv *env, QuartzSDOps *qsdo, const AWTStrike *strike, const jchar *chars, const jsize length, const jdouble x, const jdouble y) 272 { 273 if (length == 0) |