]> git.donarmstrong.com Git - lilypond.git/blob - lily/lookup.cc
release: 1.1.49
[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
14 #include <ctype.h>
15 #include "lookup.hh"
16 #include "debug.hh"
17 #include "dimensions.hh"
18 #include "scalar.hh"
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 open `%s'\n", font_name_));
104           warning (_f("Search path %s\n", global_path.str ().ch_C()));
105           error (_f("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 (char_scm_sym,
120                     gh_int2scm (cm.code ()),
121                     SCM_UNDEFINED));
122   at.font_ = ly_symbol (font_name_.ch_C());
123   m.dim_ = cm.dimensions();
124   m.add_atom (&at);
125   return m;
126 }
127
128 Molecule
129 Lookup::notehead (int j, String type) const
130 {
131   if (j > 2)
132     j = 2;
133
134   return afm_find (String ("noteheads-") + to_str (j) + type);
135 }
136
137 Molecule
138 Lookup::simple_bar (String type, Real h, Paper_def* paper_l) const
139 {
140   SCM thick = ly_symbol ("barthick_" + type);
141   Real w = 0.0;
142   
143   if (paper_l->scope_p_->elem_b (thick))
144     {
145       w = paper_l->get_realvar (thick);
146     }
147   else
148     {
149       programming_error ("No bar thickness set ! ");
150       w = 1 PT;
151     }
152   return filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
153 }
154
155   
156 Molecule
157 Lookup::bar (String str, Real h, Paper_def *paper_l) const
158 {
159   if (str == "[")
160     return staff_bracket (h);
161   else if (str == "{")
162     return staff_brace (h);
163   
164   Real kern = paper_l->get_var ("bar_kern");
165   Real thinkern = paper_l->get_var ("bar_thinkern");
166   
167   Molecule thin = simple_bar ("thin", h, paper_l);
168   Molecule thick = simple_bar ("thick", h, paper_l);
169   Molecule colon = afm_find ("dots-repeatcolon", paper_l);  
170
171   Molecule m;
172   
173   if (str == "")
174     {
175       return fill (Box (Interval(0, 0), Interval (-h/2, h/2)));
176     }
177   if (str == "scorepostbreak")
178     {
179       return simple_bar ("score", h, paper_l);
180     }
181   else if (str == "|")
182     {
183       return thin;
184     }
185   else if (str == "|.")
186     {
187       m.add_at_edge (X_AXIS, LEFT, thick, 0);      
188       m.add_at_edge (X_AXIS, LEFT, thin, kern);
189     }
190   else if (str == ".|")
191     {
192       m.add_at_edge (X_AXIS, RIGHT, thick, 0);
193       m.add_at_edge (X_AXIS, RIGHT, thin, kern);
194     }
195   else if (str == ":|")
196     {
197       m.add_at_edge (X_AXIS, LEFT, thick, 0);
198       m.add_at_edge (X_AXIS, LEFT, thin, kern);
199       m.add_at_edge (X_AXIS, LEFT, colon, kern);      
200     }
201   else if (str == "|:")
202     {
203       m.add_at_edge (X_AXIS, RIGHT, thick, 0);
204       m.add_at_edge (X_AXIS, RIGHT, thin, kern);
205       m.add_at_edge (X_AXIS, RIGHT, colon, kern);      
206     }
207   else if (str == ":|:")
208     {
209       m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
210       m.add_at_edge (X_AXIS, LEFT, colon, kern);      
211       m.add_at_edge (X_AXIS, RIGHT, thick, kern);
212       m.add_at_edge (X_AXIS, RIGHT, colon, kern);      
213     }
214   else if (str == ".|.")
215     {
216       m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
217       m.add_at_edge (X_AXIS, RIGHT, thick, kern);      
218     }
219   else if (str == "||")
220     {
221       m.add_at_edge (X_AXIS, RIGHT, thin, 0);
222       m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);      
223     }
224
225   return m;
226 }
227
228 Molecule 
229 Lookup::beam (Real slope, Real width, Real thick) const
230 {
231   Real height = slope * width; 
232   Real min_y = (0 <? height) - thick/2;
233   Real max_y = (0 >? height) + thick/2;
234
235   
236   Molecule m;
237   Atom at
238      (gh_list (beam_scm_sym,
239                                 gh_double2scm (width),
240                                 gh_double2scm (slope),
241                                 gh_double2scm (thick),
242                                 SCM_UNDEFINED));
243
244   m.dim_[X_AXIS] = Interval (0, width);
245   m.dim_[Y_AXIS] = Interval (min_y, max_y);
246   m.add_atom (&at);
247   return m;
248 }
249
250 Molecule
251 Lookup::clef (String st) const
252 {
253   return afm_find (String ("clefs-" + st));
254 }
255
256 SCM
257 offset2scm (Offset o)
258 {
259   return gh_list (gh_double2scm (o[X_AXIS]), gh_double2scm(o[Y_AXIS]),
260                   SCM_UNDEFINED);
261 }
262
263 Molecule
264 Lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
265 {
266   assert (controls.size () == 8);
267   Offset d = controls[3] - controls[0];
268   
269   Real dx = d[X_AXIS];
270   Real dy = d[Y_AXIS];
271
272   Molecule m;
273
274
275   m.dim_[X_AXIS] = Interval (0, dx);
276   m.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
277
278   SCM sc[4];
279   for (int i=0; i<  4; i++)
280     {
281       sc[i] =  offset2scm (controls[i]);
282     }
283
284   Atom at
285     (gh_list (ly_symbol ("dashed-slur"),
286               gh_double2scm (thick), 
287               gh_double2scm (dash),
288               ly_quote_scm (array_to_list (sc, 4)),
289               SCM_UNDEFINED));
290   
291   
292   m.add_atom (&at);
293   return m;
294 }
295
296 Molecule
297 Lookup::dots () const
298 {
299   return afm_find (String ("dots-dot"));
300 }
301
302
303
304 Molecule
305 Lookup::fill (Box b) const
306 {
307   Molecule m;
308   m.dim_ = b;
309   return m;
310 }
311
312 Molecule
313 Lookup::flag (int j, Direction d) const
314 {
315   char c = (d == UP) ? 'u' : 'd';
316   return  afm_find (String ("flags-") + to_str (c) + to_str (j));
317 }
318
319 Molecule
320 Lookup::rest (int j, bool o, String style) const
321 {
322   return afm_find (String ("rests-") + to_str (j) + (o ? "o" : "") + style);
323 }
324
325
326 Molecule
327 Lookup::special_time_signature (String s, int n, int d, Paper_def*pap) const
328 {
329   // First guess: s contains only the signature style
330   String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
331   
332   Molecule m = afm_find (symbolname, false);
333   if (!m.empty_b()) 
334     return m;
335
336   // Second guess: s contains the full signature name
337   m = afm_find ("timesig-"+s, false);
338   if (!m.empty_b ()) 
339     return m;
340
341   // Resort to default layout with numbers
342   return time_signature (n,d,pap);
343 }
344
345 Molecule
346 Lookup::filledbox (Box b ) const
347 {
348   Molecule m;
349   
350   Atom at  (gh_list (filledbox_scm_sym,
351                      gh_double2scm (-b[X_AXIS][LEFT]),
352                      gh_double2scm (b[X_AXIS][RIGHT]),                 
353                      gh_double2scm (-b[Y_AXIS][DOWN]),
354                      gh_double2scm (b[Y_AXIS][UP]),                    
355                      SCM_UNDEFINED));
356
357   m.dim_ = b;
358   m.add_atom (&at);
359   return m;
360 }
361
362
363
364 /**
365    Magnification steps.  These are powers of 1.2. The numbers are
366  taken from Knuth's plain.tex: */
367 static Real mag_steps[] = {1, 1, 1.200, 1.440, 1.7280,  2.074, 2.488};
368
369 /**
370    TODO: THIS IS UGLY.  Since the user has direct access to TeX
371    strings, we try some halfbaked attempt to detect TeX trickery.
372
373 */
374 Molecule
375 Lookup::text (String style, String text, Paper_def *paper_l) const
376 {
377   Molecule m;
378   if (style.empty_b ())
379     style = "roman";
380   
381   int font_mag = 1;
382   Real font_h = paper_l->get_var ("font_normal");
383   if (paper_l->scope_p_->elem_b ("font_" + style))
384     {
385       font_h = paper_l->get_var ("font_" + style);
386     }
387    
388   if (paper_l->scope_p_->elem_b ("magnification_" + style))
389     {
390       font_mag = (int)paper_l->get_var ("magnification_" + style);
391     }
392
393   /*
394     UGH.
395   */
396   SCM l = gh_eval_str (("(style-to-cmr \"" + style + "\")").ch_C());
397   if (l != SCM_BOOL_F)
398     {
399       style = ly_scm2string (SCM_CDR(l)) +to_str  ((int)font_h);
400     }
401
402   Real w = 0;
403   Interval ydims (0,0);
404
405   Font_metric* afm_l = all_fonts_global_p->find_font (style);
406   DOUT << "\nChars: ";
407
408
409   int brace_count =0;
410   for (int i = 0; i < text.length_i (); i++) 
411     {
412       
413       if (text[i]=='\\') 
414         {
415           for (i++; (i < text.length_i ()) && isalpha(text[i]); i++)
416             ;
417           i--; // Compensate for the increment in the outer loop!
418         }
419       else
420         {
421           if (text[i] == '{')
422             brace_count ++;
423           else if (text[i] == '}')
424             brace_count --;
425           Character_metric *c = afm_l->get_char ((unsigned char)text[i],false);
426
427           w += c->dimensions()[X_AXIS].length ();
428           ydims.unite (c->dimensions()[Y_AXIS]);
429         }
430     }
431
432   if (font_mag > 1 && font_mag < 7 )
433     {
434       /* UGH  */ 
435       style = style + String(" scaled \\magstep ") + to_str (font_mag);
436       w *= mag_steps[font_mag];
437       ydims *= mag_steps[font_mag];
438     }
439
440   if(brace_count)
441     {
442       warning (_f ("Non-matching braces in text `%s', adding braces.", text.ch_C()));
443
444       if (brace_count < 0)
445         {
446           text = to_str ('{', -brace_count) + text;
447         }
448       else 
449         {
450           text = text + to_str ('}', brace_count);
451         }
452     }
453
454   
455   DOUT << "\n" << to_str (w) << "\n";
456   m.dim_.x () = Interval (0, w);
457   m.dim_.y () = ydims;
458
459   
460   Atom at  (gh_list (text_scm_sym,
461                      gh_str02scm (text.ch_C()),
462                      SCM_UNDEFINED));
463   at.font_ = ly_symbol (style);
464   
465   m.add_atom (&at);
466   return m;
467 }
468   
469
470 Molecule
471 Lookup::time_signature (int num, int den, Paper_def *paper_l) const
472 {
473   String sty = "number";
474   Molecule n (text (sty, to_str (num), paper_l));
475   Molecule d (text (sty, to_str (den), paper_l));
476   n.align_to (X_AXIS, CENTER);
477   d.align_to (X_AXIS, CENTER);
478   Molecule m;
479   if (den)
480     {
481       m.add_at_edge (Y_AXIS, UP, n, 0.0);
482       m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
483     }
484   else
485     {
486       m = n;
487       m.align_to (Y_AXIS, CENTER);
488     }
489   return m;
490 }
491
492 Molecule
493 Lookup::staff_brace (Real y) const
494 {
495   Molecule m;
496   
497   Atom at  (gh_list (pianobrace_scm_sym,
498                      gh_double2scm (y),
499                      SCM_UNDEFINED
500                      ));
501   
502   m.dim_[Y_AXIS] = Interval (-y/2,y/2);
503   m.dim_[X_AXIS] = Interval (0,0);
504   m.add_atom (&at);
505   return m;
506 }
507
508 Molecule
509 Lookup::hairpin (Real width, Real height, bool decresc, bool continued) const
510 {
511   Molecule m;   
512
513   String hairpin = String (decresc ? "de" : "") + "crescendo";
514   Atom at  (gh_list (ly_symbol (hairpin),
515                      gh_double2scm (width),
516                      gh_double2scm (height),
517                      gh_double2scm (continued ? height/2 : 0.0),
518                      SCM_UNDEFINED));
519   m.dim_.x () = Interval (0, width);
520   m.dim_.y () = Interval (-2*height, 2*height);
521
522   m.add_atom (&at);
523   return m;
524 }
525
526 Molecule
527 Lookup::tuplet_bracket (Real dy , Real dx, Real thick, Real interline_f, Direction dir) const
528 {
529   Molecule m;
530
531   Atom at  (gh_list(tuplet_scm_sym,
532                     gh_double2scm (interline_f), 
533                     gh_double2scm (dx),
534                     gh_double2scm (dy),
535                     gh_double2scm (thick),
536                     gh_int2scm (dir),
537                     SCM_UNDEFINED));
538   m.add_atom (&at);
539
540   return m;
541 }
542
543 /*
544   Make a smooth curve along the points 
545  */
546 Molecule
547 Lookup::slur (Array<Offset> controls) const
548 {
549   Offset  delta_off = controls[3]- controls[0];
550   Molecule m; 
551
552   SCM scontrols [8];
553   int indices[] = {5,6,7,4,1,2,3,0};
554
555   for (int i= 0; i < 8; i++)
556     scontrols[i] = offset2scm (controls[indices[i]]);
557
558
559   Atom at  (gh_list (ly_symbol ("bezier-sandwich"),
560                      ly_quote_scm (array_to_list (scontrols, 8)),
561                      SCM_UNDEFINED));
562
563   m.dim_[X_AXIS] = Interval (0, delta_off[X_AXIS]);
564   m.dim_[Y_AXIS] = Interval (0 <? delta_off[Y_AXIS], 0 >? delta_off[Y_AXIS]);
565   m.add_atom (&at);
566   return m;
567 }
568
569 Molecule
570 Lookup::staff_bracket (Real y) const
571 {
572   Molecule m; 
573   Atom at  ( gh_list (bracket_scm_sym,
574                       gh_double2scm (y),
575                       SCM_UNDEFINED));
576   m.add_atom (&at);                              
577   m.dim_[Y_AXIS] = Interval (-y/2,y/2);
578   m.dim_[X_AXIS] = Interval (0,4 PT);
579
580   m.translate_axis (- 4. / 3. * m.dim_[X_AXIS].length (), X_AXIS);
581   return m;
582 }
583
584 Molecule
585 Lookup::volta (Real w, Real thick, Real interline_f, bool last_b) const
586 {
587   Molecule m; 
588
589   Atom at  (gh_list (volta_scm_sym,
590                      gh_double2scm (w),
591                      gh_double2scm (thick),
592                      gh_int2scm (last_b),
593                      SCM_UNDEFINED));
594
595   m.dim_[Y_AXIS] = Interval (-interline_f, interline_f);
596   m.dim_[X_AXIS] = Interval (0, w);
597
598   m.add_atom (&at);
599   return m;
600 }
601
602 Molecule
603 Lookup::accordion (SCM s, Real interline_f) const
604 {
605   Molecule m;
606   String sym = ly_scm2string(SCM_CAR(s));
607   String reg = ly_scm2string(SCM_CAR(SCM_CDR(s)));
608
609   if (sym == "Discant")
610     {
611       Molecule r = afm_find("scripts-accDiscant");
612       m.add_molecule(r);
613       if (reg.left_str(1) == "F")
614         {
615           Molecule d = afm_find("scripts-accDot");
616           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
617           m.add_molecule(d);
618           reg = reg.right_str(reg.length_i()-1);
619         }
620       int eflag = 0x00;
621       if (reg.left_str(3) == "EEE")
622         {
623           eflag = 0x07;
624           reg = reg.right_str(reg.length_i()-3);
625         }
626       else if (reg.left_str(2) == "EE")
627         {
628           eflag = 0x05;
629           reg = reg.right_str(reg.length_i()-2);
630         }
631       else if (reg.left_str(2) == "Eh")
632         {
633           eflag = 0x04;
634           reg = reg.right_str(reg.length_i()-2);
635         }
636       else if (reg.left_str(1) == "E")
637         {
638           eflag = 0x02;
639           reg = reg.right_str(reg.length_i()-1);
640         }
641       if (eflag & 0x02)
642         {
643           Molecule d = afm_find("scripts-accDot");
644           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
645           m.add_molecule(d);
646         }
647       if (eflag & 0x04)
648         {
649           Molecule d = afm_find("scripts-accDot");
650           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
651           d.translate_axis(0.8 * interline_f PT, X_AXIS);
652           m.add_molecule(d);
653         }
654       if (eflag & 0x01)
655         {
656           Molecule d = afm_find("scripts-accDot");
657           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
658           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
659           m.add_molecule(d);
660         }
661       if (reg.left_str(2) == "SS")
662         {
663           Molecule d = afm_find("scripts-accDot");
664           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
665           d.translate_axis(0.4 * interline_f PT, X_AXIS);
666           m.add_molecule(d);
667           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
668           m.add_molecule(d);
669           reg = reg.right_str(reg.length_i()-2);
670         }
671       if (reg.left_str(1) == "S")
672         {
673           Molecule d = afm_find("scripts-accDot");
674           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
675           m.add_molecule(d);
676           reg = reg.right_str(reg.length_i()-1);
677         }
678     }
679   else if (sym == "Freebase")
680     {
681       Molecule r = afm_find("scripts-accFreebase");
682       m.add_molecule(r);
683       if (reg.left_str(1) == "F")
684         {
685           Molecule d = afm_find("scripts-accDot");
686           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
687           m.add_molecule(d);
688           reg = reg.right_str(reg.length_i()-1);
689         }
690       if (reg == "E")
691         {
692           Molecule d = afm_find("scripts-accDot");
693           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
694           m.add_molecule(d);
695         }
696     }
697   else if (sym == "Bayanbase")
698     {
699       Molecule r = afm_find("scripts-accBayanbase");
700       m.add_molecule(r);
701       if (reg.left_str(1) == "T")
702         {
703           Molecule d = afm_find("scripts-accDot");
704           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
705           m.add_molecule(d);
706           reg = reg.right_str(reg.length_i()-1);
707         }
708       /* include 4' reed just for completeness. You don't want to use this. */
709       if (reg.left_str(1) == "F")
710         {
711           Molecule d = afm_find("scripts-accDot");
712           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
713           m.add_molecule(d);
714           reg = reg.right_str(reg.length_i()-1);
715         }
716       if (reg.left_str(2) == "EE")
717         {
718           Molecule d = afm_find("scripts-accDot");
719           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
720           d.translate_axis(0.4 * interline_f PT, X_AXIS);
721           m.add_molecule(d);
722           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
723           m.add_molecule(d);
724           reg = reg.right_str(reg.length_i()-2);
725         }
726       if (reg.left_str(1) == "E")
727         {
728           Molecule d = afm_find("scripts-accDot");
729           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
730           m.add_molecule(d);
731           reg = reg.right_str(reg.length_i()-1);
732         }
733     }
734   else if (sym == "Stdbase")
735     {
736       Molecule r = afm_find("scripts-accStdbase");
737       m.add_molecule(r);
738       if (reg.left_str(1) == "T")
739         {
740           Molecule d = afm_find("scripts-accDot");
741           d.translate_axis(interline_f * 3.5 PT, Y_AXIS);
742           m.add_molecule(d);
743           reg = reg.right_str(reg.length_i()-1);
744         }
745       if (reg.left_str(1) == "F")
746         {
747           Molecule d = afm_find("scripts-accDot");
748           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
749           m.add_molecule(d);
750           reg = reg.right_str(reg.length_i()-1);
751         }
752       if (reg.left_str(1) == "M")
753         {
754           Molecule d = afm_find("scripts-accDot");
755           d.translate_axis(interline_f * 2 PT, Y_AXIS);
756           d.translate_axis(interline_f PT, X_AXIS);
757           m.add_molecule(d);
758           reg = reg.right_str(reg.length_i()-1);
759         }
760       if (reg.left_str(1) == "E")
761         {
762           Molecule d = afm_find("scripts-accDot");
763           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
764           m.add_molecule(d);
765           reg = reg.right_str(reg.length_i()-1);
766         }
767       if (reg.left_str(1) == "S")
768         {
769           Molecule d = afm_find("scripts-accDot");
770           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
771           m.add_molecule(d);
772           reg = reg.right_str(reg.length_i()-1);
773         }
774     }
775   /* ugh maybe try to use regular font for S.B. and B.B and only use one font
776      for the rectangle */
777   else if (sym == "SB")
778     {
779       Molecule r = afm_find("scripts-accSB");
780       m.add_molecule(r);
781     }
782   else if (sym == "BB")
783     {
784       Molecule r = afm_find("scripts-accBB");
785       m.add_molecule(r);
786     }
787   else if (sym == "OldEE")
788     {
789       Molecule r = afm_find("scripts-accOldEE");
790       m.add_molecule(r);
791     }
792   else if (sym == "OldEES")
793     {
794       Molecule r = afm_find("scripts-accOldEES");
795       m.add_molecule(r);
796     }
797   return m;  
798 }