]> git.donarmstrong.com Git - lilypond.git/blob - lily/lookup.cc
release: 1.3.2
[lilypond.git] / lily / lookup.cc
1 /*
2   lookup.cc -- implement simple Lookup methods.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
8   Jan Nieuwenhuizen <janneke@gnu.org>
9
10   TODO
11       Glissando
12 */
13 #include <math.h>
14 #include <ctype.h>
15 #include "lookup.hh"
16 #include "debug.hh"
17 #include "dimensions.hh"
18
19 #include "paper-def.hh"
20 #include "string-convert.hh"
21 #include "file-path.hh"
22 #include "main.hh"
23 #include "lily-guile.hh"
24 #include "all-fonts.hh"
25 #include "afm.hh"
26 #include "scope.hh"
27 #include "molecule.hh"
28 #include "atom.hh"
29 #include "lily-guile.hh"
30
31
32 Lookup::Lookup ()
33 {
34   afm_l_ = 0;  
35 }
36
37 Lookup::Lookup (Lookup const& s)
38 {
39   font_name_ = s.font_name_;
40   afm_l_ = 0;  
41 }
42
43
44 /*
45   build a ledger line for small pieces.
46  */
47 Molecule
48 Lookup::ledger_line (Interval xwid) const
49 {
50   Drul_array<Molecule> endings;
51   endings[LEFT] = afm_find ("noteheads-ledgerending");
52   Molecule * e = &endings[LEFT];
53   endings[RIGHT] = *e;
54   
55   Real thick = e->dim_[Y_AXIS].length();
56   Real len = e->dim_[X_AXIS].length () - thick;
57
58   Molecule total;
59   Direction d = LEFT;
60   do {
61     endings[d].translate_axis (xwid[d] - endings[d].dim_[X_AXIS][d], X_AXIS);
62     total.add_molecule (endings[d]);    
63   } while ((flip(&d)) != LEFT);
64
65   Real xpos = xwid [LEFT] + len;
66
67   while (xpos + len + thick /2 <= xwid[RIGHT])
68     {
69       e->translate_axis (len, X_AXIS);
70       total.add_molecule (*e);
71       xpos += len;
72     }
73
74   return total;
75 }
76
77
78 Molecule
79 Lookup::accidental (int j, bool cautionary) const
80 {
81   Molecule m(afm_find (String ("accidentals-") + to_str (j)));
82   if (cautionary) 
83     {
84       Molecule open = afm_find (String ("accidentals-("));
85       Molecule close = afm_find (String ("accidentals-)"));
86       m.add_at_edge(X_AXIS, LEFT, Molecule(open), 0);
87       m.add_at_edge(X_AXIS, RIGHT, Molecule(close), 0);
88     }
89   return m;
90 }
91
92
93
94 Molecule
95 Lookup::afm_find (String s, bool warn) const
96 {
97   if (!afm_l_)      
98     {
99       Lookup * me = (Lookup*)(this);
100       me->afm_l_ = all_fonts_global_p->find_afm (font_name_);
101       if (!me->afm_l_)
102         {
103           warning (_f ("Can't find font: `%s'", font_name_));
104           warning (_f ("(search path: `%s')", global_path.str ().ch_C()));
105           error (_ ("Aborting"));
106         }
107     }
108   Adobe_font_char_metric cm = afm_l_->find_char (s, warn);
109   Molecule m;
110   if (cm.code () < 0)
111     {
112       /*
113         don't want people relying on this kind of dimension. 
114       */
115       m.set_empty (false);
116       return m;
117     }
118   
119   Atom at (gh_list (gh_symbol2scm ("char"),
120                     gh_int2scm (cm.code ()),
121                     SCM_UNDEFINED));
122   at.font_ = ly_symbol (font_name_.ch_C());
123   at.magn_ = gh_int2scm (0);
124   
125   m.dim_ = cm.dimensions();
126   m.add_atom (&at);
127   return m;
128 }
129
130 Molecule
131 Lookup::notehead (int j, String type) const
132 {
133   if (j > 2)
134     j = 2;
135   if (type == "harmonic" || type == "cross")
136     j = 2;
137
138   return afm_find (String ("noteheads-") + to_str (j) + type);
139 }
140
141 Molecule
142 Lookup::simple_bar (String type, Real h, Paper_def* paper_l) const
143 {
144   SCM thick = ly_symbol ("barthick_" + type);
145   Real w = 0.0;
146   
147   if (paper_l->scope_p_->elem_b (thick))
148     {
149       w = paper_l->get_realvar (thick);
150     }
151   else
152     {
153       programming_error ("No bar thickness set ! ");
154       w = 1 PT;
155     }
156   return filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
157 }
158
159   
160 Molecule
161 Lookup::bar (String str, Real h, Paper_def *paper_l) const
162 {
163   if (str == "bracket")
164     return staff_bracket (h, paper_l);
165   else if (str == "brace")
166     {
167       Real staffht  = paper_l->get_var ("staffheight");
168       return staff_brace (h,staffht);
169     }
170   Real kern = paper_l->get_var ("bar_kern");
171   Real thinkern = paper_l->get_var ("bar_thinkern");
172
173   Molecule thin = simple_bar ("thin", h, paper_l);
174   Molecule thick = simple_bar ("thick", h, paper_l);
175   Molecule colon = afm_find ("dots-repeatcolon", paper_l);  
176
177   Molecule m;
178   
179   if (str == "")
180     {
181       return fill (Box (Interval(0, 0), Interval (-h/2, h/2)));
182     }
183   if (str == "scorepostbreak")
184     {
185       return simple_bar ("score", h, paper_l);
186     }
187   else if (str == "|")
188     {
189       return thin;
190     }
191   else if (str == "|.")
192     {
193       m.add_at_edge (X_AXIS, LEFT, thick, 0);      
194       m.add_at_edge (X_AXIS, LEFT, thin, kern);
195     }
196   else if (str == ".|")
197     {
198       m.add_at_edge (X_AXIS, RIGHT, thick, 0);
199       m.add_at_edge (X_AXIS, RIGHT, thin, kern);
200     }
201   else if (str == ":|")
202     {
203       m.add_at_edge (X_AXIS, LEFT, thick, 0);
204       m.add_at_edge (X_AXIS, LEFT, thin, kern);
205       m.add_at_edge (X_AXIS, LEFT, colon, kern);      
206     }
207   else if (str == "|:")
208     {
209       m.add_at_edge (X_AXIS, RIGHT, thick, 0);
210       m.add_at_edge (X_AXIS, RIGHT, thin, kern);
211       m.add_at_edge (X_AXIS, RIGHT, colon, kern);      
212     }
213   else if (str == ":|:")
214     {
215       m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
216       m.add_at_edge (X_AXIS, LEFT, colon, kern);      
217       m.add_at_edge (X_AXIS, RIGHT, thick, kern);
218       m.add_at_edge (X_AXIS, RIGHT, colon, kern);      
219     }
220   else if (str == ".|.")
221     {
222       m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
223       m.add_at_edge (X_AXIS, RIGHT, thick, kern);      
224     }
225   else if (str == "||")
226     {
227       m.add_at_edge (X_AXIS, RIGHT, thin, 0);
228       m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);      
229     }
230
231   return m;
232 }
233
234 Molecule 
235 Lookup::beam (Real slope, Real width, Real thick) const
236 {
237   Real height = slope * width; 
238   Real min_y = (0 <? height) - thick/2;
239   Real max_y = (0 >? height) + thick/2;
240
241   
242   Molecule m;
243   Atom at
244     (gh_list (gh_symbol2scm ("beam"),
245               gh_double2scm (width),
246               gh_double2scm (slope),
247               gh_double2scm (thick),
248               SCM_UNDEFINED));
249
250   m.dim_[X_AXIS] = Interval (0, width);
251   m.dim_[Y_AXIS] = Interval (min_y, max_y);
252   m.add_atom (&at);
253   return m;
254 }
255
256 Molecule
257 Lookup::clef (String st) const
258 {
259   return afm_find (String ("clefs-" + st));
260 }
261
262 SCM
263 offset2scm (Offset o)
264 {
265   return gh_list (gh_double2scm (o[X_AXIS]), gh_double2scm(o[Y_AXIS]),
266                   SCM_UNDEFINED);
267 }
268
269 Molecule
270 Lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
271 {
272   assert (controls.size () == 8);
273   Offset d = controls[3] - controls[0];
274   
275   Real dx = d[X_AXIS];
276   Real dy = d[Y_AXIS];
277
278   Molecule m;
279
280
281   m.dim_[X_AXIS] = Interval (0, dx);
282   m.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
283
284   SCM sc[4];
285   for (int i=0; i<  4; i++)
286     {
287       sc[i] =  offset2scm (controls[i]);
288     }
289
290   Atom at
291     (gh_list (gh_symbol2scm ("dashed-slur"),
292               gh_double2scm (thick), 
293               gh_double2scm (dash),
294               ly_quote_scm (array_to_list (sc, 4)),
295               SCM_UNDEFINED));
296   
297   
298   m.add_atom (&at);
299   return m;
300 }
301
302 Molecule
303 Lookup::dots () const
304 {
305   return afm_find (String ("dots-dot"));
306 }
307
308
309
310 Molecule
311 Lookup::fill (Box b) const
312 {
313   Molecule m;
314   m.dim_ = b;
315   return m;
316 }
317
318 Molecule
319 Lookup::rest (int j, bool o, String style) const
320 {
321   return afm_find (String ("rests-") + to_str (j) + (o ? "o" : "") + style);
322 }
323
324
325 Molecule
326 Lookup::special_time_signature (String s, int n, int d, Paper_def*pap) const
327 {
328   // First guess: s contains only the signature style
329   String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
330   
331   Molecule m = afm_find (symbolname, false);
332   if (!m.empty_b()) 
333     return m;
334
335   // Second guess: s contains the full signature name
336   m = afm_find ("timesig-"+s, false);
337   if (!m.empty_b ()) 
338     return m;
339
340   // Resort to default layout with numbers
341   return time_signature (n,d,pap);
342 }
343
344 Molecule
345 Lookup::filledbox (Box b ) const
346 {
347   Molecule m;
348   
349   Atom at  (gh_list (gh_symbol2scm ("filledbox"),
350                      gh_double2scm (-b[X_AXIS][LEFT]),
351                      gh_double2scm (b[X_AXIS][RIGHT]),                 
352                      gh_double2scm (-b[Y_AXIS][DOWN]),
353                      gh_double2scm (b[Y_AXIS][UP]),                    
354                      SCM_UNDEFINED));
355
356   m.dim_ = b;
357   m.add_atom (&at);
358   return m;
359 }
360
361
362
363 /**
364    Magnification steps.  These are powers of 1.2. The numbers are
365  taken from Knuth's plain.tex: */
366
367
368 /**
369    TODO: THIS IS UGLY.  Since the user has direct access to TeX
370    strings, we try some halfbaked attempt to detect TeX trickery.
371
372 */
373 Molecule
374 Lookup::text (String style, String text, Paper_def *paper_l) const
375 {
376   Molecule m;
377   if (style.empty_b ())
378     style = "roman";
379   
380   int font_mag = 0;
381   Real font_h = paper_l->get_var ("font_normal");
382   if (paper_l->scope_p_->elem_b ("font_" + style))
383     {
384       font_h = paper_l->get_var ("font_" + style);
385     }
386
387
388   Real realmag = 1.0;
389   if (paper_l->scope_p_->elem_b ("magnification_" + style))
390     {
391       font_mag = (int)paper_l->get_var ("magnification_" + style);
392       realmag = pow (1.2, font_mag);
393     }
394
395   /*
396     UGH.
397   */
398   SCM l = ly_ch_C_eval_scm (("(style-to-cmr \"" + style + "\")").ch_C());
399   if (l != SCM_BOOL_F)
400     {
401       style = ly_scm2string (gh_cdr(l)) +to_str  ((int)font_h);
402     }
403
404   Real w = 0;
405   Interval ydims (0,0);
406
407   Font_metric* afm_l = all_fonts_global_p->find_font (style);
408   DEBUG_OUT << "\nChars: ";
409
410
411   int brace_count =0;
412   for (int i = 0; i < text.length_i (); i++) 
413     {
414       
415       if (text[i]=='\\') 
416         {
417           for (i++; (i < text.length_i ()) && isalpha(text[i]); i++)
418             ;
419           i--; // Compensate for the increment in the outer loop!
420         }
421       else
422         {
423           if (text[i] == '{')
424             brace_count ++;
425           else if (text[i] == '}')
426             brace_count --;
427           Character_metric *c = (Character_metric*)afm_l->
428             get_char ((unsigned char)text[i],false);
429
430           // Ugh, use the width of 'x' for unknown characters
431           if (c->dimensions()[X_AXIS].length () == 0) 
432             c = (Character_metric*)afm_l->get_char ((unsigned char)'x',false);
433           w += c->dimensions()[X_AXIS].length ();
434           ydims.unite (c->dimensions()[Y_AXIS]);
435         }
436     }
437
438   if(brace_count)
439     {
440       warning (_f ("Non-matching braces in text `%s', adding braces", text.ch_C()));
441
442       if (brace_count < 0)
443         {
444           text = to_str ('{', -brace_count) + text;
445         }
446       else 
447         {
448           text = text + to_str ('}', brace_count);
449         }
450     }
451
452   ydims *= realmag;
453   m.dim_.x () = Interval (0, w*realmag);
454   m.dim_.y () = ydims;
455
456   
457   Atom at  (gh_list (gh_symbol2scm ("text"),
458                      ly_str02scm (text.ch_C()),
459                      SCM_UNDEFINED));
460   at.font_ = ly_symbol (style);
461   at.magn_ = gh_int2scm (font_mag);
462   
463   m.add_atom (&at);
464   return m;
465 }
466   
467
468 Molecule
469 Lookup::time_signature (int num, int den, Paper_def *paper_l) const
470 {
471   String sty = "number";
472   Molecule n (text (sty, to_str (num), paper_l));
473   Molecule d (text (sty, to_str (den), paper_l));
474   n.align_to (X_AXIS, CENTER);
475   d.align_to (X_AXIS, CENTER);
476   Molecule m;
477   if (den)
478     {
479       m.add_at_edge (Y_AXIS, UP, n, 0.0);
480       m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
481     }
482   else
483     {
484       m = n;
485       m.align_to (Y_AXIS, CENTER);
486     }
487   return m;
488 }
489
490 Molecule
491 Lookup::staff_brace (Real y, int staff_size) const
492 {
493   Molecule m;
494   /*
495     (define (pianobrace y staffht)
496     (let* ((step 1.0)
497     (minht (* 2 staffht))
498     (maxht (* 7 minht))
499     )
500     (string-append
501     (select-font (string-append "feta-braces" (number->string (inexact->exact staffht))) 0)
502     (char (max 0 (/  (- (min y (- maxht step)) minht) step))))
503     )
504     )
505   */
506
507   Real step  = 1.0;
508   int minht  = 2 * staff_size;
509   int maxht = 7 *  minht;
510   int idx = int (((maxht - step) <? y - minht) / step);
511   idx = idx >? 0;
512   
513   SCM f =  ly_symbol (String ("feta-braces" + to_str (staff_size)));
514   SCM e =gh_list (gh_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
515   Atom at  (e);
516   at.font_ = f;
517   
518   m.dim_[Y_AXIS] = Interval (-y/2,y/2);
519   m.dim_[X_AXIS] = Interval (0,0);
520   m.add_atom (&at);
521   return m;
522 }
523
524 Molecule
525 Lookup::hairpin (Real width, Real height, Real thick, bool decresc, bool continued) const
526 {
527   Molecule m;   
528
529   String hairpin = String (decresc ? "de" : "") + "crescendo";
530   Atom at  (gh_list (ly_symbol (hairpin),
531                      gh_double2scm (thick),
532                      gh_double2scm (width),
533                      gh_double2scm (height),
534                      gh_double2scm (continued ? height/2 : 0.0),
535                      SCM_UNDEFINED));
536   m.dim_.x () = Interval (0, width);
537   m.dim_.y () = Interval (-2*height, 2*height);
538
539   m.add_atom (&at);
540   return m;
541 }
542
543 Molecule
544 Lookup::tuplet_bracket (Real dy , Real dx, Real thick, Real gap,
545                         Real height, Direction dir) const
546 {
547   Molecule m;
548
549   Atom at  (gh_list(gh_symbol2scm ("tuplet"),
550                     gh_double2scm (height),
551                     gh_double2scm (gap),
552                     gh_double2scm (dx),
553                     gh_double2scm (dy),
554                     gh_double2scm (thick),
555                     gh_int2scm (dir),
556                     SCM_UNDEFINED));
557   m.add_atom (&at);
558
559   return m;
560 }
561
562 /*
563   Make a smooth curve along the points 
564  */
565 Molecule
566 Lookup::slur (Array<Offset> controls, Real linethick) const
567 {
568   Offset  delta_off = controls[3]- controls[0];
569   Molecule m; 
570
571   SCM scontrols [8];
572   int indices[] = {5,6,7,4,1,2,3,0};
573
574   for (int i= 0; i < 8; i++)
575     scontrols[i] = offset2scm (controls[indices[i]]);
576
577
578   Atom at  (gh_list (ly_symbol ("bezier-sandwich"),
579                      ly_quote_scm (array_to_list (scontrols, 8)),
580                      gh_double2scm (linethick),
581                      SCM_UNDEFINED));
582
583   m.dim_[X_AXIS] = Interval (0, delta_off[X_AXIS]);
584   m.dim_[Y_AXIS] = Interval (0 <? delta_off[Y_AXIS], 0 >? delta_off[Y_AXIS]);
585   m.add_atom (&at);
586   return m;
587 }
588
589 Molecule
590 Lookup::staff_bracket (Real height, Paper_def* paper_l) const
591 {
592   Molecule m;
593   Atom at  ( gh_list (gh_symbol2scm ("bracket"),
594                       gh_double2scm (paper_l->get_var("bracket_arch_angle")),
595                       gh_double2scm (paper_l->get_var("bracket_arch_width")),
596                       gh_double2scm (paper_l->get_var("bracket_arch_height")),
597                       gh_double2scm (paper_l->get_var("bracket_width")),
598                       gh_double2scm (height),
599                       gh_double2scm (paper_l->get_var("bracket_arch_thick")),
600                       gh_double2scm (paper_l->get_var("bracket_thick")),
601                       SCM_UNDEFINED));
602   
603   m.add_atom (&at);                              
604   m.dim_[Y_AXIS] = Interval (-height/2,height/2);
605   m.dim_[X_AXIS] = Interval (0,4 PT);
606
607   m.translate_axis (- 4. / 3. * m.dim_[X_AXIS].length (), X_AXIS);
608   return m;
609 }
610
611 Molecule
612 Lookup::volta (Real h, Real w, Real thick, bool vert_start, bool vert_end) const
613 {
614   Molecule m; 
615
616   Atom at  (gh_list (gh_symbol2scm ("volta"),
617                      gh_double2scm (h),
618                      gh_double2scm (w),
619                      gh_double2scm (thick),
620                      gh_int2scm (vert_start),
621                      gh_int2scm (vert_end),
622                      SCM_UNDEFINED));
623
624   m.dim_[Y_AXIS] = Interval (- h/2, h/2);
625   m.dim_[X_AXIS] = Interval (0, w);
626
627   m.add_atom (&at);
628   return m;
629 }
630
631 Molecule
632 Lookup::accordion (SCM s, Real interline_f) const
633 {
634   Molecule m;
635   String sym = ly_scm2string(SCM_CAR(s));
636   String reg = ly_scm2string(SCM_CAR(SCM_CDR(s)));
637
638   if (sym == "Discant")
639     {
640       Molecule r = afm_find("scripts-accDiscant");
641       m.add_molecule(r);
642       if (reg.left_str(1) == "F")
643         {
644           Molecule d = afm_find("scripts-accDot");
645           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
646           m.add_molecule(d);
647           reg = reg.right_str(reg.length_i()-1);
648         }
649       int eflag = 0x00;
650       if (reg.left_str(3) == "EEE")
651         {
652           eflag = 0x07;
653           reg = reg.right_str(reg.length_i()-3);
654         }
655       else if (reg.left_str(2) == "EE")
656         {
657           eflag = 0x05;
658           reg = reg.right_str(reg.length_i()-2);
659         }
660       else if (reg.left_str(2) == "Eh")
661         {
662           eflag = 0x04;
663           reg = reg.right_str(reg.length_i()-2);
664         }
665       else if (reg.left_str(1) == "E")
666         {
667           eflag = 0x02;
668           reg = reg.right_str(reg.length_i()-1);
669         }
670       if (eflag & 0x02)
671         {
672           Molecule d = afm_find("scripts-accDot");
673           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
674           m.add_molecule(d);
675         }
676       if (eflag & 0x04)
677         {
678           Molecule d = afm_find("scripts-accDot");
679           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
680           d.translate_axis(0.8 * interline_f PT, X_AXIS);
681           m.add_molecule(d);
682         }
683       if (eflag & 0x01)
684         {
685           Molecule d = afm_find("scripts-accDot");
686           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
687           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
688           m.add_molecule(d);
689         }
690       if (reg.left_str(2) == "SS")
691         {
692           Molecule d = afm_find("scripts-accDot");
693           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
694           d.translate_axis(0.4 * interline_f PT, X_AXIS);
695           m.add_molecule(d);
696           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
697           m.add_molecule(d);
698           reg = reg.right_str(reg.length_i()-2);
699         }
700       if (reg.left_str(1) == "S")
701         {
702           Molecule d = afm_find("scripts-accDot");
703           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
704           m.add_molecule(d);
705           reg = reg.right_str(reg.length_i()-1);
706         }
707     }
708   else if (sym == "Freebase")
709     {
710       Molecule r = afm_find("scripts-accFreebase");
711       m.add_molecule(r);
712       if (reg.left_str(1) == "F")
713         {
714           Molecule d = afm_find("scripts-accDot");
715           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
716           m.add_molecule(d);
717           reg = reg.right_str(reg.length_i()-1);
718         }
719       if (reg == "E")
720         {
721           Molecule d = afm_find("scripts-accDot");
722           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
723           m.add_molecule(d);
724         }
725     }
726   else if (sym == "Bayanbase")
727     {
728       Molecule r = afm_find("scripts-accBayanbase");
729       m.add_molecule(r);
730       if (reg.left_str(1) == "T")
731         {
732           Molecule d = afm_find("scripts-accDot");
733           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
734           m.add_molecule(d);
735           reg = reg.right_str(reg.length_i()-1);
736         }
737       /* include 4' reed just for completeness. You don't want to use this. */
738       if (reg.left_str(1) == "F")
739         {
740           Molecule d = afm_find("scripts-accDot");
741           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
742           m.add_molecule(d);
743           reg = reg.right_str(reg.length_i()-1);
744         }
745       if (reg.left_str(2) == "EE")
746         {
747           Molecule d = afm_find("scripts-accDot");
748           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
749           d.translate_axis(0.4 * interline_f PT, X_AXIS);
750           m.add_molecule(d);
751           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
752           m.add_molecule(d);
753           reg = reg.right_str(reg.length_i()-2);
754         }
755       if (reg.left_str(1) == "E")
756         {
757           Molecule d = afm_find("scripts-accDot");
758           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
759           m.add_molecule(d);
760           reg = reg.right_str(reg.length_i()-1);
761         }
762     }
763   else if (sym == "Stdbase")
764     {
765       Molecule r = afm_find("scripts-accStdbase");
766       m.add_molecule(r);
767       if (reg.left_str(1) == "T")
768         {
769           Molecule d = afm_find("scripts-accDot");
770           d.translate_axis(interline_f * 3.5 PT, Y_AXIS);
771           m.add_molecule(d);
772           reg = reg.right_str(reg.length_i()-1);
773         }
774       if (reg.left_str(1) == "F")
775         {
776           Molecule d = afm_find("scripts-accDot");
777           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
778           m.add_molecule(d);
779           reg = reg.right_str(reg.length_i()-1);
780         }
781       if (reg.left_str(1) == "M")
782         {
783           Molecule d = afm_find("scripts-accDot");
784           d.translate_axis(interline_f * 2 PT, Y_AXIS);
785           d.translate_axis(interline_f PT, X_AXIS);
786           m.add_molecule(d);
787           reg = reg.right_str(reg.length_i()-1);
788         }
789       if (reg.left_str(1) == "E")
790         {
791           Molecule d = afm_find("scripts-accDot");
792           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
793           m.add_molecule(d);
794           reg = reg.right_str(reg.length_i()-1);
795         }
796       if (reg.left_str(1) == "S")
797         {
798           Molecule d = afm_find("scripts-accDot");
799           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
800           m.add_molecule(d);
801           reg = reg.right_str(reg.length_i()-1);
802         }
803     }
804   /* ugh maybe try to use regular font for S.B. and B.B and only use one font
805      for the rectangle */
806   else if (sym == "SB")
807     {
808       Molecule r = afm_find("scripts-accSB");
809       m.add_molecule(r);
810     }
811   else if (sym == "BB")
812     {
813       Molecule r = afm_find("scripts-accBB");
814       m.add_molecule(r);
815     }
816   else if (sym == "OldEE")
817     {
818       Molecule r = afm_find("scripts-accOldEE");
819       m.add_molecule(r);
820     }
821   else if (sym == "OldEES")
822     {
823       Molecule r = afm_find("scripts-accOldEES");
824       m.add_molecule(r);
825     }
826   return m;  
827 }
828