@@ -223,12 +223,6 @@ void JavaCT_BreakupUnicodeIntoSurrogatePairs(int uniChar, UTF16Char charRef[]) {
223223// Using the Quartz Surface Data context, draw a hot-substituted character run
224224void JavaCT_DrawTextUsingQSD (JNIEnv *env, const QuartzSDOps *qsdo, const AWTStrike *strike, const jchar *chars, const jsize length)
225225{
226- NSAttributedString *attribString = nil ;
227- CTTypesetterRef typeSetterRef = NULL ;
228- CTLineRef lineRef = NULL ;
229-
230- JNI_COCOA_ENTER (env);
231-
232226 CGContextRef cgRef = qsdo->cgRef ;
233227
234228 AWTFont *awtFont = strike->fAWTFont ;
@@ -257,18 +251,20 @@ render using the right font (see bug 7183516) when attribString is not
257251
258252 CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedStringAndOptions((CFAttributedStringRef) attribString, (CFDictionaryRef) ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle)));
259253 */
260- attribString = [[NSAttributedString alloc ]
254+ NSAttributedString * attribString = [[NSAttributedString alloc ]
261255 initWithString: string
262256 attributes: ctsDictionaryFor (nsFont, JRSFontStyleUsesFractionalMetrics (strike->fStyle))];
263257
264- typeSetterRef = CTTypesetterCreateWithAttributedString ((CFAttributedStringRef) attribString);
258+ CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedString ((CFAttributedStringRef) attribString);
265259
266260 CFRange range = {0 , length};
267- lineRef = CTTypesetterCreateLine (typeSetterRef, range);
261+ CTLineRef lineRef = CTTypesetterCreateLine (typeSetterRef, range);
268262
269263 CTLineDraw (lineRef, cgRef);
270264
271- JNI_COCOA_EXIT_WITH_ACTION (env, ( [attribString release ], CFRelease_even_NULL (lineRef), CFRelease_even_NULL (typeSetterRef) ) );
265+ [attribString release ];
266+ CFRelease (lineRef);
267+ CFRelease (typeSetterRef);
272268}
273269
274270
@@ -284,16 +280,16 @@ render using the right font (see bug 7183516) when attribString is not
284280 return ;
285281 }
286282
287- JNI_COCOA_ENTER (env);
288-
289283 qsdo->BeginSurface (env, qsdo, SD_Text);
290284 if (qsdo->cgRef == NULL )
291285 {
286+ qsdo->FinishSurface (env, qsdo);
292287 return ;
293288 }
294289
295290 CGContextRef cgRef = qsdo->cgRef ;
296291
292+
297293 CGContextSaveGState (cgRef);
298294 JRSFontSetRenderingStyleOnContext (cgRef, strike->fStyle );
299295
@@ -307,7 +303,7 @@ render using the right font (see bug 7183516) when attribString is not
307303
308304 CGContextRestoreGState (cgRef);
309305
310- JNI_COCOA_RENDERER_EXIT (env);
306+ qsdo-> FinishSurface (env, qsdo );
311307}
312308
313309#pragma mark --- Glyph Vector Pipeline ---
@@ -532,34 +528,40 @@ render using the right font (see bug 7183516) when attribString is not
532528 CGSize advances[length];
533529 doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers (env, qsdo, strike, gVector , glyphs, uniChars, advances, length, glyphsArray);
534530 }
535- else {
536- CGGlyph *glyphs = NULL ;
537- int *uniChars = NULL ;
538- CGSize *advances = NULL ;
539- @try {
540- // otherwise, we should malloc and free buffers for this large run
541- glyphs = (CGGlyph *)malloc (sizeof (CGGlyph) * length);
542- uniChars = (int *) malloc (sizeof (int ) * length);
543- advances = (CGSize *) malloc (sizeof (CGSize) * length);
531+ else
532+ {
533+ // otherwise, we should malloc and free buffers for this large run
534+ CGGlyph *glyphs = (CGGlyph *)malloc (sizeof (CGGlyph) * length);
535+ int *uniChars = (int *)malloc (sizeof (int ) * length);
536+ CGSize *advances = (CGSize *)malloc (sizeof (CGSize) * length);
544537
545- if ((glyphs == NULL ) || (uniChars == NULL ) || (advances == NULL )) {
546- [NSException raise: NSMallocException format: @" allocation failure (%s :%d %s )" , __FILE__, __LINE__, __FUNCTION__];
547- } else {
548- doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers (env, qsdo, strike, gVector , glyphs, uniChars, advances, length, glyphsArray);
549- }
550- } @finally {
551- if (glyphs != NULL ) {
538+ if (glyphs == NULL || uniChars == NULL || advances == NULL )
539+ {
540+ (*env)->DeleteLocalRef (env, glyphsArray);
541+ [NSException raise: NSMallocException format: @" %s -%s :%d " , __FILE__, __FUNCTION__, __LINE__];
542+ if (glyphs)
543+ {
552544 free (glyphs);
553545 }
554- if (uniChars != NULL ) {
546+ if (uniChars)
547+ {
555548 free (uniChars);
556549 }
557- if (advances != NULL ) {
550+ if (advances)
551+ {
558552 free (advances);
559553 }
560- (*env)-> DeleteLocalRef (env, glyphsArray) ;
554+ return ;
561555 }
556+
557+ doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers (env, qsdo, strike, gVector , glyphs, uniChars, advances, length, glyphsArray);
558+
559+ free (glyphs);
560+ free (uniChars);
561+ free (advances);
562562 }
563+
564+ (*env)->DeleteLocalRef (env, glyphsArray);
563565}
564566
565567// Setup and save the state of the CGContext, and apply any java.awt.Font transforms to the context.
0 commit comments