The R Project SVN R

Rev

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

Rev 32392 Rev 32397
Line 20... Line 20...
20
 *  along with this program; if not, write to the Free Software
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 */
22
 */
23
 
23
 
24
/* <UTF8-FIXME>
24
/* <UTF8-FIXME>
25
   byte-level access and use of ctype functions
25
   byte-level access and use of ctype functions for symbol font
26
   byte-level charmetric information.
-
 
-
 
26
 
27
   Has encoding of symbol font hard-coded.
27
   Has encoding of symbol font hard-coded.  Not clear if this is enough.
28
*/
28
*/
29
 
29
 
30
#ifdef HAVE_CONFIG_H
30
#ifdef HAVE_CONFIG_H
31
#include <config.h>
31
#include <config.h>
32
#endif
32
#endif
33
 
33
 
34
#include <ctype.h>
34
#include <ctype.h>
-
 
35
#ifdef SUPPORT_UTF8
-
 
36
# include <wchar.h>
-
 
37
# include <wctype.h>
-
 
38
#endif
-
 
39
 
35
 
40
 
36
#include <Defn.h>
41
#include <Defn.h>
37
#include <Rmath.h>
42
#include <Rmath.h>
38
#include <Graphics.h>
43
#include <Graphics.h>
39
 
44
 
Line 990... Line 995...
990
	prev = SetFont(PlainFont, gc);
995
	prev = SetFont(PlainFont, gc);
991
    else
996
    else
992
	prev = SetFont(SymbolFont, gc);
997
	prev = SetFont(SymbolFont, gc);
993
    bbox = GlyphBBox(ascii, gc, dd);
998
    bbox = GlyphBBox(ascii, gc, dd);
994
    if (draw) {
999
    if (draw) {
-
 
1000
	/* <UTF8-FIXME> */
995
	asciiStr[0] = ascii;
1001
	asciiStr[0] = ascii;
996
	asciiStr[1] = '\0';
1002
	asciiStr[1] = '\0';
997
	GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), asciiStr,
1003
	GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), asciiStr,
998
	       0.0, 0.0, mc->CurrentAngle, gc,
1004
	       0.0, 0.0, mc->CurrentAngle, gc,
999
	       dd);
1005
	       dd);
Line 1016... Line 1022...
1016
    double lastItalicCorr = 0;
1022
    double lastItalicCorr = 0;
1017
    FontType prevfont = GetFont(gc);
1023
    FontType prevfont = GetFont(gc);
1018
    FontType font = prevfont;
1024
    FontType font = prevfont;
1019
    chr[1] = '\0';
1025
    chr[1] = '\0';
1020
    if (str) {
1026
    if (str) {
-
 
1027
	/* <UTF8-FIXME> perhaps */
1021
	char *s = str;
1028
	char *s = str;
1022
	while (*s) {
1029
	while (*s) {
1023
	    if (isdigit((int)*s) && font != PlainFont) {
1030
	    if (isdigit((int)*s) && font != PlainFont) {
1024
		font = PlainFont;
1031
		font = PlainFont;
1025
		SetFont(PlainFont, gc);
1032
		SetFont(PlainFont, gc);
Line 1053... Line 1060...
1053
    return resultBBox;
1060
    return resultBBox;
1054
}
1061
}
1055
 
1062
 
1056
/* Code for Character String Atoms. */
1063
/* Code for Character String Atoms. */
1057
 
1064
 
-
 
1065
/* This only gets called from RenderAccent */
1058
static BBOX RenderChar(int ascii, int draw, mathContext *mc,
1066
static BBOX RenderChar(int ascii, int draw, mathContext *mc,
1059
		       R_GE_gcontext *gc, GEDevDesc *dd)
1067
		       R_GE_gcontext *gc, GEDevDesc *dd)
1060
{
1068
{
1061
    BBOX bbox;
1069
    BBOX bbox;
1062
    char asciiStr[2];
1070
    char asciiStr[2];
1063
    bbox = GlyphBBox(ascii, gc, dd);
1071
    bbox = GlyphBBox(ascii, gc, dd);
1064
    if (draw) {
1072
    if (draw) {
-
 
1073
	/* <UTF8-FIXME> This appears only to get called with values
-
 
1074
	   for hat, tilde and ring.  The latter appears to be hardcoded
-
 
1075
	   in Latin-1.
-
 
1076
	 */
1065
	asciiStr[0] = ascii;
1077
	asciiStr[0] = ascii;
1066
	asciiStr[1] = '\0';
1078
	asciiStr[1] = '\0';
1067
	GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), asciiStr,
1079
	GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), asciiStr,
1068
	       0.0, 0.0, mc->CurrentAngle, gc,
1080
	       0.0, 0.0, mc->CurrentAngle, gc,
1069
	       dd);
1081
	       dd);
1070
	PMoveAcross(bboxWidth(bbox), mc);
1082
	PMoveAcross(bboxWidth(bbox), mc);
1071
    }
1083
    }
1072
    return bbox;
1084
    return bbox;
1073
}
1085
}
1074
 
1086
 
-
 
1087
/* This gets called on strings and PRINTNAMES */
1075
static BBOX RenderStr(char *str, int draw, mathContext *mc,
1088
static BBOX RenderStr(char *str, int draw, mathContext *mc,
1076
		      R_GE_gcontext *gc, GEDevDesc *dd)
1089
		      R_GE_gcontext *gc, GEDevDesc *dd)
1077
{
1090
{
1078
    BBOX glyphBBox;
1091
    BBOX glyphBBox;
1079
    BBOX resultBBox = NullBBox();
1092
    BBOX resultBBox = NullBBox();
1080
    if (str) {
1093
    if (str) {
-
 
1094
#ifdef SUPPORT_UTF8
-
 
1095
	int n = strlen(str), used;
-
 
1096
	wchar_t wc;
-
 
1097
	char *p = str;
-
 
1098
	while ((used = mbrtowc(&wc, p, n, NULL)) > 0) {
-
 
1099
	    glyphBBox = GlyphBBox(wc, gc, dd);
-
 
1100
	    resultBBox = CombineBBoxes(resultBBox, glyphBBox);
-
 
1101
	    p += used; n -= used;
-
 
1102
	}
-
 
1103
#else
1081
	char *s = str;
1104
	char *s = str;
1082
	while (*s) {
1105
	while (*s) {
1083
	    glyphBBox = GlyphBBox(*s, gc, dd);
1106
	    glyphBBox = GlyphBBox(*s, gc, dd);
1084
	    resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1107
	    resultBBox = CombineBBoxes(resultBBox, glyphBBox);
1085
	    s++;
1108
	    s++;
1086
	}
1109
	}
-
 
1110
#endif
1087
	if (draw) {
1111
	if (draw) {
1088
	    GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), str,
1112
	    GEText(ConvertedX(mc ,dd), ConvertedY(mc, dd), str,
1089
		   0.0, 0.0, mc->CurrentAngle, gc,
1113
		   0.0, 0.0, mc->CurrentAngle, gc,
1090
		   dd);
1114
		   dd);
1091
	    PMoveAcross(bboxWidth(resultBBox), mc);
1115
	    PMoveAcross(bboxWidth(resultBBox), mc);