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