]> git.donarmstrong.com Git - lilypond.git/blob - lily/lookup.cc
1000f37ab64312106fac2f49d46e7e96204cfb34
[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 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 (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   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 (text_scm_sym,
458                      ly_ch_C_to_scm (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 (char_scm_sym, 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, Real interline_f, Direction dir) const
545 {
546   Molecule m;
547
548   Atom at  (gh_list(tuplet_scm_sym,
549                     gh_double2scm (interline_f),
550                     gh_double2scm (gap),
551                     gh_double2scm (dx),
552                     gh_double2scm (dy),
553                     gh_double2scm (thick),
554                     gh_int2scm (dir),
555                     SCM_UNDEFINED));
556   m.add_atom (&at);
557
558   return m;
559 }
560
561 /*
562   Make a smooth curve along the points 
563  */
564 Molecule
565 Lookup::slur (Array<Offset> controls, Real linethick) const
566 {
567   Offset  delta_off = controls[3]- controls[0];
568   Molecule m; 
569
570   SCM scontrols [8];
571   int indices[] = {5,6,7,4,1,2,3,0};
572
573   for (int i= 0; i < 8; i++)
574     scontrols[i] = offset2scm (controls[indices[i]]);
575
576
577   Atom at  (gh_list (ly_symbol ("bezier-sandwich"),
578                      ly_quote_scm (array_to_list (scontrols, 8)),
579                      gh_double2scm (linethick),
580                      SCM_UNDEFINED));
581
582   m.dim_[X_AXIS] = Interval (0, delta_off[X_AXIS]);
583   m.dim_[Y_AXIS] = Interval (0 <? delta_off[Y_AXIS], 0 >? delta_off[Y_AXIS]);
584   m.add_atom (&at);
585   return m;
586 }
587
588 Molecule
589 Lookup::staff_bracket (Real y) const
590 {
591   Molecule m; 
592   Atom at  ( gh_list (bracket_scm_sym,
593                       gh_double2scm (y),
594                       SCM_UNDEFINED));
595   m.add_atom (&at);                              
596   m.dim_[Y_AXIS] = Interval (-y/2,y/2);
597   m.dim_[X_AXIS] = Interval (0,4 PT);
598
599   m.translate_axis (- 4. / 3. * m.dim_[X_AXIS].length (), X_AXIS);
600   return m;
601 }
602
603 Molecule
604 Lookup::volta (Real h, Real w, Real thick, bool vert_start, bool vert_end) const
605 {
606   Molecule m; 
607
608   Atom at  (gh_list (volta_scm_sym,
609                      gh_double2scm (h),
610                      gh_double2scm (w),
611                      gh_double2scm (thick),
612                      gh_int2scm (vert_start),
613                      gh_int2scm (vert_end),
614                      SCM_UNDEFINED));
615
616   m.dim_[Y_AXIS] = Interval (- h/2, h/2);
617   m.dim_[X_AXIS] = Interval (0, w);
618
619   m.add_atom (&at);
620   return m;
621 }
622
623 Molecule
624 Lookup::accordion (SCM s, Real interline_f) const
625 {
626   Molecule m;
627   String sym = ly_scm2string(SCM_CAR(s));
628   String reg = ly_scm2string(SCM_CAR(SCM_CDR(s)));
629
630   if (sym == "Discant")
631     {
632       Molecule r = afm_find("scripts-accDiscant");
633       m.add_molecule(r);
634       if (reg.left_str(1) == "F")
635         {
636           Molecule d = afm_find("scripts-accDot");
637           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
638           m.add_molecule(d);
639           reg = reg.right_str(reg.length_i()-1);
640         }
641       int eflag = 0x00;
642       if (reg.left_str(3) == "EEE")
643         {
644           eflag = 0x07;
645           reg = reg.right_str(reg.length_i()-3);
646         }
647       else if (reg.left_str(2) == "EE")
648         {
649           eflag = 0x05;
650           reg = reg.right_str(reg.length_i()-2);
651         }
652       else if (reg.left_str(2) == "Eh")
653         {
654           eflag = 0x04;
655           reg = reg.right_str(reg.length_i()-2);
656         }
657       else if (reg.left_str(1) == "E")
658         {
659           eflag = 0x02;
660           reg = reg.right_str(reg.length_i()-1);
661         }
662       if (eflag & 0x02)
663         {
664           Molecule d = afm_find("scripts-accDot");
665           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
666           m.add_molecule(d);
667         }
668       if (eflag & 0x04)
669         {
670           Molecule d = afm_find("scripts-accDot");
671           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
672           d.translate_axis(0.8 * interline_f PT, X_AXIS);
673           m.add_molecule(d);
674         }
675       if (eflag & 0x01)
676         {
677           Molecule d = afm_find("scripts-accDot");
678           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
679           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
680           m.add_molecule(d);
681         }
682       if (reg.left_str(2) == "SS")
683         {
684           Molecule d = afm_find("scripts-accDot");
685           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
686           d.translate_axis(0.4 * interline_f PT, X_AXIS);
687           m.add_molecule(d);
688           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
689           m.add_molecule(d);
690           reg = reg.right_str(reg.length_i()-2);
691         }
692       if (reg.left_str(1) == "S")
693         {
694           Molecule d = afm_find("scripts-accDot");
695           d.translate_axis(0.5 * interline_f PT, Y_AXIS);
696           m.add_molecule(d);
697           reg = reg.right_str(reg.length_i()-1);
698         }
699     }
700   else if (sym == "Freebase")
701     {
702       Molecule r = afm_find("scripts-accFreebase");
703       m.add_molecule(r);
704       if (reg.left_str(1) == "F")
705         {
706           Molecule d = afm_find("scripts-accDot");
707           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
708           m.add_molecule(d);
709           reg = reg.right_str(reg.length_i()-1);
710         }
711       if (reg == "E")
712         {
713           Molecule d = afm_find("scripts-accDot");
714           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
715           m.add_molecule(d);
716         }
717     }
718   else if (sym == "Bayanbase")
719     {
720       Molecule r = afm_find("scripts-accBayanbase");
721       m.add_molecule(r);
722       if (reg.left_str(1) == "T")
723         {
724           Molecule d = afm_find("scripts-accDot");
725           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
726           m.add_molecule(d);
727           reg = reg.right_str(reg.length_i()-1);
728         }
729       /* include 4' reed just for completeness. You don't want to use this. */
730       if (reg.left_str(1) == "F")
731         {
732           Molecule d = afm_find("scripts-accDot");
733           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
734           m.add_molecule(d);
735           reg = reg.right_str(reg.length_i()-1);
736         }
737       if (reg.left_str(2) == "EE")
738         {
739           Molecule d = afm_find("scripts-accDot");
740           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
741           d.translate_axis(0.4 * interline_f PT, X_AXIS);
742           m.add_molecule(d);
743           d.translate_axis(-0.8 * interline_f PT, X_AXIS);
744           m.add_molecule(d);
745           reg = reg.right_str(reg.length_i()-2);
746         }
747       if (reg.left_str(1) == "E")
748         {
749           Molecule d = afm_find("scripts-accDot");
750           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
751           m.add_molecule(d);
752           reg = reg.right_str(reg.length_i()-1);
753         }
754     }
755   else if (sym == "Stdbase")
756     {
757       Molecule r = afm_find("scripts-accStdbase");
758       m.add_molecule(r);
759       if (reg.left_str(1) == "T")
760         {
761           Molecule d = afm_find("scripts-accDot");
762           d.translate_axis(interline_f * 3.5 PT, Y_AXIS);
763           m.add_molecule(d);
764           reg = reg.right_str(reg.length_i()-1);
765         }
766       if (reg.left_str(1) == "F")
767         {
768           Molecule d = afm_find("scripts-accDot");
769           d.translate_axis(interline_f * 2.5 PT, Y_AXIS);
770           m.add_molecule(d);
771           reg = reg.right_str(reg.length_i()-1);
772         }
773       if (reg.left_str(1) == "M")
774         {
775           Molecule d = afm_find("scripts-accDot");
776           d.translate_axis(interline_f * 2 PT, Y_AXIS);
777           d.translate_axis(interline_f PT, X_AXIS);
778           m.add_molecule(d);
779           reg = reg.right_str(reg.length_i()-1);
780         }
781       if (reg.left_str(1) == "E")
782         {
783           Molecule d = afm_find("scripts-accDot");
784           d.translate_axis(interline_f * 1.5 PT, Y_AXIS);
785           m.add_molecule(d);
786           reg = reg.right_str(reg.length_i()-1);
787         }
788       if (reg.left_str(1) == "S")
789         {
790           Molecule d = afm_find("scripts-accDot");
791           d.translate_axis(interline_f * 0.5 PT, Y_AXIS);
792           m.add_molecule(d);
793           reg = reg.right_str(reg.length_i()-1);
794         }
795     }
796   /* ugh maybe try to use regular font for S.B. and B.B and only use one font
797      for the rectangle */
798   else if (sym == "SB")
799     {
800       Molecule r = afm_find("scripts-accSB");
801       m.add_molecule(r);
802     }
803   else if (sym == "BB")
804     {
805       Molecule r = afm_find("scripts-accBB");
806       m.add_molecule(r);
807     }
808   else if (sym == "OldEE")
809     {
810       Molecule r = afm_find("scripts-accOldEE");
811       m.add_molecule(r);
812     }
813   else if (sym == "OldEES")
814     {
815       Molecule r = afm_find("scripts-accOldEES");
816       m.add_molecule(r);
817     }
818   return m;  
819 }