The R Project SVN R

Rev

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

Rev 44437 Rev 44535
Line 1147... Line 1147...
1147
static BBOX RenderStr(const char *str, int draw, mathContext *mc,
1147
static BBOX RenderStr(const char *str, int draw, mathContext *mc,
1148
		      pGEcontext gc, pGEDevDesc dd)
1148
		      pGEcontext gc, pGEDevDesc dd)
1149
{
1149
{
1150
    BBOX glyphBBox = NullBBox(); /* might be use do italic corr on str="" */
1150
    BBOX glyphBBox = NullBBox(); /* might be use do italic corr on str="" */
1151
    BBOX resultBBox = NullBBox();
1151
    BBOX resultBBox = NullBBox();
-
 
1152
    int nc = 0;
1152
 
1153
 
1153
    if (str) {
1154
    if (str) {
1154
#ifdef SUPPORT_MBCS
1155
#ifdef SUPPORT_MBCS
1155
	/* need to advance by character, not byte, except in the symbol font */
1156
	/* need to advance by character, not byte, except in the symbol font */
1156
	if(mbcslocale && gc->fontface != 5) {
1157
	if(mbcslocale && gc->fontface != 5) {
Line 1160... Line 1161...
1160
	    mbstate_t mb_st;
1161
	    mbstate_t mb_st;
1161
	    mbs_init(&mb_st);
1162
	    mbs_init(&mb_st);
1162
	    while ((used = Mbrtowc(&wc, p, n, &mb_st)) > 0) {
1163
	    while ((used = Mbrtowc(&wc, p, n, &mb_st)) > 0) {
1163
		glyphBBox = GlyphBBox(wc, gc, dd);
1164
		glyphBBox = GlyphBBox(wc, gc, dd);
1164
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1165
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1165
		p += used; n -= used;
1166
		p += used; n -= used; nc++;
1166
	    }
1167
	    }
1167
	} else
1168
	} else
1168
#endif
1169
#endif
1169
	{
1170
	{
1170
	    const char *s = str;
1171
	    const char *s = str;
1171
	    while (*s) {
1172
	    while (*s) {
1172
		glyphBBox = GlyphBBox(*s, gc, dd);
1173
		glyphBBox = GlyphBBox(*s, gc, dd);
1173
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1174
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1174
		s++;
1175
		s++; nc++;
1175
	    }
1176
	    }
1176
	}
1177
	}
-
 
1178
	if(nc > 1) {
-
 
1179
	    /* Finding the width by adding up boxes is incorrect (kerning) */
-
 
1180
	    double wd = GEStrWidth(str, CE_NATIVE, gc, dd);
-
 
1181
	    bboxWidth(resultBBox) = fromDeviceHeight(wd, MetricUnit, dd);
-
 
1182
	}
1177
	if (draw) {
1183
	if (draw) {
1178
	    GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), str, CE_NATIVE,
1184
	    GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), str, CE_NATIVE,
1179
		   0.0, 0.0, mc->CurrentAngle, gc, dd);
1185
		   0.0, 0.0, mc->CurrentAngle, gc, dd);
1180
	    PMoveAcross(bboxWidth(resultBBox), mc);
1186
	    PMoveAcross(bboxWidth(resultBBox), mc);
1181
	}
1187
	}