The R Project SVN R

Rev

Rev 28254 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28254 Rev 28362
Line 46... Line 46...
46
242, 243, 134,  32,  32, 167, 136, 135, 137, 139,
46
242, 243, 134,  32,  32, 167, 136, 135, 137, 139,
47
138, 140, 190, 141, 143, 142, 144, 145, 147, 146,
47
138, 140, 190, 141, 143, 142, 144, 145, 147, 146,
48
148, 149,  32, 150, 152, 151, 153, 155, 154, 214, 
48
148, 149,  32, 150, 152, 151, 153, 155, 154, 214, 
49
191, 157, 156, 158, 159,  32,  32, 216};
49
191, 157, 156, 158, 159,  32,  32, 216};
50
 
50
 
-
 
51
#define MAX_NON_SYMBS 17
-
 
52
unsigned char NotSymbols[] = {
-
 
53
 32, 33, 37, 38, 40, 41, 42, 43, 44, 58, 
-
 
54
 60, 61, 62, 91, 93, 95, 123, 125
-
 
55
};
-
 
56
 
-
 
57
/* conversion table to use symbol font enoded as
-
 
58
   unicode under MacOSX and no longer MacRoman
-
 
59
*/
-
 
60
unsigned char Lat2Uni[] = { 
-
 
61
    32, /* space */
-
 
62
	33, /* exclam */
-
 
63
    34, /* universal" */
-
 
64
	35, /* numbersign */
-
 
65
   154, /* existential */
-
 
66
	37, /* percent */
-
 
67
	38, /* ampersand */
-
 
68
	39, /* suchthat */
-
 
69
    40, /* parenleft */
-
 
70
    41, /* parenright */
-
 
71
   155, /* asteriskmath */
-
 
72
	 3, /* plus */
-
 
73
	44, /* comma */
-
 
74
	60, /* minus */
-
 
75
	46, /* period */
-
 
76
	58, /* slash*/
-
 
77
	48, /* 0 */
-
 
78
	49, /* 1 */
-
 
79
	50, /* 2 */
-
 
80
	51, /* 3 */
-
 
81
	52, /* 4 */
-
 
82
	53, /* 5 */
-
 
83
	54, /* 6 */
-
 
84
	55, /* 7 */
-
 
85
	56, /* 8 */
-
 
86
	57, /* 9 */
-
 
87
    58, /* colon */
-
 
88
	59, /* semicolon */
-
 
89
	60, /* less */
-
 
90
	62, /* equal */
-
 
91
	62, /* greater */
-
 
92
	63, /* question */
-
 
93
   129, /* congruent */
-
 
94
    73, /* Alpha */
-
 
95
	74, /* Beta */
-
 
96
	93, /* Chi */
-
 
97
	54, /* Delta */
-
 
98
	76, /* Epsilon */
-
 
99
	92, /* Phi */
-
 
100
	75, /* Gamma */
-
 
101
	78, /* Eta */
-
 
102
	80, /* Iota */
-
 
103
	85, /* theta1 */
-
 
104
	81, /* Kappa */
-
 
105
	82, /* Lambda */
-
 
106
	83, /* Mu */
-
 
107
	84, /* Nu */
-
 
108
	86, /* Omicron */
-
 
109
	87, /* Pi */
-
 
110
	79, /* Theta */
-
 
111
	88, /* Rho */
-
 
112
	89, /* Sigma */
-
 
113
	90, /* Tau */
-
 
114
	91, /* Upsilon */
-
 
115
	45, /* sigma1 */
-
 
116
	49, /* Omega */
-
 
117
	93, /* Xi */
-
 
118
	94, /* Psi */
-
 
119
	77, /* Zeta */
-
 
120
	33, /* bracketleft */  /* Miscellaneous Special Characters */
-
 
121
    92, /* therefore */
-
 
122
	35, /* bracketright */
-
 
123
   140, /* perpendicular */
-
 
124
	32, /* underscore */
-
 
125
	51, /* radicalex */
-
 
126
 95, /* alpha */
-
 
127
 96, /* beta */
-
 
128
114, /* chi */
-
 
129
 98, /* delta */
-
 
130
 161, /* epsilon */
-
 
131
 113, /* phi */
-
 
132
 97, /* gamma */
-
 
133
 100, /* eta */
-
 
134
 102, /* iota */
-
 
135
 160, /* phi1 */
-
 
136
 103, /* kappa */
-
 
137
 104, /* lambda */
-
 
138
  43, /* mu */
-
 
139
 105, /* nu */
-
 
140
 107, /* omicron */
-
 
141
 47, /* pi */
-
 
142
 101, /* theta */
-
 
143
 108, /* rho */
-
 
144
 109, /* sigma */
-
 
145
 111, /* tau */
-
 
146
 112, /* upsilon */
-
 
147
 159, /* omega1 */
-
 
148
 116, /* omega */
-
 
149
 106, /* xi */
-
 
150
 115, /* psi */
-
 
151
 110, /* zeta */
-
 
152
 123, /* braceleft */
-
 
153
 180, /* bar */
-
 
154
 125, /* braceright */
-
 
155
 126, /* similar */
-
 
156
 32, 32, 32, 32, 
-
 
157
 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-
 
158
 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-
 
159
 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
-
 
160
 175, /* Upsilon1 */	/* Lone Greek */
-
 
161
 118, /* minute */
-
 
162
  41, /* lessequal */
-
 
163
 177, /* fraction */
-
 
164
  39, /* infinity */
-
 
165
 166, /* florin      ??? */
-
 
166
 121, /* club */
-
 
167
 122, /* diamond */
-
 
168
 120, /* heart */
-
 
169
 123, /* spade */
-
 
170
  67, /* arrowboth */
-
 
171
  64, /* arrowleft */
-
 
172
  66, /* arrowup */
-
 
173
  65, /* arrowright */
-
 
174
  63, /* arrowdown */
-
 
175
  36, /* degree */
-
 
176
  40, /* plusminus */
-
 
177
 119, /* second */
-
 
178
  42, /* greaterequal */
-
 
179
 155, /* multiply */
-
 
180
 124, /* proportional */
-
 
181
  44, /* partialdiff */
-
 
182
  20, /* bullet */
-
 
183
  56, /* divide */
-
 
184
  38, /* notequal */
-
 
185
  62, /* equivalence */
-
 
186
  53, /* approxequal ??? */
-
 
187
  55, /* ellipsis    ??? */
-
 
188
 189, /* arrowvertex ??? */ 
-
 
189
 190, /* arrowhorizex ??? */
-
 
190
 191, /* carriagereturn */
-
 
191
 148, /* aleph */
-
 
192
 188, /* Ifraktur */
-
 
193
 189, /* Rfraktur */
-
 
194
 195, /* weierstrass ??? */
-
 
195
 128, /* circlemultiply */
-
 
196
 127, /* circleplus */
-
 
197
 146, /* emptyset */
-
 
198
  69, /* intersection */
-
 
199
  70, /* union */
-
 
200
 130, /* propersuperset */
-
 
201
 131, /* reflexsuperset */
-
 
202
 134, /* notsubset */
-
 
203
 132, /* propersubset */
-
 
204
 133, /* reflexsubset */
-
 
205
  68, /* element */
-
 
206
 141, /* notelement */
-
 
207
 144, /* angle */
-
 
208
 162, /* gradient */
-
 
209
 186, /* registerserif */
-
 
210
 185, /* copyrightserif */
-
 
211
 184, /* trademarkserif */
-
 
212
  87, /* product */
-
 
213
  51, /* radical */
-
 
214
  46, /* dotmath */
-
 
215
  32,
-
 
216
 217, /* logicaland ???*/
-
 
217
 218, /* logicalor ???*/
-
 
218
 139, /* arrowdblboth */
-
 
219
 136, /* arrowdblleft */
-
 
220
 138, /* arrowdblup */
-
 
221
 137, /* arrowdblright */
-
 
222
 135, /* arrowdbldown */
-
 
223
  57, /* lozenge */
-
 
224
 225, /* angleleft ???*/
-
 
225
 183, /* registersans */
-
 
226
 182, /* copyrightsans */
-
 
227
 181, /* trademarksans */
-
 
228
  89, /* summation */
-
 
229
 163, /* parenlefttp */
-
 
230
 179, /* parenleftex */
-
 
231
 164, /* parenleftbt */
-
 
232
 149, /* bracketlefttp */
-
 
233
 147, /* bracketleftex */
-
 
234
 150, /* bracketleftbt */
-
 
235
 168, /* bracelefttp */
-
 
236
 169, /* braceleftmid */
-
 
237
 170, /* braceleftbt */
-
 
238
 172, /* braceex */
-
 
239
  32,
-
 
240
 241, /* angleright */
-
 
241
  48, /* integral */
-
 
242
  71, /* integraltp */
-
 
243
 180, /* integralex */
-
 
244
  72, /* integralbt */
-
 
245
 165, /* parenrighttp */
-
 
246
 181, /* parenrightex */
-
 
247
 166, /* parenrightbt */
-
 
248
 151, /* bracketrighttp */
-
 
249
 166, /* bracketrightex */
-
 
250
 152, /* bracketrightbt */
-
 
251
 172, /* bracerighttp */
-
 
252
 173, /* bracerightmid */
-
 
253
 174, /* bracerightbt */
-
 
254
 255 /* NULL */
-
 
255
};
-
 
256
 
51
unsigned char Mac2Lat[] = { 
257
unsigned char Mac2Lat[] = { 
52
196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 
258
196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 
53
228, 227, 229, 231, 233, 232, 234, 235, 237, 236, 
259
228, 227, 229, 231, 233, 232, 234, 235, 237, 236, 
54
238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 
260
238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 
55
251, 252,  32, 176, 162, 163, 167,  32, 182, 223, 
261
251, 252,  32, 176, 162, 163, 167,  32, 182, 223, 
Line 625... Line 831...
625
    return(position.x);
831
    return(position.x);
626
}
832
}
627
 
833
 
628
 
834
 
629
 
835
 
-
 
836
/* This new version of Quartz_SetFont handles correctly the unicode encoding of
-
 
837
   the Symbol font under Panther
-
 
838
 */
630
 
839
 
631
static void Quartz_SetFont(int style,  double cex, double ps, NewDevDesc *dd)
840
static void Quartz_SetFont(int style,  double cex, double ps, NewDevDesc *dd)
632
{
841
{
633
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
842
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
634
    int size = cex * ps + 0.5;
843
    int size = cex * ps + 0.5;
Line 641... Line 850...
641
    SetPortWindowPort(xd->window);
850
    SetPortWindowPort(xd->window);
642
    
851
    
643
    switch(style){
852
    switch(style){
644
     case 5:
853
     case 5:
645
      strcpy(CurrFont,"Symbol");
854
      strcpy(CurrFont,"Symbol");
-
 
855
	  CGContextSelectFont( GetContext(xd), CurrFont, size,kCGEncodingFontSpecific);
646
     break;
856
     break;
647
 
857
 
648
     default:
858
     default:
649
        if(xd->family)
859
        if(xd->family)
650
            strcpy(CurrFont,xd->family);
860
            strcpy(CurrFont,xd->family);
651
        else
861
        else
652
            strcpy(CurrFont,"Helvetica");
862
            strcpy(CurrFont,"Helvetica");
-
 
863
		    CGContextSelectFont( GetContext(xd), CurrFont, size, kCGEncodingMacRoman);	
653
     break;
864
     break;
654
    }
865
    }
655
 
866
 
-
 
867
/* This is needed for test only purposes 
-
 
868
    if(strcmp(CurrFont,"Symbol")==0)
656
    CGContextSelectFont( GetContext(xd), CurrFont, size, kCGEncodingMacRoman);
869
     CGContextSelectFont( GetContext(xd), CurrFont, size, kCGEncodingFontSpecific);
-
 
870
*/
657
    CopyCStringToPascal(CurrFont,CurrFontName);
871
    CopyCStringToPascal(CurrFont,CurrFontName);
658
    GetFNum(CurrFontName, &CurrFontId);
872
    GetFNum(CurrFontName, &CurrFontId);
659
    TextSize(size);
873
    TextSize(size);
660
    TextFont(CurrFontId);
874
    TextFont(CurrFontId);
661
    SetPort(savePort);
875
    SetPort(savePort);
662
}
876
}
663
 
877
 
664
 
878
 
-
 
879
 
-
 
880
Boolean IsThisASymbol(unsigned char c);
-
 
881
Boolean IsThisASymbol(unsigned char c){
-
 
882
 int i;
-
 
883
 for(i=0; i <  MAX_NON_SYMBS; i++){
-
 
884
  if(c == NotSymbols[i])
-
 
885
   return(false);
-
 
886
  }
-
 
887
     
-
 
888
  return(true); 
-
 
889
}
-
 
890
 
-
 
891
/* This new version of Quartz_Text handles correctly the symbol font under Panther */
-
 
892
 
-
 
893
 
665
static void 	Quartz_Text(double x, double y, char *str,
894
static void 	Quartz_Text(double x, double y, char *str,
666
			    double rot, double hadj, 
895
			    double rot, double hadj, 
667
			    R_GE_gcontext *gc,
896
			    R_GE_gcontext *gc,
668
			    NewDevDesc *dd)
897
			    NewDevDesc *dd)
669
{
898
{
670
    int len,i;
899
    int len,i;
671
    char *buf=NULL;
900
    char *buf=NULL;
-
 
901
	char symbuf;
672
    unsigned char tmp;
902
    unsigned char tmp;
673
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
903
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
674
 
904
	 
675
    CGContextSaveGState( GetContext(xd) );
905
    CGContextSaveGState( GetContext(xd) );
676
    CGContextTranslateCTM( GetContext(xd), x, y );
906
    CGContextTranslateCTM( GetContext(xd), x, y );
677
 
907
 
678
    CGContextScaleCTM( GetContext(xd) , -1, 1);
908
    CGContextScaleCTM( GetContext(xd) , -1, 1);
679
 
909
 
Line 684... Line 914...
684
    CGContextSetTextDrawingMode( GetContext(xd), kCGTextFill );
914
    CGContextSetTextDrawingMode( GetContext(xd), kCGTextFill );
685
    Quartz_SetFill(gc->col, gc->gamma, dd);
915
    Quartz_SetFill(gc->col, gc->gamma, dd);
686
    Quartz_SetFont(gc->fontface, gc->cex,  gc->ps, dd);
916
    Quartz_SetFont(gc->fontface, gc->cex,  gc->ps, dd);
687
    len = strlen(str);
917
    len = strlen(str);
688
 
918
 
689
    if(gc->fontface == 5)
919
    if( (gc->fontface == 5) && (len==1) ){
-
 
920
	   tmp = (unsigned char)str[0];
-
 
921
       if(tmp>31)
-
 
922
        symbuf = (char)Lat2Uni[tmp-31-1];
-
 
923
	   else
-
 
924
	    symbuf = str[0];
-
 
925
       if( !IsThisASymbol(tmp) ){
-
 
926
		 Quartz_SetFont(-1, gc->cex,  gc->ps, dd);
-
 
927
		 symbuf = str[0];
-
 
928
       }
690
     CGContextShowTextAtPoint( GetContext(xd), 0, 0, str, strlen(str) );
929
     CGContextShowTextAtPoint( GetContext(xd), 0, 0, &symbuf, len );
691
    else {
930
     } else {
692
     if( (buf = malloc(len)) != NULL){
931
     if( (buf = malloc(len)) != NULL){
693
      for(i=0;i <len;i++){
932
      for(i=0;i <len;i++){
694
        tmp = (unsigned char)str[i];
933
        tmp = (unsigned char)str[i];
695
      if(tmp>127)
934
      if(tmp>127)
696
       buf[i] = (char)Lat2Mac[tmp-127-1];
935
       buf[i] = (char)Lat2Mac[tmp-127-1];
Line 703... Line 942...
703
    }
942
    }
704
    CGContextRestoreGState( GetContext(xd) );
943
    CGContextRestoreGState( GetContext(xd) );
705
}
944
}
706
 
945
 
707
 
946
 
-
 
947
 
708
static void 	Quartz_Rect(double x0, double y0, double x1, double y1,
948
static void 	Quartz_Rect(double x0, double y0, double x1, double y1,
709
			    R_GE_gcontext *gc,
949
			    R_GE_gcontext *gc,
710
			    NewDevDesc *dd)
950
			    NewDevDesc *dd)
711
{
951
{
712
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
952
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
Line 998... Line 1238...
998
static void 	Quartz_Hold(NewDevDesc *dd)
1238
static void 	Quartz_Hold(NewDevDesc *dd)
999
{
1239
{
1000
 return;
1240
 return;
1001
}
1241
}
1002
 
1242
 
-
 
1243
#if !defined(FixedToFloat)
1003
#define FixedToFloat(a)	((float)(a) / fixed1)
1244
# define FixedToFloat(a)	((float)(a) / fixed1)
1004
#define FloatToFixed(a)	((Fixed)((float) (a) * fixed1))
1245
# define FloatToFixed(a)	((Fixed)((float) (a) * fixed1))
-
 
1246
#endif
1005
 
1247
 
1006
static void 	Quartz_MetricInfo(int c, 
1248
static void 	Quartz_MetricInfo(int c, 
1007
				  R_GE_gcontext *gc,
1249
				  R_GE_gcontext *gc,
1008
				  double* ascent, double* descent, 
1250
				  double* ascent, double* descent, 
1009
				  double* width,
1251
				  double* width,
Line 1013... Line 1255...
1013
    QuartzDesc *xd = (QuartzDesc *) dd-> deviceSpecific;
1255
    QuartzDesc *xd = (QuartzDesc *) dd-> deviceSpecific;
1014
    char testo[2];
1256
    char testo[2];
1015
    CGrafPtr savedPort;
1257
    CGrafPtr savedPort;
1016
    Rect bounds;
1258
    Rect bounds;
1017
    CGPoint position;
1259
    CGPoint position;
-
 
1260
	unsigned char tmp;
1018
 
1261
 
1019
    testo[0] = c;
1262
    testo[0] = c;
1020
    testo[1] = '\0';
1263
    testo[1] = '\0';
1021
 
1264
 
1022
    GetPort(&savedPort);
1265
    GetPort(&savedPort);
Line 1035... Line 1278...
1035
    CGContextTranslateCTM( GetContext(xd), 0, 0 );
1278
    CGContextTranslateCTM( GetContext(xd), 0, 0 );
1036
    CGContextScaleCTM( GetContext(xd), -1, 1);
1279
    CGContextScaleCTM( GetContext(xd), -1, 1);
1037
    CGContextRotateCTM( GetContext(xd), -1.0 * 3.1416);
1280
    CGContextRotateCTM( GetContext(xd), -1.0 * 3.1416);
1038
    CGContextSetTextDrawingMode( GetContext(xd), kCGTextInvisible );
1281
    CGContextSetTextDrawingMode( GetContext(xd), kCGTextInvisible );
1039
    Quartz_SetFont(gc->fontface, gc->cex,  gc->ps, dd);
1282
    Quartz_SetFont(gc->fontface, gc->cex,  gc->ps, dd);
-
 
1283
	
-
 
1284
	tmp = (unsigned char)c;
-
 
1285
    if( (gc->fontface == 5) ){
-
 
1286
       if( (tmp>31) && IsThisASymbol(tmp))
-
 
1287
        testo[0] = (char)Lat2Uni[tmp-31-1];
-
 
1288
       else	
-
 
1289
		Quartz_SetFont(-1, gc->cex,  gc->ps, dd);
-
 
1290
	 } else {
-
 
1291
        if(tmp>127)
-
 
1292
         testo[0] = (char)Lat2Mac[tmp-127-1];
-
 
1293
     }	 
-
 
1294
 
1040
    CGContextShowTextAtPoint( GetContext(xd), 0, 0, testo, 1 );
1295
    CGContextShowTextAtPoint( GetContext(xd), 0, 0, testo, 1 );
-
 
1296
    
-
 
1297
	
1041
    position = CGContextGetTextPosition( GetContext(xd) );
1298
    position = CGContextGetTextPosition( GetContext(xd) );
1042
    CGContextRestoreGState( GetContext(xd) );
1299
    CGContextRestoreGState( GetContext(xd) );
1043
    
1300
    
1044
        QDTextBounds(1,testo,&bounds);
1301
        QDTextBounds(1,testo,&bounds);
1045
        *ascent = -bounds.top;
1302
        *ascent = -bounds.top;