Rev 14535 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
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 |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
8185 | bpr | 18 | #include "wims.h" |
19 | |||
7673 | bpr | 20 | /* fonts which should have align=middle */ |
10 | reyssat | 21 | char *middle_fonts=",y,beta,eta,mu,phi,rho,varphi,psi,\ |
22 | le,leq,ge,geq,pm,ne,neq,\ |
||
23 | subseteq,supseteq,wp,\ |
||
24 | int,oint,Vert,\ |
||
25 | QQ,\ |
||
26 | leftpar2,leftpar3,leftpar4,leftpar5,leftpar6,\ |
||
27 | leftpar7,leftpar8,leftpar9,leftpar10,leftpar11,leftpar12,\ |
||
28 | rightpar2,rightpar3,rightpar4,rightpar5,rightpar6,\ |
||
29 | rightpar7,rightpar8,rightpar9,rightpar10,rightpar11,rightpar12,\ |
||
30 | leftbrace2,leftbrace3,leftbrace4,leftbrace5,leftbrace6,\ |
||
31 | leftbrace7,leftbrace8,leftbrace9,leftbrace10,leftbrace11,leftbrace12,\ |
||
32 | rightbrace2,rightbrace3,rightbrace4,rightbrace5,rightbrace6,\ |
||
33 | rightbrace7,rightbrace8,rightbrace9,rightbrace10,rightbrace11,rightbrace12,"; |
||
34 | |||
7673 | bpr | 35 | /* These are temporary definitions. */ |
10 | reyssat | 36 | char *mathfont_dir="mathfonts"; |
37 | |||
8155 | bpr | 38 | /* tex font size list */ |
10 | reyssat | 39 | int texsize_list[]={63,69,76,83,91,100,109,120,131,144,158,173}; |
40 | int texbasesize=6; /* defaults to 109 */ |
||
41 | int usertexsize=-1; /* non-negative if defined */ |
||
42 | #define texsize_no (sizeof(texsize_list)/sizeof(texsize_list[0])) |
||
43 | |||
44 | int current_tex_size; |
||
45 | |||
46 | void fix_tex_size(void) |
||
47 | { |
||
12240 | bpr | 48 | char buf[64],*p; int i,ts; |
49 | ts=texbasesize; |
||
50 | if(usertexsize>=0) ts=usertexsize+1; |
||
51 | if(getwimstexsize) p=getvar("wims_texsize"); else p=NULL; |
||
52 | if(p!=NULL && *p!=0) { |
||
53 | i=evalue(p); |
||
54 | if(i>=-5 && i<=5) ts+=i; |
||
55 | } |
||
56 | if(ts<0) ts=0; |
||
57 | if(ts>=texsize_no) ts=texsize_no-1; |
||
58 | current_tex_size=texsize_list[ts]; |
||
59 | snprintf(buf,sizeof(buf),"%d",current_tex_size); |
||
60 | setenv("texgif_density",buf,1); |
||
10 | reyssat | 61 | } |
62 | |||
8155 | bpr | 63 | /* takes math font image file string */ |
10 | reyssat | 64 | char *mathfont(char *fontname) |
65 | { |
||
12240 | bpr | 66 | char buf1[MAX_LINELEN+1],buf2[MAX_LINELEN+1]; |
67 | struct stat st; |
||
10 | reyssat | 68 | |
12240 | bpr | 69 | if(fontname[0]=='\\') fontname++; |
70 | else if(strncmp(fontname,mathfont_prefix,strlen(mathfont_prefix))==0) |
||
71 | fontname+=strlen(mathfont_prefix); |
||
72 | if(strlen(fontname)==1 /* && strchr("xyz",fontname[0])==NULL */) { |
||
73 | char c=fontname[0]; |
||
74 | if(!isalpha(c)) { // c is not a letter |
||
75 | buf2[0]=c;buf2[1]=0; |
||
76 | } |
||
77 | else { |
||
7673 | bpr | 78 | // case of variable xyz in particular |
12240 | bpr | 79 | char *pp; |
80 | if(c=='f') pp=" "; else pp=""; |
||
81 | snprintf(buf2,sizeof(buf2),"<i>%c</i>%s",c,pp); |
||
5523 | bpr | 82 | //FIXME-> should we arrive here in mathml case ??? |
10 | reyssat | 83 | } |
12240 | bpr | 84 | } |
85 | else {/* interpret font with at least two caracters as \RR \calB - only outside of math environment |
||
5461 | bpr | 86 | not useful in mathml*/ |
12240 | bpr | 87 | char *underscore; |
88 | fix_tex_size(); underscore=""; |
||
89 | { |
||
90 | char *p, *p2; |
||
91 | for(p=fontname; *p && !isupper(*p); p++); |
||
7673 | bpr | 92 | /* verify positionning of capital letter */ |
12240 | bpr | 93 | if(*p && p>fontname && *(p+1)!=0) return NULL; |
94 | if(p==fontname && (fontname[1]!=*p || strlen(fontname)!=2)) { |
||
95 | for(p2=p+1; *p2 && !isupper(*p2); p2++); |
||
96 | if(*p2) return NULL; |
||
97 | } |
||
98 | if(*p) underscore="_"; |
||
99 | } |
||
100 | snprintf(buf1,sizeof(buf1),"%s/%d/%s%s.gif", |
||
7673 | bpr | 101 | mathfont_dir,current_tex_size,fontname,underscore); |
12240 | bpr | 102 | if(*underscore && stat(buf1,&st)!=0) |
103 | snprintf(buf1,sizeof(buf1),"%s/%d/%s.gif", |
||
7673 | bpr | 104 | mathfont_dir,current_tex_size,fontname); |
8179 | bpr | 105 | |
12240 | bpr | 106 | if(stat(buf1,&st)!=0) return NULL; |
107 | snprintf(buf2,sizeof(buf2),",%s,",fontname); |
||
108 | if(strstr(middle_fonts,buf2)!=NULL) |
||
109 | snprintf(buf2,sizeof(buf2), |
||
7673 | bpr | 110 | "%s<img src=\"%s%s\" style=\"vertical-align: middle; border:none\" \ |
17177 | bpr | 111 | alt=\"%s\">%s", |
7673 | bpr | 112 | mathalign_sup1,ref_base,buf1,fontname,mathalign_sup2); |
12240 | bpr | 113 | else |
7673 | bpr | 114 | snprintf(buf2,sizeof(buf2),"<img src=\"%s%s\" style=\"margin:0px; border:none\" \ |
17177 | bpr | 115 | alt=\"%s\">", |
7673 | bpr | 116 | ref_base,buf1,fontname); |
12240 | bpr | 117 | } |
118 | force_setvar("wims_mathfont_",buf2); return getvar("wims_mathfont_"); |
||
10 | reyssat | 119 | } |