summaryrefslogtreecommitdiff
path: root/support/w2latex/rtf.fonts.c
blob: c277c19afa41a3198e42cf20d64129e82ce83ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#define MaxFontsTex 21
typedef struct _E_Q_FONTS_ { char * FontRTF; char * FontTeX; } EQFonts;
EQFonts EqFontsRTF_TeX[MaxFontsTex]=
{ { "Times New Roman", "\\pzrm " },
  { "Arial", "\\pzrm " },
  { "AvantGarde", "\\pzrm " },
  { "Bookman", "\\pzrm " },
  { "Courier", "\\tt " },
  { "Courier New", "\\tt " },
  { "Fences", "\\pzrm " },
  { "Helvetica", "\\pzrm\\bf " },
  { "Helvetica-Narrow", "\\pzrm " },
  { "Modern", "\\pzrm " },
  { "MS LineDraw", "\\pzrm " },
  { "MT Extra", "\\pzrm " },
  { "NewCenturySchlbk", "\\pzrm " },
  { "Palatino", "\\pzrm " },
  { "Roman", "\\pzrm " },
  { "Script", "\\pzrm\\it " },
  { "Symbol", "\\pzrm " },
  { "Times", "\\pzrm " },
  { "Wingdings", "\\pzrm " },
  { "ZapfChancery", "\\pzrm \\it " },
  { "ZapfDingbats", "\\pzrm " },
};
typedef struct _E_Q_TAILLES_ { int tailleRTF; char * tailleTeX; } EQTailles;
#define MaxTaillesTex 25
EQTailles EqTailles_TeX[MaxTaillesTex]=
{ { 1, "\\tiny " },   { 2, "\\tiny " },       { 3, "\\tiny " },       { 4, "\\tiny " },   { 5, "\\tiny " },
  { 6, "\\tiny " },   { 7, "\\scriptsize " }, { 8, "\\footnotesize " }, { 9, "\\small " }, 
  { 10, "\\normalsize " }, { 11, "\\normalsize " }, { 12, "\\large " }, { 13, "\\large " }, { 14, "\\Large " }, 
  { 15, "\\Large " }, { 16, "\\Large " },     { 17, "\\LARGE " },     { 18, "\\LARGE " }, { 19, "\\LARGE " }, 
  { 20, "\\huge " },  { 21, "\\huge " },      { 22, "\\huge " },      { 23, "\\huge " },  { 24, "\\huge " }, 
  { 25, "\\Huge " },
};
#define MaxSymboles 256
char FontSymboles[MaxSymboles][25]=
{ "@","@","@","@","@","@","@","@",
  "@","@","@","@","@","@","@","@",
  "@","@","@","@","@","@","@","@",
  "@","@","@","@","@","@","@","@",
  "","!","\\forall ","\\#=","\\exists ","\\%","\\&","\\exists ",
  "(",")","*","+",",","-",".","/",
  "0","1","2","3","4","5","6","7",
  "8","9",":",";","<","=",">","?",
  "\\cong ","A","B","X","\\Delta ","E","\\Phi ","\\Gamma ",
  "H","I","\\vartheta ","K","\\Lambda ","M","N","O",
  "\\Pi ","\\Theta ","P","\\Sigma ","T","Y","\\varsigma ","\\Omega ",
  "\\Xi ","\\Psi ","Z","[","\\, ","]","\\perp ","\\_",
  "\\_","\\alpha ","\\beta ","\\chi ","\\delta ","\\varepsilon ","\\phi ","\\gamma ",
  "\\eta ","\\iota ","\\varphi ","\\kappa ","\\lambda ","\\mu ","\\nu ","o",
  "\\pi ","\\theta ","\\rho ","\\sigma ","\\tau ","\\upsilon ","\\varpi ","\\omega ",
  "\\xi ","\\psi ","\\zeta ","\\{","|","\\}","\\~{}","@",
  "@","@","@","@","@","@","@","@",
  "@","@","@","@","@","@","@","@",
  "@","@","@","@","@","@","@","@",
  "@","@","@","@","@","@","@","@",
  "@","\\Upsilon ","'","\\leq ","/","\\infinity ","f","\\clubsuit ",
  "\\diamondsuit ","\\heartsuit ","\\spadesuite ","\\leftrightarrow ","\\leftarrow ",
		"\\uparrow ","\\rightarrow ","\\downarrow ",
  "\\circ ","\\pm ","@","\\geq ","\\times ","\\propto ","\\partial ","\\bullet ",
  "\\div ","\\neq ","\\equiv ","\\approx ","\\cdots ","\\mid","-","\\hookleftarrow ",
  "\\aleph ","\\Im ","\\Re ","@","\\otimes ","\\oplus ","\\oslash ","\\cap ",
  "\\cup ","\\supset ","\\supseteq ","\\not\\subset ","\\subset ","\\subseteq ","\\in ","\\not\\in ",
  "\\angle ","\\bigtriangledown ","\\copyright ","\\copyright ","\\copyright ","\\Pi ","\\surd ","\\cdot ",
  "\\neg ","\\wedge ","\\vee ","\\Leftrightarrow ","\\Leftarrow ","\\Uparrow ","\\Rightarrow ","\\Downarrow ",
  "\\diamond ","\\angle ","\\copyright ","\\copyright ","\\copyright ","\\Sigma ","{\\mathex \\char'060 }",
		"{\\mathex \\char'102 }",
  "{\\mathex \\char'100 }","{\\mathex \\char'062 }","{\\mathex \\char'102 }","{\\mathex \\char'064 }",
		"{\\mathex \\char'070 }","{\\mathex \\char'074 }","{\\mathex \\char'072 }","{\\mathex \\char'102 }",
  "@","{\\mathex \\char'105 }","{\\mathex \\char'122 }","{\\mathex \\char'070 }","{\\mathex \\char'102 }","{\\mathex \\char'073 }",
		"{\\mathex \\char'061 }","{\\mathex \\char'102 }",
  "{\\mathex \\char'101 }","{\\mathex \\char'063 }","{\\mathex \\char'102 }","{\\mathex \\char'065 }",
		"{\\mathex \\char'071 }","{\\mathex \\char'075 }","{\\mathex \\char'073 }","@"
};
											       
char * chercheEqTeX(char * );
/**************************************************************************************************
**	Function name : nouvfonte
**
**	Description : Cree un nouveau maillon avec la description d'une fonte 
**	Input : Declarations sur les fontes
**	Output : Pointeur sur le maillon cree.
**************************************************************************************************/
p_LFonte nouvfonte(int NLF_Fontnum, int NLF_Fontfamily, int NLF_Fcharset, 
		   int NLF_Fprq, char * NLF_Fontname)
{
  p_LFonte LFtemp=DebLisFontes;
  char * pcalutemp;
  if (LFtemp!=NULL)
    {
      while(LFtemp->suiv!=NULL)
	LFtemp=LFtemp->suiv;
      LFtemp->suiv=(p_LFonte) malloc (sizeof(t_LFonte));
      LFtemp=LFtemp->suiv;
    }
  else
    {
      LFtemp=(p_LFonte) malloc (sizeof(t_LFonte));
      DebLisFontes=LFtemp;
    };
  LFtemp->LF_Fontnum=NLF_Fontnum;
  LFtemp->LF_Fontfamily=NLF_Fontfamily;
  LFtemp->LF_Fcharset=NLF_Fcharset;
  LFtemp->LF_Fprq=NLF_Fprq;
  LFtemp->LF_Fontname=(char *) malloc (strlen(NLF_Fontname)+1);
  strcpy(LFtemp->LF_Fontname,NLF_Fontname);
  pcalutemp=chercheEqTeX(NLF_Fontname);
  LFtemp->LF_TexEquiv=(char *) malloc (strlen(pcalutemp)+1);
  strcpy(LFtemp->LF_TexEquiv,pcalutemp);
  LFtemp->suiv=NULL;
}

/**************************************************************************************************
**	Function name : cherchefonte
**
**	Description : A partir du numero de fonte, cherche une fonte donnee.
**	Input : Numero de fonte.
**	Output : Pointeur sur le maillon contenant les caracteristiques.
**************************************************************************************************/
p_LFonte cherchefonte(int CLFnum)
{
  p_LFonte LFtemp=DebLisFontes;
  while (LFtemp!=NULL && LFtemp->LF_Fontnum!=CLFnum)
    LFtemp=LFtemp->suiv;
  return LFtemp;
}

/**************************************************************************************************
**	Function name : parcoursfontes
**
**	Description :
**	Input :
**	Output :
**************************************************************************************************/
parcoursfontes()
{
/*  p_LFonte LFtemp=DebLisFontes;
  while (LFtemp!=NULL)
    {
      fprintf(stderr,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
      fprintf(stderr,"LF_Fontnum:%d;\nLF_Fontfamily:%d;\n",LFtemp->LF_Fontnum,LFtemp->LF_Fontfamily);
      fprintf(stderr,"LF_Fcharset:%d;\nLF_Fprq:%d;\n",LFtemp->LF_Fcharset,LFtemp->LF_Fprq);
      fprintf(stderr,"LF_Fontname:%s;\nLF_TexEquiv%s\n",LFtemp->LF_Fontname,LFtemp->LF_TexEquiv);
      fprintf(stderr,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
      LFtemp=LFtemp->suiv;
    }*/
}

/**************************************************************************************************
**	Function name : chercheEqTeX
**
**	Description : Cherche un equivalent TeX pour un nom de fonte RTF
**	Input : Nom de la fonte RTF
**	Output : Equivalent TeX (ou police par defaut sinon.
**************************************************************************************************/
char * chercheEqTeX(char * FontNameRTF)
{
  int i;
  for (i=0;i<MaxFontsTex;i++)
    {
      if (strcmp(FontNameRTF,EqFontsRTF_TeX[i].FontRTF)==0)
	return EqFontsRTF_TeX[i].FontTeX;
    }
  /* Si on est toujours la, c'est qu'on n'a pas trouve de fonte correspondante: On prends la valeur par
     defaut: Times New Roman ou cmr10 */
  return "\\pzrm ";
}

/**************************************************************************************************
**	Function name : EqTeXTaille
**
**	Description : Determine la taille de police a utiliser, a partir de la donnee RTF, 
                      et retourne la chaine de caracteres equivalente TeX.
**	Input : Taille de la police en demi-points.
**	Output : Equivalent TeX
**************************************************************************************************/
char * EqTeXTaille(int TailleRTF)
{
  TailleRTF/=2;
  if (TailleRTF<1)
    return EqTailles_TeX[0].tailleTeX;
  if (TailleRTF>MaxTaillesTex)
    return EqTailles_TeX[MaxTaillesTex-1].tailleTeX;
  return EqTailles_TeX[TailleRTF-1].tailleTeX;
}

/**************************************************************************************************
**	Function name : printSymbol
**
**	Description :
**	Input : char * chaineIN
**	Output : void
**************************************************************************************************/
void printSymbol(char * chaineIN)
{
  int i=0;
  for (i=0;i<strlen(chaineIN);i++)
    fprintf(SORT,"%s",FontSymboles[chaineIN[i]]);
}

/**************************************************************************************************
**	Function name : printText
**
**	Description :
**	Input : char * chaineIN
**	Output : void
**************************************************************************************************/
void printText(char * chaineIN)
{
  int i=0;
  for (i=0;i<strlen(chaineIN);i++)
    {
      if ((chaineIN[i]=='|' || chaineIN[i]=='<' || chaineIN[i]=='>') && FLAG_Equation==0)
	{
	  fprintf(SORT,"$%c$",chaineIN[i]);
	}
      else fprintf(SORT,"%c",chaineIN[i]);
    }
}

/**************************************************************************************************
**	Function name : printApostrophe
**
**	Description :
**	Input : int ulluIN
**	Output : void
**************************************************************************************************/
void printApostrophe(int ulluIN)
{
  if (FLAG_Equation==0)
    {
      if (ulluIN<238)
	fprintf(SORT,"$%s$",FontSymboles[ulluIN]);
      else
	fprintf(SORT,"%s",FontSymboles[ulluIN]);
    }
  else 
    {
      if (ulluIN<238)
	fprintf(SORT,"%s",FontSymboles[ulluIN]);
      else
	fprintf(SORT,"$%s$",FontSymboles[ulluIN]);
    }
}