Subversion Repositories wimsdev

Rev

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

Rev 8185 Rev 12240
Line 44... Line 44...
44
 
44
 
45
int current_tex_size;
45
int current_tex_size;
46
 
46
 
47
void fix_tex_size(void)
47
void fix_tex_size(void)
48
{
48
{
49
    char buf[64],*p; int i,ts;
49
  char buf[64],*p; int i,ts;
50
    ts=texbasesize;
50
  ts=texbasesize;
51
    if(usertexsize>=0) ts=usertexsize+1;
51
  if(usertexsize>=0) ts=usertexsize+1;
52
    if(getwimstexsize) p=getvar("wims_texsize"); else p=NULL;
52
  if(getwimstexsize) p=getvar("wims_texsize"); else p=NULL;
53
    if(p!=NULL && *p!=0) {
53
  if(p!=NULL && *p!=0) {
54
     i=evalue(p);
54
    i=evalue(p);
55
     if(i>=-5 && i<=5) ts+=i;
55
    if(i>=-5 && i<=5) ts+=i;
56
    }
56
  }
57
    if(ts<0) ts=0;
57
  if(ts<0) ts=0;
58
    if(ts>=texsize_no) ts=texsize_no-1;
58
  if(ts>=texsize_no) ts=texsize_no-1;
59
    current_tex_size=texsize_list[ts];
59
  current_tex_size=texsize_list[ts];
60
    snprintf(buf,sizeof(buf),"%d",current_tex_size);
60
  snprintf(buf,sizeof(buf),"%d",current_tex_size);
61
    setenv("texgif_density",buf,1);
61
  setenv("texgif_density",buf,1);
62
}
62
}
63
 
63
 
64
/* takes math font image file string */
64
/* takes math font image file string */
65
char *mathfont(char *fontname)
65
char *mathfont(char *fontname)
66
{
66
{
67
    char buf1[MAX_LINELEN+1],buf2[MAX_LINELEN+1];
67
  char buf1[MAX_LINELEN+1],buf2[MAX_LINELEN+1];
68
    struct stat st;
68
  struct stat st;
69
 
69
 
70
    if(fontname[0]=='\\') fontname++;
70
  if(fontname[0]=='\\') fontname++;
71
    else if(strncmp(fontname,mathfont_prefix,strlen(mathfont_prefix))==0)
71
  else if(strncmp(fontname,mathfont_prefix,strlen(mathfont_prefix))==0)
72
      fontname+=strlen(mathfont_prefix);
72
    fontname+=strlen(mathfont_prefix);
73
    if(strlen(fontname)==1 /* && strchr("xyz",fontname[0])==NULL */) {
73
  if(strlen(fontname)==1 /* && strchr("xyz",fontname[0])==NULL */) {
74
     char c=fontname[0];
74
    char c=fontname[0];
75
     if(!isalpha(c)) { // c is not a letter
75
    if(!isalpha(c)) { // c is not a letter
76
         buf2[0]=c;buf2[1]=0;
76
      buf2[0]=c;buf2[1]=0;
77
     }
77
   }
78
     else {
78
   else {
79
// case of variable xyz in particular
79
// case of variable xyz in particular
80
         char *pp;
80
    char *pp;
81
         if(c=='f') pp="&nbsp;"; else pp="";
81
    if(c=='f') pp="&nbsp;"; else pp="";
82
         snprintf(buf2,sizeof(buf2),"<i>%c</i>%s",c,pp);
82
    snprintf(buf2,sizeof(buf2),"<i>%c</i>%s",c,pp);
83
//FIXME-> should we arrive here in mathml case ???
83
//FIXME-> should we arrive here in mathml case ???
84
     }
84
    }
85
    }
85
  }
86
    else {/* interpret font with at least two caracters as \RR \calB - only outside of math environment
86
  else {/* interpret font with at least two caracters as \RR \calB - only outside of math environment
87
    not useful in mathml*/
87
    not useful in mathml*/
88
     char *underscore;
88
    char *underscore;
89
     fix_tex_size(); underscore="";
89
    fix_tex_size(); underscore="";
90
         {
90
    {
91
          char *p, *p2;
91
      char *p, *p2;
92
          for(p=fontname; *p && !isupper(*p); p++);
92
      for(p=fontname; *p && !isupper(*p); p++);
93
/* verify positionning of capital letter */
93
/* verify positionning of capital letter */
94
          if(*p && p>fontname && *(p+1)!=0) return NULL;
94
      if(*p && p>fontname && *(p+1)!=0) return NULL;
95
          if(p==fontname && (fontname[1]!=*p || strlen(fontname)!=2)) {
95
      if(p==fontname && (fontname[1]!=*p || strlen(fontname)!=2)) {
96
              for(p2=p+1; *p2 && !isupper(*p2); p2++);
96
        for(p2=p+1; *p2 && !isupper(*p2); p2++);
97
              if(*p2) return NULL;
97
        if(*p2) return NULL;
98
          }
98
      }
99
          if(*p) underscore="_";
99
      if(*p) underscore="_";
100
         }
100
    }
101
     snprintf(buf1,sizeof(buf1),"%s/%d/%s%s.gif",
101
    snprintf(buf1,sizeof(buf1),"%s/%d/%s%s.gif",
102
           mathfont_dir,current_tex_size,fontname,underscore);
102
           mathfont_dir,current_tex_size,fontname,underscore);
103
     if(*underscore && stat(buf1,&st)!=0)
103
    if(*underscore && stat(buf1,&st)!=0)
104
       snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif",
104
      snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif",
105
             mathfont_dir,current_tex_size,fontname);
105
             mathfont_dir,current_tex_size,fontname);
106
 
106
 
107
     if(stat(buf1,&st)!=0) return NULL;
107
    if(stat(buf1,&st)!=0) return NULL;
108
     snprintf(buf2,sizeof(buf2),",%s,",fontname);
108
    snprintf(buf2,sizeof(buf2),",%s,",fontname);
109
     if(strstr(middle_fonts,buf2)!=NULL)
109
    if(strstr(middle_fonts,buf2)!=NULL)
110
       snprintf(buf2,sizeof(buf2),
110
      snprintf(buf2,sizeof(buf2),
111
             "%s<img src=\"%s%s\" style=\"vertical-align: middle; border:none\" \
111
             "%s<img src=\"%s%s\" style=\"vertical-align: middle; border:none\" \
112
alt=\"%s\" />%s",
112
alt=\"%s\" />%s",
113
             mathalign_sup1,ref_base,buf1,fontname,mathalign_sup2);
113
             mathalign_sup1,ref_base,buf1,fontname,mathalign_sup2);
114
     else
114
    else
115
       snprintf(buf2,sizeof(buf2),"<img src=\"%s%s\" style=\"margin:0px; border:none\" \
115
       snprintf(buf2,sizeof(buf2),"<img src=\"%s%s\" style=\"margin:0px; border:none\" \
116
alt=\"%s\" />",
116
alt=\"%s\" />",
117
             ref_base,buf1,fontname);
117
             ref_base,buf1,fontname);
118
    }
118
  }
119
    force_setvar("wims_mathfont_",buf2); return getvar("wims_mathfont_");
119
  force_setvar("wims_mathfont_",buf2); return getvar("wims_mathfont_");
120
}
120
}
121
 
-