added jsMath files
[lambda.git] / jsMath / extensions / font.js
1 jsMath.Package(jsMath.Parser,{
2
3   macros: {font: 'Font'},
4   fontCS: {},
5   
6   /*
7    *  Get a CS name or give an error
8    */
9   GetCSname: function (cmd) {
10     var c = this.GetNext();
11     if (c != this.cmd) {this.Error(cmd+" must be followed by a control sequence"); return null}
12     var cs = this.trimSpaces(this.GetArgument(cmd)); if (this.error) {return null};
13     return cs.substr(1);
14   },
15
16   /*
17    *  Handle the \font command
18    */
19   Font: function (name) {
20     var cs = this.GetCSname(this.cmd+name); if (this.error) return;
21     while (this.nextIsSpace()) {this.i++}
22     if (this.string.charAt(this.i++) == '=') {
23       while (this.nextIsSpace()) {this.i++}
24       var font = this.string.slice(this.i).match(/^[a-z]+[0-9]+/i);
25       if (font) {
26         this.i += (new String(font)).length;
27         if (jsMath.TeX.famName[font] != null) {
28           this.macros[cs] = ['HandleFont',jsMath.TeX.famName[font]];
29         } else {
30           this.macros[cs] = ['Extension',jsMath.Font.URL(font),"fontCS"];
31           this.fontCS[cs] = 1; // so Extension has something to delete
32         }
33       } else {this.Error("Missing font name")}
34     } else {this.Error("Missing font definition")}
35   }
36   
37 });
38