Subversion Repositories wimsdev

Rev

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

Rev 6214 Rev 7673
Line 13... Line 13...
13
 *  You should have received a copy of the GNU General Public License
13
 *  You should have received a copy of the GNU General Public License
14
 *  along with this program; if not, write to the Free Software
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
16
 */
17
 
17
 
18
        /* fonts which should have align=middle */
18
/* fonts which should have align=middle */
19
char *middle_fonts=",y,beta,eta,mu,phi,rho,varphi,psi,\
19
char *middle_fonts=",y,beta,eta,mu,phi,rho,varphi,psi,\
20
le,leq,ge,geq,pm,ne,neq,\
20
le,leq,ge,geq,pm,ne,neq,\
21
subseteq,supseteq,wp,\
21
subseteq,supseteq,wp,\
22
int,oint,Vert,\
22
int,oint,Vert,\
23
QQ,\
23
QQ,\
Line 29... Line 29...
29
leftbrace2,leftbrace3,leftbrace4,leftbrace5,leftbrace6,\
29
leftbrace2,leftbrace3,leftbrace4,leftbrace5,leftbrace6,\
30
leftbrace7,leftbrace8,leftbrace9,leftbrace10,leftbrace11,leftbrace12,\
30
leftbrace7,leftbrace8,leftbrace9,leftbrace10,leftbrace11,leftbrace12,\
31
rightbrace2,rightbrace3,rightbrace4,rightbrace5,rightbrace6,\
31
rightbrace2,rightbrace3,rightbrace4,rightbrace5,rightbrace6,\
32
rightbrace7,rightbrace8,rightbrace9,rightbrace10,rightbrace11,rightbrace12,";
32
rightbrace7,rightbrace8,rightbrace9,rightbrace10,rightbrace11,rightbrace12,";
33
 
33
 
34
        /* These are temporary definitions. */
34
/* These are temporary definitions. */
35
char *mathfont_dir="mathfonts";
35
char *mathfont_dir="mathfonts";
36
 
36
 
37
  /* tex font size list */
37
  /* tex font size list */
38
int texsize_list[]={63,69,76,83,91,100,109,120,131,144,158,173};
38
int texsize_list[]={63,69,76,83,91,100,109,120,131,144,158,173};
39
int texbasesize=6; /* defaults to 109 */
39
int texbasesize=6; /* defaults to 109 */
Line 47... Line 47...
47
    char buf[64],*p; int i,ts;
47
    char buf[64],*p; int i,ts;
48
    ts=texbasesize;
48
    ts=texbasesize;
49
    if(usertexsize>=0) ts=usertexsize+1;
49
    if(usertexsize>=0) ts=usertexsize+1;
50
    if(getwimstexsize) p=getvar("wims_texsize"); else p=NULL;
50
    if(getwimstexsize) p=getvar("wims_texsize"); else p=NULL;
51
    if(p!=NULL && *p!=0) {
51
    if(p!=NULL && *p!=0) {
52
        i=evalue(p);
52
     i=evalue(p);
53
        if(i>=-5 && i<=5) ts+=i;
53
     if(i>=-5 && i<=5) ts+=i;
54
    }
54
    }
55
    if(ts<0) ts=0;
55
    if(ts<0) ts=0;
56
    if(ts>=texsize_no) ts=texsize_no-1;    
56
    if(ts>=texsize_no) ts=texsize_no-1;
57
    current_tex_size=texsize_list[ts];
57
    current_tex_size=texsize_list[ts];
58
    snprintf(buf,sizeof(buf),"%d",current_tex_size);
58
    snprintf(buf,sizeof(buf),"%d",current_tex_size);
59
    setenv("texgif_density",buf,1);
59
    setenv("texgif_density",buf,1);
60
}
60
}
61
 
61
 
Line 64... Line 64...
64
{
64
{
65
    char buf1[MAX_LINELEN+1],buf2[MAX_LINELEN+1];
65
    char buf1[MAX_LINELEN+1],buf2[MAX_LINELEN+1];
66
    struct stat st;
66
    struct stat st;
67
 
67
 
68
    if(fontname[0]=='\\') fontname++;
68
    if(fontname[0]=='\\') fontname++;
69
    else if(strncmp(fontname,mathfont_prefix,strlen(mathfont_prefix))==0)
69
    else if(strncmp(fontname,mathfont_prefix,strlen(mathfont_prefix))==0)
70
      fontname+=strlen(mathfont_prefix);
70
      fontname+=strlen(mathfont_prefix);
71
    if(strlen(fontname)==1 /* && strchr("xyz",fontname[0])==NULL */) {
71
    if(strlen(fontname)==1 /* && strchr("xyz",fontname[0])==NULL */) {
72
        char c=fontname[0];
72
     char c=fontname[0];
73
        if(!isalpha(c)) { // c is not a letter
73
     if(!isalpha(c)) { // c is not a letter
74
            buf2[0]=c;buf2[1]=0;
74
         buf2[0]=c;buf2[1]=0;
75
        }
75
     }
76
        else {
76
     else {
77
        // case of variable xyz in particular
77
// case of variable xyz in particular
78
            char *pp;
78
         char *pp;
79
            if(c=='f') pp="&nbsp;"; else pp="";
79
         if(c=='f') pp="&nbsp;"; else pp="";
80
            snprintf(buf2,sizeof(buf2),"<i>%c</i>%s",c,pp);
80
         snprintf(buf2,sizeof(buf2),"<i>%c</i>%s",c,pp);
81
//FIXME-> should we arrive here in mathml case ???
81
//FIXME-> should we arrive here in mathml case ???
82
        }
82
     }
83
    }
83
    }
84
    else {/* interpret font with at least two caracters as \RR \calB - only outside of math environment
84
    else {/* interpret font with at least two caracters as \RR \calB - only outside of math environment
85
    not useful in mathml*/
85
    not useful in mathml*/
86
#ifdef CASE_INSENSITIVE_FS
86
#ifdef CASE_INSENSITIVE_FS
87
        char *underscore;
87
     char *underscore;
88
        fix_tex_size(); underscore="";
88
     fix_tex_size(); underscore="";
89
            {
89
         {
90
                char *p, *p2;
90
          char *p, *p2;
91
                for(p=fontname; *p && !isupper(*p); p++);
91
          for(p=fontname; *p && !isupper(*p); p++);
92
                /* verify positionning of capital letter */
92
/* verify positionning of capital letter */
93
                if(*p && p>fontname && *(p+1)!=0) return NULL;
93
          if(*p && p>fontname && *(p+1)!=0) return NULL;
94
                if(p==fontname && (fontname[1]!=*p || strlen(fontname)!=2)) {
94
          if(p==fontname && (fontname[1]!=*p || strlen(fontname)!=2)) {
95
                    for(p2=p+1; *p2 && !isupper(*p2); p2++);
95
              for(p2=p+1; *p2 && !isupper(*p2); p2++);
96
                    if(*p2) return NULL;
96
              if(*p2) return NULL;
97
                }
97
          }
98
                if(*p) underscore="_";
98
          if(*p) underscore="_";
99
            }
99
         }
100
        snprintf(buf1,sizeof(buf1),"%s/%d/%s%s.gif",
100
     snprintf(buf1,sizeof(buf1),"%s/%d/%s%s.gif",
101
                 mathfont_dir,current_tex_size,fontname,underscore);
101
           mathfont_dir,current_tex_size,fontname,underscore);
102
        if(*underscore && stat(buf1,&st)!=0)
102
     if(*underscore && stat(buf1,&st)!=0)
103
          snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif",
103
       snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif",
104
                   mathfont_dir,current_tex_size,fontname);
104
             mathfont_dir,current_tex_size,fontname);
105
#else
105
#else
106
        fix_tex_size();
106
     fix_tex_size();
107
        snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif",
107
     snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif",
108
                 mathfont_dir,current_tex_size,fontname);
108
           mathfont_dir,current_tex_size,fontname);
109
#endif
109
#endif
110
        if(stat(buf1,&st)!=0) return NULL;
110
     if(stat(buf1,&st)!=0) return NULL;
111
        snprintf(buf2,sizeof(buf2),",%s,",fontname);
111
     snprintf(buf2,sizeof(buf2),",%s,",fontname);
112
        if(strstr(middle_fonts,buf2)!=NULL)
112
     if(strstr(middle_fonts,buf2)!=NULL)
113
          snprintf(buf2,sizeof(buf2),
113
       snprintf(buf2,sizeof(buf2),
114
                   "%s<img src=\"%s%s\" style=\"vertical-align: middle; border:none\" \
114
             "%s<img src=\"%s%s\" style=\"vertical-align: middle; border:none\" \
115
alt=\"%s\" />%s",
115
alt=\"%s\" />%s",
116
                   mathalign_sup1,ref_base,buf1,fontname,mathalign_sup2);
116
             mathalign_sup1,ref_base,buf1,fontname,mathalign_sup2);
117
        else
117
     else
118
          snprintf(buf2,sizeof(buf2),"<img src=\"%s%s\" style=\"margin:0px; border:none\" \
118
       snprintf(buf2,sizeof(buf2),"<img src=\"%s%s\" style=\"margin:0px; border:none\" \
119
alt=\"%s\" />",
119
alt=\"%s\" />",
120
                   ref_base,buf1,fontname);
120
             ref_base,buf1,fontname);
121
    }
121
    }
122
    force_setvar("wims_mathfont_",buf2); return getvar("wims_mathfont_");
122
    force_setvar("wims_mathfont_",buf2); return getvar("wims_mathfont_");
123
}
123
}
124
 
124