@@ -2567,6 +2567,10 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2567
2567
#endif
2568
2568
CFRelease (string);
2569
2569
}
2570
+ if (font == NULL )
2571
+ {
2572
+ PyErr_SetString (PyExc_ValueError, " Could not load font" );
2573
+ }
2570
2574
#ifndef COMPILING_FOR_10_5
2571
2575
CGContextSelectFont (cr, name, size, kCGEncodingMacRoman );
2572
2576
#endif
@@ -2632,7 +2636,11 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2632
2636
CFStringRef s = CFStringCreateWithCharacters (kCFAllocatorDefault , text, n);
2633
2637
#endif
2634
2638
2635
- font = setfont (cr, family, size, weight, italic );
2639
+ if (!(font = setfont (cr, family, size, weight, italic )))
2640
+ {
2641
+ CFRelease (s);
2642
+ return NULL ;
2643
+ }
2636
2644
2637
2645
color = CGColorCreateGenericRGB (self->color [0 ],
2638
2646
self->color [1 ],
@@ -2739,7 +2747,11 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2739
2747
CFStringRef s = CFStringCreateWithCharacters (kCFAllocatorDefault , text, n);
2740
2748
#endif
2741
2749
2742
- font = setfont (cr, family, size, weight, italic );
2750
+ if (!(font = setfont (cr, family, size, weight, italic )))
2751
+ {
2752
+ CFRelease (s);
2753
+ return NULL ;
2754
+ };
2743
2755
2744
2756
CFStringRef keys[1 ];
2745
2757
CFTypeRef values[1 ];
@@ -2810,7 +2822,10 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2810
2822
&italic ,
2811
2823
&angle)) return NULL ;
2812
2824
2813
- atsfont = setfont (cr, family, size, weight, italic );
2825
+ if (!(atsfont = setfont (cr, family, size, weight, italic ))
2826
+ {
2827
+ return NULL ;
2828
+ }
2814
2829
2815
2830
OSStatus status;
2816
2831
@@ -2895,7 +2910,10 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2895
2910
2896
2911
if (!PyArg_ParseTuple (args, " u#Ofss" , &text, &n, &family, &size, &weight, &italic )) return NULL ;
2897
2912
2898
- atsfont = setfont (cr, family, size, weight, italic );
2913
+ if (!(atsfont = setfont (cr, family, size, weight, italic )))
2914
+ {
2915
+ return NULL ;
2916
+ }
2899
2917
2900
2918
OSStatus status = noErr ;
2901
2919
ATSUAttributeTag tags[] = {kATSUFontTag ,
0 commit comments