added math templates
[lambda.git] / jsMath / extensions / autobold.js
1 /*
2  *  extensions/autobold.js
3  *  
4  *  Part of the jsMath package for mathematics on the web.
5  *
6  *  This file causes jsMath to use \boldsymbol{...} around mathematics
7  *  that appears within <B>...</B> tags or has font-weight:bold applied
8  *  via CSS rule.  You can activate it by calling
9  *  
10  *    jsMath.Extension.Require('autobold');
11  *    
12  *  once jsMath.js has been loaded, or by adding "extensions/autobold.js"
13  *  to the loadFiles array in jsMath/easy/load.js.
14  *  
15  *  Note that you will need to install the cmmib10 and cmbsy10 fonts
16  *  that are available from the jsMath extra font page at
17  *  
18  *      http://www.math.union.edu/locate/jsMath/download/extra-fonts/
19  *
20  *  to make this work in image mode.  Note that there is no unicode
21  *  fallback for these fonts at the moment.
22  *  
23  *  ---------------------------------------------------------------------
24  *
25  *  Copyright 2008 by Davide P. Cervone
26  * 
27  *  Licensed under the Apache License, Version 2.0 (the "License");
28  *  you may not use this file except in compliance with the License.
29  *  You may obtain a copy of the License at
30  * 
31  *      http://www.apache.org/licenses/LICENSE-2.0
32  * 
33  *  Unless required by applicable law or agreed to in writing, software
34  *  distributed under the License is distributed on an "AS IS" BASIS,
35  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36  *  See the License for the specific language governing permissions and
37  *  limitations under the License.
38  */
39
40 /********************************************************************/
41
42 jsMath.Extension.Require("boldsymbol");
43
44 jsMath.Translate.OldParse = jsMath.Translate.Parse;
45 jsMath.Translate.Parse = function (style,text,noCache) {
46   if (jsMath.BBoxFor('</SPAN></SPAN><SPAN STYLE="font-family:Times,serif">MMMMMMMMMM</SPAN><SPAN><SPAN>').w >
47       jsMath.BBoxFor('</SPAN></SPAN><SPAN STYLE="font-family:Times,serif; font-weight:normal">MMMMMMMMMM</SPAN><SPAN><SPAN>').w) {
48     text = '\\boldsymbol{' + text + '}';
49   }
50   return jsMath.Translate.OldParse(style,text,noCache);
51 }