The R Project SVN R

Rev

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

Rev 47460 Rev 49591
Line 26... Line 26...
26
#include <config.h>
26
#include <config.h>
27
#endif
27
#endif
28
#include <Defn.h>
28
#include <Defn.h>
29
 
29
 
30
#include <ctype.h>
30
#include <ctype.h>
31
#ifdef SUPPORT_MBCS
-
 
32
# include <R_ext/rlocale.h>
31
#include <R_ext/rlocale.h>
33
# include <wchar.h>
-
 
34
# include <wctype.h>
-
 
35
#endif
-
 
36
 
32
 
37
 
33
 
38
#include <Rmath.h>
34
#include <Rmath.h>
39
#include <R_ext/GraphicsEngine.h>
35
#include <R_ext/GraphicsEngine.h>
40
 
36
 
Line 968... Line 964...
968
    double lastItalicCorr = 0;
964
    double lastItalicCorr = 0;
969
    FontType prevfont = GetFont(gc);
965
    FontType prevfont = GetFont(gc);
970
    FontType font = prevfont;
966
    FontType font = prevfont;
971
 
967
 
972
    if (str) {
968
    if (str) {
973
#ifdef SUPPORT_MBCS
-
 
974
	/* Need to advance by character, not byte, except in the symbol font.
969
	/* Need to advance by character, not byte, except in the symbol font.
975
	   The latter would be hard to achieve, but perhaps not impossible.
970
	   The latter would be hard to achieve, but perhaps not impossible.
976
	 */
971
	 */
977
	if(mbcslocale && gc->fontface != 5) {
972
	if(mbcslocale && gc->fontface != 5) {
978
	    wchar_t wc;
973
	    wchar_t wc;
Line 1012... Line 1007...
1012
		bboxWidth(resultBBox) += lastItalicCorr;
1007
		bboxWidth(resultBBox) += lastItalicCorr;
1013
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1008
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1014
		lastItalicCorr = bboxItalic(glyphBBox);
1009
		lastItalicCorr = bboxItalic(glyphBBox);
1015
		s += res;
1010
		s += res;
1016
	    }
1011
	    }
1017
	} else
1012
	} else {
1018
#endif
-
 
1019
	{
-
 
1020
	    while (*s) {
1013
	    while (*s) {
1021
		if (isdigit((int)*s) && font != PlainFont) {
1014
		if (isdigit((int)*s) && font != PlainFont) {
1022
		    font = PlainFont;
1015
		    font = PlainFont;
1023
		    SetFont(PlainFont, gc);
1016
		    SetFont(PlainFont, gc);
1024
		}
1017
		}
Line 1063... Line 1056...
1063
    char asciiStr[7];
1056
    char asciiStr[7];
1064
 
1057
 
1065
    bbox = GlyphBBox(ascii, gc, dd);
1058
    bbox = GlyphBBox(ascii, gc, dd);
1066
    if (draw) {
1059
    if (draw) {
1067
	memset(asciiStr, 0, sizeof(asciiStr));
1060
	memset(asciiStr, 0, sizeof(asciiStr));
1068
#ifdef SUPPORT_MBCS
-
 
1069
	if(mbcslocale) {
1061
	if(mbcslocale) {
1070
	    size_t res = wcrtomb(asciiStr, ascii, NULL);
1062
	    size_t res = wcrtomb(asciiStr, ascii, NULL);
1071
	    if(res == -1)
1063
	    if(res == -1)
1072
		error("invalid character in current multibyte locale");
1064
		error("invalid character in current multibyte locale");
1073
	} else
1065
	} else
1074
#endif
-
 
1075
	    asciiStr[0] = ascii;
1066
	    asciiStr[0] = ascii;
1076
	GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), asciiStr, CE_NATIVE,
1067
	GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), asciiStr, CE_NATIVE,
1077
	       0.0, 0.0, mc->CurrentAngle, gc,
1068
	       0.0, 0.0, mc->CurrentAngle, gc,
1078
	       dd);
1069
	       dd);
1079
	PMoveAcross(bboxWidth(bbox), mc);
1070
	PMoveAcross(bboxWidth(bbox), mc);
Line 1089... Line 1080...
1089
    BBOX resultBBox = NullBBox();
1080
    BBOX resultBBox = NullBBox();
1090
    int nc = 0;
1081
    int nc = 0;
1091
    cetype_t enc = (gc->fontface == 5) ? CE_SYMBOL : CE_NATIVE;
1082
    cetype_t enc = (gc->fontface == 5) ? CE_SYMBOL : CE_NATIVE;
1092
 
1083
 
1093
    if (str) {
1084
    if (str) {
1094
#ifdef SUPPORT_MBCS
-
 
1095
	/* need to advance by character, not byte, except in the symbol font */
1085
	/* need to advance by character, not byte, except in the symbol font */
1096
	if(mbcslocale && gc->fontface != 5) {
1086
	if(mbcslocale && gc->fontface != 5) {
1097
	    int n = strlen(str), used;
1087
	    int n = strlen(str), used;
1098
	    wchar_t wc;
1088
	    wchar_t wc;
1099
	    const char *p = str;
1089
	    const char *p = str;
Line 1103... Line 1093...
1103
		/* On Windows could have sign extension here */
1093
		/* On Windows could have sign extension here */
1104
		glyphBBox = GlyphBBox((unsigned int) wc, gc, dd);
1094
		glyphBBox = GlyphBBox((unsigned int) wc, gc, dd);
1105
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1095
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1106
		p += used; n -= used; nc++;
1096
		p += used; n -= used; nc++;
1107
	    }
1097
	    }
1108
	} else
1098
	} else {
1109
#endif
-
 
1110
	{
-
 
1111
	    const char *s = str;
1099
	    const char *s = str;
1112
	    while (*s) {
1100
	    while (*s) {
1113
		/* Watch for sign extension here - fixed > 2.7.1 */
1101
		/* Watch for sign extension here - fixed > 2.7.1 */
1114
		glyphBBox = GlyphBBox((unsigned char) *s, gc, dd);
1102
		glyphBBox = GlyphBBox((unsigned char) *s, gc, dd);
1115
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1103
		resultBBox = CombineBBoxes(resultBBox, glyphBBox);