]> git.donarmstrong.com Git - lilypond.git/blob - lily/lookup.cc
release: 1.2.1
[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 #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   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);
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 (beam_scm_sym,
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 (ly_symbol ("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 (filledbox_scm_sym,
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 (SCM_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   DOUT << "\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->get_char ((unsigned char)text[i],false);
428
429           w += c->dimensions()[X_AXIS].length ();
430           ydims.unite (c->dimensions()[Y_AXIS]);
431         }
432     }
433
434   if(brace_count)
435     {
436       warning (_f ("Non-matching braces in text `%s', adding braces.", text.ch_C()));
437
438       if (brace_count < 0)
439         {
440           text = to_str ('{', -brace_count) + text;
441         }
442       else 
443         {
444           text = text + to_str ('}', brace_count);
445         }
446     }
447
448   ydims *= realmag;
449   m.dim_.x () = Interval (0, w*realmag);
450   m.dim_.y () = ydims;
451
452   
453   Atom at  (gh_list (text_scm_sym,
454                      ly_ch_C_to_scm (text.ch_C()),
455                      SCM_UNDEFINED));
456   at.font_ = ly_symbol (style);
457   at.magn_ = gh_int2scm (font_mag);
458   
459   m.add_atom (&at);
460   return m;
461 }
462   
463
464 Molecule
465 Lookup::time_signature (int num, int den, Paper_def *paper_l) const
466 {
467   String sty = "number";
468   Molecule n (text (sty, to_str (num), paper_l));
469   Molecule d (text (sty, to_str (den), paper_l));
470   n.align_to (X_AXIS, CENTER);
471   d.align_to (X_AXIS, CENTER);
472   Molecule m;
473   if (den)
474     {
475       m.add_at_edge (Y_AXIS, UP, n, 0.0);
476       m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
477     }
478   else
479     {
480       m = n;
481       m.align_to (Y_AXIS, CENTER);
482     }
483   return m;
484 }
485
486 Molecule
487 Lookup::staff_brace (Real y, int staff_size) const
488 {
489   Molecule m;
490   /*
491   (define (pianobrace y staffht)
492     (let* ((step 1.0)
493            (minht (* 2 staffht))
494            (maxht (* 7 minht))
495            )
496       (string-append
497        (select-font (string-append "feta-braces" (number->string (inexact->exact staffht))) 0)
498        (char (max 0 (/  (- (min y (- maxht step)) minht) step))))
499       )
500     )
501   */
502
503   Real step  = 1.0;
504   int minht  = 2 * staff_size;
505   int maxht = 7 *  minht;
506   int idx = int (((maxht - step) <? y - minht) / step);
507   idx = idx >? 0;
508   
509   SCM f =  ly_symbol (String ("feta-braces" + to_str (staff_size)));
510   SCM e =gh_list (char_scm_sym, gh_int2scm (idx), SCM_UNDEFINED);
511   Atom at  (e);
512   at.font_ = f;
513   
514   m.dim_[Y_AXIS] = Interval (-y/2,y/2);
515   m.dim_[X_AXIS] = Interval (0,0);
516   m.add_atom (&at);
517   return m;
518 }
519
520 Molecule
521 Lookup::hairpin (Real width, Real height, Real thick, bool decresc, bool continued) const
522 {
523   Molecule m;   
524
525   String hairpin = String (decresc ? "de" : "") + "crescendo";
526   Atom at  (gh_list (ly_symbol (hairpin),
527                      gh_double2scm (thick),
528                      gh_double2scm (width),
529                      gh_double2scm (height),
530                      gh_double2scm (continued ? height/2 : 0.0),
531                      SCM_UNDEFINED));
532   m.dim_.x () = Interval (0, width);
533   m.dim_.y () = Interval (-2*height, 2*height);
534
535   m.add_atom (&at);
536   return m;
537 }
538
539 Molecule
540 Lookup::tuplet_bracket (Real dy , Real dx, Real thick, Real gap, Real interline_f, Direction dir) const
541 {
542   Molecule m;
543
544   Atom at  (gh_list(tuplet_scm_sym,
545                     gh_double2scm (interline_f),
546                     gh_double2scm (gap),
547                     gh_double2scm (dx),
548                     gh_double2scm (dy),
549                     gh_double2scm (thick),
550                     gh_int2scm (dir),
551                     SCM_UNDEFINED));
552   m.add_atom (&at);
553
554   return m;
555 }
556
557 /*
558   Make a smooth curve along the points 
559  */
560 Molecule
561 Lookup::slur (Array<Offset> controls, Real linethick) const
562 {
563   Offset  delta_off = controls[3]- controls[0];
564   Molecule m; 
565
566   SCM scontrols [8];
567   int indices[] = {5,6,7,4,1,2,3,0};
568
569   for (int i= 0; i < 8; i++)
570     scontrols[i] = offset2scm (controls[indices[i]]);
571
572
573   Atom at  (gh_list (ly_symbol ("bezier-sandwich"),
574                      ly_quote_scm (array_to_list (scontrols, 8)),
575                      gh_double2scm (linethick),
576                      SCM_UNDEFINED));
577
578   m.dim_[X_AXIS] = Interval (0, delta_off[X_AXIS]);
579   m.dim_[Y_AXIS] = Interval (0 <? delta_off[Y_AXIS], 0 >? delta_off[Y_AXIS]);
580   m.add_atom (&at);
581   return m;
582 }
583
584 Molecule
585 Lookup::staff_bracket (Real y) const
586 {
587   Molecule m; 
588   Atom at  ( gh_list (bracket_scm_sym,
589                       gh_double2scm (y),
590                       SCM_UNDEFINED));
591   m.add_atom (&at);                              
592   m.dim_[Y_AXIS] = Interval (-y/2,y/2);
593   m.dim_[X_AXIS] = Interval (0,4 PT);
594
595   m.translate_axis (- 4. / 3. * m.dim_[X_AXIS].length (), X_AXIS);
596   return m;
597 }
598
599 Molecule
600 Lookup::volta (Real h, Real w, Real thick, bool vert_start, bool vert_end) const
601 {
602   Molecule m; 
603
604   Atom at  (gh_list (volta_scm_sym,
605                      gh_double2scm (h),
606                      gh_double2scm (w),
607                      gh_double2scm (thick),
608                      gh_int2scm (vert_start),
609                      gh_int2scm (vert_end),
610                      SCM_UNDEFINED));
611
612   m.dim_[Y_AXIS] = Interval (- h/2, h/2);
613   m.dim_[X_AXIS] = Interval (0, w);
614
615   m.add_atom (&at);
616   return m;
617 }
618
619 Molecule
620 Lookup::accordion (SCM s, Real interline_f) const
621 {
622   Molecule m;
623   String sym = ly_scm2string(SCM_CAR(s));
624   String reg = ly_scm2string(SCM_CAR(SCM_CDR(s)));
625
626   if (sym == "Discant")
627     {
628       Molecule r = afm_find("scripts-accDiscant");
629       m.add_molecule(r);
630       if (reg.left_str(1) == "F")
631         {
632           Molecule d = afm_find("scripts-accDot");
633           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
634           m.add_molecule(d);
635           reg = reg.right_str(reg.length_i()-1);
636         }
637       int eflag = 0x00;
638       if (reg.left_str(3) == "EEE")
639         {
640           eflag = 0x07;
641           reg = reg.right_str(reg.length_i()-3);
642         }
643       else if (reg.left_str(2) == "EE")
644         {
645           eflag = 0x05;
646           reg = reg.right_str(reg.length_i()-2);
647         }
648       else if (reg.left_str(2) == "Eh")
649         {
650           eflag = 0x04;
651           reg = reg.right_str(reg.length_i()-2);
652         }
653       else if (reg.left_str(1) == "E")
654         {
655           eflag = 0x02;
656           reg = reg.right_str(reg.length_i()-1);
657         }
658       if (eflag & 0x02)
659         {
660           Molecule d = afm_find("scripts-accDot");
661           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
662           m.add_molecule(d);
663         }
664       if (eflag & 0x04)
665         {
666           Molecule d = afm_find("scripts-accDot");
667           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
668           d.translate_axis(0.8 * interline_f PT, X_AXIS);
669           m.add_molecule(d);
670         }
671       if (eflag & 0x01)
672         {
673           Molecule d = afm_find("scripts-accDot");
674           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
675           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
676           m.add_molecule(d);
677         }
678       if (reg.left_str(2) == "SS")
679         {
680           Molecule d = afm_find("scripts-accDot");
681           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
682           d.translate_axis(0.4 * interline_f PT, X_AXIS);
683           m.add_molecule(d);
684           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
685           m.add_molecule(d);
686           reg = reg.right_str(reg.length_i()-2);
687         }
688       if (reg.left_str(1) == "S")
689         {
690           Molecule d = afm_find("scripts-accDot");
691           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
692           m.add_molecule(d);
693           reg = reg.right_str(reg.length_i()-1);
694         }
695     }
696   else if (sym == "Freebase")
697     {
698       Molecule r = afm_find("scripts-accFreebase");
699       m.add_molecule(r);
700       if (reg.left_str(1) == "F")
701         {
702           Molecule d = afm_find("scripts-accDot");
703           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
704           m.add_molecule(d);
705           reg = reg.right_str(reg.length_i()-1);
706         }
707       if (reg == "E")
708         {
709           Molecule d = afm_find("scripts-accDot");
710           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
711           m.add_molecule(d);
712         }
713     }
714   else if (sym == "Bayanbase")
715     {
716       Molecule r = afm_find("scripts-accBayanbase");
717       m.add_molecule(r);
718       if (reg.left_str(1) == "T")
719         {
720           Molecule d = afm_find("scripts-accDot");
721           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
722           m.add_molecule(d);
723           reg = reg.right_str(reg.length_i()-1);
724         }
725       /* include 4' reed just for completeness. You don't want to use this. */
726       if (reg.left_str(1) == "F")
727         {
728           Molecule d = afm_find("scripts-accDot");
729           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
730           m.add_molecule(d);
731           reg = reg.right_str(reg.length_i()-1);
732         }
733       if (reg.left_str(2) == "EE")
734         {
735           Molecule d = afm_find("scripts-accDot");
736           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
737           d.translate_axis(0.4 * interline_f PT, X_AXIS);
738           m.add_molecule(d);
739           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
740           m.add_molecule(d);
741           reg = reg.right_str(reg.length_i()-2);
742         }
743       if (reg.left_str(1) == "E")
744         {
745           Molecule d = afm_find("scripts-accDot");
746           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
747           m.add_molecule(d);
748           reg = reg.right_str(reg.length_i()-1);
749         }
750     }
751   else if (sym == "Stdbase")
752     {
753       Molecule r = afm_find("scripts-accStdbase");
754       m.add_molecule(r);
755       if (reg.left_str(1) == "T")
756         {
757           Molecule d = afm_find("scripts-accDot");
758           d.translate_axis(interline_f * 3.5 PT, Y_AXIS);
759           m.add_molecule(d);
760           reg = reg.right_str(reg.length_i()-1);
761         }
762       if (reg.left_str(1) == "F")
763         {
764           Molecule d = afm_find("scripts-accDot");
765           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
766           m.add_molecule(d);
767           reg = reg.right_str(reg.length_i()-1);
768         }
769       if (reg.left_str(1) == "M")
770         {
771           Molecule d = afm_find("scripts-accDot");
772           d.translate_axis(interline_f * 2 PT, Y_AXIS);
773           d.translate_axis(interline_f PT, X_AXIS);
774           m.add_molecule(d);
775           reg = reg.right_str(reg.length_i()-1);
776         }
777       if (reg.left_str(1) == "E")
778         {
779           Molecule d = afm_find("scripts-accDot");
780           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
781           m.add_molecule(d);
782           reg = reg.right_str(reg.length_i()-1);
783         }
784       if (reg.left_str(1) == "S")
785         {
786           Molecule d = afm_find("scripts-accDot");
787           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
788           m.add_molecule(d);
789           reg = reg.right_str(reg.length_i()-1);
790         }
791     }
792   /* ugh maybe try to use regular font for S.B. and B.B and only use one font
793      for the rectangle */
794   else if (sym == "SB")
795     {
796       Molecule r = afm_find("scripts-accSB");
797       m.add_molecule(r);
798     }
799   else if (sym == "BB")
800     {
801       Molecule r = afm_find("scripts-accBB");
802       m.add_molecule(r);
803     }
804   else if (sym == "OldEE")
805     {
806       Molecule r = afm_find("scripts-accOldEE");
807       m.add_molecule(r);
808     }
809   else if (sym == "OldEES")
810     {
811       Molecule r = afm_find("scripts-accOldEES");
812       m.add_molecule(r);
813     }
814   return m;  
815 }