11
11
#define PY3K 0
12
12
#endif
13
13
14
+ #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >=3)
15
+ #define PY33 1
16
+ #else
17
+ #define PY33 0
18
+ #endif
19
+
14
20
/* Must define Py_TYPE for Python 2.5 or older */
15
21
#ifndef Py_TYPE
16
22
# define Py_TYPE (o ) ((o)->ob_type)
@@ -2546,6 +2552,11 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2546
2552
CTFontRef font;
2547
2553
CGColorRef color;
2548
2554
CGFloat descent;
2555
+ #if PY33
2556
+ const char * text;
2557
+ #else
2558
+ const UniChar* text;
2559
+ #endif
2549
2560
2550
2561
CFStringRef keys[2 ];
2551
2562
CFTypeRef values[2 ];
@@ -2556,7 +2567,7 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2556
2567
PyErr_SetString (PyExc_RuntimeError, " CGContextRef is NULL" );
2557
2568
return NULL ;
2558
2569
}
2559
-
2570
+ # if PY33
2560
2571
if (!PyArg_ParseTuple (args, " ffs#Ofssf" ,
2561
2572
&x,
2562
2573
&y,
@@ -2568,6 +2579,19 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2568
2579
&italic,
2569
2580
&angle)) return NULL ;
2570
2581
CFStringRef s = CFStringCreateWithCString (kCFAllocatorDefault , text, kCFStringEncodingUTF8 );
2582
+ #else
2583
+ if (!PyArg_ParseTuple (args, " ffu#Ofssf" ,
2584
+ &x,
2585
+ &y,
2586
+ &text,
2587
+ &n,
2588
+ &family,
2589
+ &size,
2590
+ &weight,
2591
+ &italic,
2592
+ &angle)) return NULL ;
2593
+ CFStringRef s = CFStringCreateWithCharacters (kCFAllocatorDefault , text, n);
2594
+ #endif
2571
2595
2572
2596
font = setfont (cr, family, size, weight, italic);
2573
2597
@@ -2636,6 +2660,11 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2636
2660
const char * text;
2637
2661
const char * weight;
2638
2662
const char * italic;
2663
+ #if PY33
2664
+ const char * text;
2665
+ #else
2666
+ const UniChar* text;
2667
+ #endif
2639
2668
2640
2669
CGFloat ascent;
2641
2670
CGFloat descent;
@@ -2651,6 +2680,7 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2651
2680
return NULL ;
2652
2681
}
2653
2682
2683
+ #if PY33
2654
2684
if (!PyArg_ParseTuple (args, " s#Ofss" ,
2655
2685
&text,
2656
2686
&n,
@@ -2659,6 +2689,16 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
2659
2689
&weight,
2660
2690
&italic)) return NULL ;
2661
2691
CFStringRef s = CFStringCreateWithCString (kCFAllocatorDefault , text, kCFStringEncodingUTF8 );
2692
+ #else
2693
+ if (!PyArg_ParseTuple (args, " u#Ofss" ,
2694
+ &
A3FF
;text,
2695
+ &n,
2696
+ &family,
2697
+ &size,
2698
+ &weight,
2699
+ &italic)) return NULL ;
2700
+ CFStringRef s = CFStringCreateWithCharacters (kCFAllocatorDefault , text, n);
2701
+ #endif
2662
2702
2663
2703
font = setfont (cr, family, size, weight, italic);
2664
2704
@@ -4902,7 +4942,7 @@ -(void)save_figure:(id)sender
4902
4942
unsigned int n = [filename length ];
4903
4943
unichar * buffer = malloc (n*sizeof (unichar ));
4904
4944
[filename getCharacters: buffer];
4905
- #if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)
4945
+ #if PY33
4906
4946
PyObject* string = PyUnicode_FromKindAndData (PyUnicode_2BYTE_KIND, buffer, n);
4907
4947
#else
4908
4948
PyObject* string = PyUnicode_FromUnicode (buffer, n);
0 commit comments