The R Project SVN R

Rev

Rev 21062 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21062 Rev 27236
Line 24... Line 24...
24
#include <Defn.h>
24
#include <Defn.h>
25
#include <Rdynpriv.h>
25
#include <Rdynpriv.h>
26
#include <Graphics.h>
26
#include <Graphics.h>
27
 
27
 
28
typedef struct {
28
typedef struct {
29
    R_GE_VTextRoutine GVText;
29
    R_GE_VTextRoutine GEVText;
30
    R_GE_VStrWidthRoutine GVStrWidth;
30
    R_GE_VStrWidthRoutine GEVStrWidth;
31
    R_GE_VStrHeightRoutine GVStrHeight;
31
    R_GE_VStrHeightRoutine GEVStrHeight;
32
} VfontRoutines;
32
} VfontRoutines;
33
 
33
 
34
static VfontRoutines routines, *ptr = &routines;
34
static VfontRoutines routines, *ptr = &routines;
35
 
35
 
36
/*
36
/*
Line 51... Line 51...
51
void
51
void
52
R_GE_setVFontRoutines(R_GE_VStrWidthRoutine vwidth, 
52
R_GE_setVFontRoutines(R_GE_VStrWidthRoutine vwidth, 
53
		      R_GE_VStrHeightRoutine vheight, 
53
		      R_GE_VStrHeightRoutine vheight, 
54
		      R_GE_VTextRoutine vtext)
54
		      R_GE_VTextRoutine vtext)
55
{
55
{
56
    ptr->GVStrWidth = vwidth;
56
    ptr->GEVStrWidth = vwidth;
57
    ptr->GVStrHeight = vheight;
57
    ptr->GEVStrHeight = vheight;
58
    ptr->GVText = vtext;
58
    ptr->GEVText = vtext;
59
}
59
}
60
 
60
 
61
static void vfonts_Init(void)
61
static void vfonts_Init(void)
62
{
62
{
63
    int res = moduleCdynload("vfonts", 1, 1);
63
    int res = moduleCdynload("vfonts", 1, 1);
Line 68... Line 68...
68
}
68
}
69
 
69
 
70
double GVStrWidth (const unsigned char *s, int typeface, int fontindex,
70
double GVStrWidth (const unsigned char *s, int typeface, int fontindex,
71
		   int unit, DevDesc *dd)
71
		   int unit, DevDesc *dd)
72
{
72
{
73
    return GConvertXUnits(R_GE_VStrWidth(s, typeface, fontindex, 1, 
73
    R_GE_gcontext gc;
74
					 Rf_gpptr(dd)->cex, 
74
    gcontextFromGP(&gc, dd);
75
					 Rf_gpptr(dd)->ps, 
75
    gc.fontface = typeface;
-
 
76
    gc.fontfamily[0] = fontindex;
76
					 (GEDevDesc *) dd),
77
    return GConvertXUnits(R_GE_VStrWidth(s, &gc, (GEDevDesc *) dd),
77
			  DEVICE, unit, dd);
78
			  DEVICE, unit, dd);
78
}
79
}
79
 
80
 
80
double R_GE_VStrWidth(const unsigned char *s, int typeface, int fontindex,
81
double R_GE_VStrWidth(const unsigned char *s, 
-
 
82
		      R_GE_gcontext *gc,
81
		      double lineheight, double cex, double ps, GEDevDesc *dd)
83
		      GEDevDesc *dd)
82
{
84
{
83
    if(!initialized) vfonts_Init();
85
    if(!initialized) vfonts_Init();
84
    if(initialized > 0)
86
    if(initialized > 0)
85
	return (*ptr->GVStrWidth)(s, typeface, fontindex, lineheight,
87
	return (*ptr->GEVStrWidth)(s, gc, dd);
86
				  cex, ps, dd);
-
 
87
    else {
88
    else {
88
	error("Hershey fonts cannot be loaded");
89
	error("Hershey fonts cannot be loaded");
89
	return 0.0;
90
	return 0.0;
90
    }
91
    }
91
}
92
}
92
 
93
 
93
double GVStrHeight (const unsigned char *s, int typeface, int fontindex,
94
double GVStrHeight (const unsigned char *s, int typeface, int fontindex,
94
		    int unit, DevDesc *dd)
95
		    int unit, DevDesc *dd)
95
{
96
{
96
    return GConvertYUnits(R_GE_VStrHeight(s, typeface, fontindex, 1, 
97
    R_GE_gcontext gc;
97
					  Rf_gpptr(dd)->cex, 
98
    gcontextFromGP(&gc, dd);
98
					  Rf_gpptr(dd)->ps, 
99
    gc.fontface = typeface;
-
 
100
    gc.fontfamily[0] = fontindex;
99
					  (GEDevDesc *) dd),
101
    return GConvertYUnits(R_GE_VStrHeight(s, &gc, (GEDevDesc *) dd),
100
			  DEVICE, unit, dd);
102
			  DEVICE, unit, dd);
101
}
103
}
102
 
104
 
103
double R_GE_VStrHeight(const unsigned char *s, int typeface, int fontindex,
105
double R_GE_VStrHeight(const unsigned char *s, 
-
 
106
		       R_GE_gcontext *gc,
104
		       double lineheight, double cex, double ps, GEDevDesc *dd)
107
		       GEDevDesc *dd)
105
{
108
{
106
    if(!initialized) vfonts_Init();
109
    if(!initialized) vfonts_Init();
107
    if(initialized > 0)
110
    if(initialized > 0)
108
	return (*ptr->GVStrHeight)(s, typeface, fontindex, lineheight,
111
	return (*ptr->GEVStrHeight)(s, gc, dd);
109
				   cex, ps, dd);
-
 
110
    else {
112
    else {
111
	error("Hershey fonts cannot be loaded");
113
	error("Hershey fonts cannot be loaded");
112
	return 0.0;
114
	return 0.0;
113
    }
115
    }
114
}
116
}
Line 116... Line 118...
116
void GVText (double x, double y, int unit, char *s, 
118
void GVText (double x, double y, int unit, char *s, 
117
	     int typeface, int fontindex,
119
	     int typeface, int fontindex,
118
	     double x_justify, double y_justify, double rotation,
120
	     double x_justify, double y_justify, double rotation,
119
	     DevDesc *dd)
121
	     DevDesc *dd)
120
{
122
{
-
 
123
    R_GE_gcontext gc;
-
 
124
    gcontextFromGP(&gc, dd);
121
    /* 
125
    /* 
122
     * Ensure that the current par(xpd) settings are enforced.
126
     * Ensure that the current par(xpd) settings are enforced.
123
     */
127
     */
124
    GClip(dd);
128
    GClip(dd);
125
    GConvert(&x, &y, unit, DEVICE, dd);
129
    GConvert(&x, &y, unit, DEVICE, dd);
126
    R_GE_VText(x, y, s, typeface, fontindex, x_justify, y_justify,
130
    gc.fontface = typeface;
127
	       rotation, Rf_gpptr(dd)->col, Rf_gpptr(dd)->gamma,
131
    gc.fontfamily[0] = fontindex;
128
	       1 /* lineheight */, Rf_gpptr(dd)->cex, Rf_gpptr(dd)->ps,
132
    R_GE_VText(x, y, s, x_justify, y_justify, rotation, &gc, (GEDevDesc *) dd);
129
	       (GEDevDesc *) dd);
-
 
130
}
133
}
131
 
134
 
132
void R_GE_VText(double x, double y, char *s, 
135
void R_GE_VText(double x, double y, char *s, 
133
		int typeface, int fontindex,
-
 
134
		double x_justify, double y_justify, double rotation,
136
		double x_justify, double y_justify, double rotation,
135
		int col, double gamma, double lineheight,
-
 
136
		double cex, double ps,
137
		R_GE_gcontext *gc,
137
		GEDevDesc *dd)
138
		GEDevDesc *dd)
138
{
139
{
139
    if(!initialized) vfonts_Init();
140
    if(!initialized) vfonts_Init();
140
    if(initialized > 0)
141
    if(initialized > 0)
141
	(*ptr->GVText)(x, y, s, typeface, fontindex, 
142
	(*ptr->GEVText)(x, y, s, x_justify, y_justify, rotation, gc, dd);
142
		       x_justify, y_justify, rotation, 
-
 
143
		       col, gamma, lineheight, cex, ps, dd);
-
 
144
    else
143
    else
145
	error("Hershey fonts cannot be loaded");
144
	error("Hershey fonts cannot be loaded");
146
}
145
}