]> git.donarmstrong.com Git - lilypond.git/blob - lily/lily-guile.cc
298b374203bdbb34cff32fc6dd66abf5c6a4d3c3
[lilypond.git] / lily / lily-guile.cc
1 /*
2   lily-guile.cc -- implement assorted guile functions
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7                  Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <libintl.h>            // gettext on macos x
14 #include <math.h>   /* isinf */
15 #include <string.h> /* strdup, strchr */
16 #include <ctype.h>
17
18 #include "lily-proto.hh"
19 #include "version.hh"
20
21 /* MacOS S fix:
22    source-file.hh includes cmath which undefines isinf and isnan
23
24    FIXME: #ifdef MACOS_X?
25 */
26 inline int my_isinf (Real r) { return isinf (r); }
27 inline int my_isnan (Real r) { return isnan (r); }
28
29
30 #include "libc-extension.hh"
31 #include "lily-guile.hh"
32 #include "main.hh"
33 #include "file-path.hh"
34 #include "warn.hh"
35 #include "direction.hh"
36 #include "offset.hh"
37 #include "interval.hh"
38 #include "pitch.hh"
39 #include "dimensions.hh"
40 #include "source-file.hh"
41
42 // #define TEST_GC
43
44 SCM
45 ly_to_symbol (SCM scm)
46 {
47   return scm_string_to_symbol (ly_to_string (scm));
48 }
49
50 SCM
51 ly_to_string (SCM scm)
52 {
53   return scm_call_3 (ly_scheme_function ("format"), SCM_BOOL_F,
54                      scm_makfrom0str ("~S"), scm);
55 }
56
57 SCM
58 ly_last (SCM list)
59 {
60   return scm_car (scm_last_pair (list));
61 }
62
63 SCM
64 ly_write2scm (SCM s)
65 {
66   SCM port = scm_mkstrport (SCM_INUM0, 
67                             scm_make_string (SCM_INUM0, SCM_UNDEFINED),
68                             SCM_OPN | SCM_WRTNG,
69                             "ly_write2string");
70   //  SCM write = scm_eval_3 (ly_symbol2scm ("write"), s, SCM_EOL);
71   SCM write = scm_primitive_eval (ly_symbol2scm ("write"));
72   
73   // scm_apply (write, port, SCM_EOL);
74   scm_call_2 (write, s, port);
75   return scm_strport_to_string (port);
76 }
77
78 SCM
79 ly_quote_scm (SCM s)
80 {
81   return scm_list_n (ly_symbol2scm ("quote"), s, SCM_UNDEFINED);
82 }
83
84 String
85 ly_symbol2string (SCM s)
86 {
87   /*
88     Ugh. this is not very efficient.
89    */
90   SCM str = scm_symbol_to_string (s);
91   return ly_scm2string (str);
92 }
93
94 String
95 gulp_file_to_string (String fn, bool must_exist)
96 {
97   String s = global_path.find (fn);
98   if (s == "")
99     {
100       if (must_exist)
101         {
102           String e = _f ("can't find file: `%s'", fn);
103           e += " ";
104           e += _f ("(load path: `%s')", global_path.to_string ());
105           error (e);
106           /* unreachable */
107         }
108       return s;
109     }
110
111   if (verbose_global_b)
112     progress_indication ("[" + s);
113
114   int n;
115   char *str = gulp_file (s, &n);
116   String result (str);
117   delete[] str;
118   
119   if (verbose_global_b)
120     progress_indication ("]");
121
122   return result;
123 }
124
125 LY_DEFINE (ly_gulp_file, "ly:gulp-file",
126            1, 0, 0, (SCM name),
127            "Read the file @var{name}, and return its contents in a string.  "
128            "The file is looked up using the search path.")
129 {
130   SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
131   return scm_makfrom0str (gulp_file_to_string (ly_scm2string (name),
132                                                true).to_str0 ());
133                                                
134 }
135
136
137 extern "C" {
138   // maybe gdb 5.0 becomes quicker if it doesn't do fancy C++ typing?
139 void
140 ly_display_scm (SCM s)
141 {
142   scm_display (s, scm_current_output_port ());
143   scm_newline (scm_current_output_port ());
144 }
145 };
146
147 String
148 ly_scm2string (SCM str)
149 {
150   return String ((Byte*)scm_i_string_chars (str),
151                  (int) scm_i_string_length (str));
152 }
153
154 char *
155 ly_scm2newstr (SCM str, size_t *lenp)
156 {
157   SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
158
159   size_t len = SCM_STRING_LENGTH (str);
160   if (char *new_str = (char *) malloc ((len + 1) * sizeof (char)))
161     {
162       memcpy (new_str, scm_i_string_chars (str), len);
163       new_str[len] = '\0';
164
165       if (lenp)
166         *lenp = len;
167       
168       return new_str;
169     }
170   return 0;
171 }
172
173 SCM
174 index_get_cell (SCM s, Direction d)
175 {
176   
177   assert (d);
178   return (d == LEFT) ? scm_car (s) : scm_cdr (s);
179 }
180
181 SCM
182 index_set_cell (SCM s, Direction d, SCM v)
183 {
184   if (d == LEFT)
185     scm_set_car_x (s, v);
186   else if (d == RIGHT)
187     scm_set_cdr_x (s, v);
188   return s;
189 }
190   
191 LY_DEFINE (ly_warn, "ly:warn",
192            1, 0, 1, (SCM str, SCM rest),
193            "Scheme callable function to issue the warning @code{msg}. "
194            "The message is formatted with @code{format} and @code{rest}.")
195 {
196   SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
197   progress_indication ("\n");
198
199   str = scm_simple_format (SCM_BOOL_F, str, rest);
200   warning ("lily-guile: " + ly_scm2string (str));
201   return SCM_UNSPECIFIED;
202 }
203
204 LY_DEFINE (ly_programming_error, "ly:programming-error",
205            1, 0, 1, (SCM str, SCM rest),
206            "Scheme callable function to issue the warning @code{msg}. "
207            "The message is formatted with @code{format} and @code{rest}.")
208 {
209   SCM_ASSERT_TYPE (scm_is_string (str), str, SCM_ARG1, __FUNCTION__, "string");
210   progress_indication ("\n");
211
212   str = scm_simple_format (SCM_BOOL_F, str, rest);
213   programming_error (ly_scm2string (str));
214   return SCM_UNSPECIFIED;
215 }
216
217 LY_DEFINE (ly_dir_p, "ly:dir?",
218            1, 0, 0, (SCM s),
219           "type predicate. A direction is @code{-1}, @code{0} or "
220            "@code{1}, where @code{-1} represents "
221           "left or down and @code{1} represents right or up.")
222 {
223   if (scm_is_number (s))
224     {
225       int i = scm_to_int (s);
226       return (i>= -1 && i <= 1)  ? SCM_BOOL_T : SCM_BOOL_F; 
227     }
228   return SCM_BOOL_F;
229 }
230
231 bool
232 is_number_pair (SCM p)
233 {
234   return scm_is_pair (p)
235     && scm_is_number (scm_car (p)) && scm_is_number (scm_cdr (p));
236 }
237
238 typedef void (*Void_fptr) ();
239 Array<Void_fptr> *scm_init_funcs_;
240
241 void add_scm_init_func (void (*f) ())
242 {
243   if (!scm_init_funcs_)
244     scm_init_funcs_ = new Array<Void_fptr>;
245
246   scm_init_funcs_->push (f);
247 }
248
249 void
250 ly_init_ly_module (void *)
251 {
252   for (int i = scm_init_funcs_->size () ; i--;)
253     (scm_init_funcs_->elem (i)) ();
254
255   if (verbose_global_b)
256     progress_indication ("\n");
257   
258   scm_primitive_load_path (scm_makfrom0str ("lily.scm"));
259 }
260
261 SCM global_lily_module;
262
263 void
264 ly_c_init_guile ()
265 {
266   global_lily_module = scm_c_define_module ("lily", ly_init_ly_module, 0);
267   scm_c_use_module ("lily");
268 }
269
270 unsigned int
271 ly_scm_hash (SCM s)
272 {
273   return scm_ihashv (s, ~1u);
274 }
275
276 bool
277 is_direction (SCM s)
278 {
279   if (scm_is_number (s))
280     {
281       int i = scm_to_int (s);
282       return i>= -1 && i <= 1; 
283     }
284   return false;
285 }
286
287 LY_DEFINE (ly_assoc_get, "ly:assoc-get",
288            2, 1, 0,
289            (SCM key, SCM alist, SCM default_value),
290            "Return value if KEY in ALIST, else DEFAULT-VALUE "
291            "(or #f if not specified).")
292 {
293   SCM handle = scm_assoc (key, alist);
294
295   if (default_value == SCM_UNDEFINED)
296     default_value = SCM_BOOL_F;
297   
298   if (scm_is_pair (handle))
299     return scm_cdr (handle);
300   else
301     return default_value;
302 }
303
304 bool
305 is_axis (SCM s)
306 {
307   if (scm_is_number (s))
308     {
309       int i = scm_to_int (s);
310       return i== 0 || i == 1;
311     }
312   return false;
313 }
314
315 Direction
316 to_dir (SCM s)
317 {
318   return scm_is_integer (s) ? (Direction) scm_to_int (s) : CENTER;
319 }
320
321 Interval
322 ly_scm2interval (SCM p)
323 {
324   return Interval (scm_to_double (scm_car (p)), scm_to_double (scm_cdr (p)));
325 }
326
327 Drul_array<Real>
328 ly_scm2realdrul (SCM p)
329 {
330   return Drul_array<Real> (scm_to_double (scm_car (p)),
331                            scm_to_double (scm_cdr (p)));
332 }
333
334 SCM
335 ly_interval2scm (Drul_array<Real> i)
336 {
337   return scm_cons (scm_make_real (i[LEFT]), scm_make_real (i[RIGHT]));
338 }
339
340 bool
341 to_boolean (SCM s)
342 {
343   return scm_is_bool (s) && ly_scm2bool (s);
344 }
345
346 /* Appendable list L: the cdr contains the list, the car the last cons
347    in the list.  */
348 SCM
349 appendable_list ()
350 {
351   SCM s = scm_cons (SCM_EOL, SCM_EOL);
352   scm_set_car_x (s, s);
353   
354   return s;
355 }
356
357 void
358 appendable_list_append (SCM l, SCM elt)
359 {
360   SCM newcons = scm_cons (elt, SCM_EOL);
361   
362   scm_set_cdr_x (scm_car (l), newcons);      
363   scm_set_car_x (l, newcons);
364 }
365
366 SCM
367 ly_offset2scm (Offset o)
368 {
369   return scm_cons (scm_make_real (o[X_AXIS]), scm_make_real (o[Y_AXIS]));
370 }
371
372 Offset
373 ly_scm2offset (SCM s)
374 {
375   return Offset (scm_to_double (scm_car (s)),
376                  scm_to_double (scm_cdr (s)));
377 }
378
379 LY_DEFINE (ly_number2string, "ly:number->string",
380            1, 0, 0, (SCM s),
381            "Convert @var{num} to a string without generating many decimals.")
382 {
383   SCM_ASSERT_TYPE (scm_is_number (s), s, SCM_ARG1, __FUNCTION__, "number");
384
385   char str[400];                        // ugh.
386
387   if (scm_exact_p (s) == SCM_BOOL_F)
388     {
389       Real r (scm_to_double (s));
390
391       if (my_isinf (r) || my_isnan (r))
392         {
393           programming_error ("Infinity or NaN encountered while converting Real number; setting to zero.");
394           r = 0.0;
395         }
396
397       sprintf (str, "%08.4f", r);
398     }
399   else
400     sprintf (str, "%d", scm_to_int (s));
401
402   return scm_makfrom0str (str);
403 }
404
405
406
407 LY_DEFINE (ly_version,  "ly:version", 0, 0, 0, (),
408           "Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
409 {
410   char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " "  PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
411   
412   return scm_c_eval_string ((char*)vs);
413 }
414
415 LY_DEFINE (ly_unit,  "ly:unit", 0, 0, 0, (),
416           "Return the unit used for lengths as a string.")
417 {
418   return scm_makfrom0str (INTERNAL_UNIT);
419 }
420
421
422
423 LY_DEFINE (ly_dimension_p,  "ly:dimension?", 1, 0, 0, (SCM d),
424           "Return @var{d} is a number. Used to distinguish length "
425           "variables from normal numbers.")
426 {
427   return scm_number_p (d);
428 }
429
430 SCM
431 ly_deep_copy (SCM src)
432 {
433   if (scm_is_pair (src))
434     return scm_cons (ly_deep_copy (scm_car (src)), ly_deep_copy (scm_cdr (src)));
435   else if (ly_c_vector_p (src))
436     {
437       int len = SCM_VECTOR_LENGTH (src);
438       SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
439       for (int i = 0 ;i < len ; i++)
440         {
441           SCM si = scm_int2num (i);
442           scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si))); 
443         }
444     }
445   return src;
446 }
447
448
449
450
451 SCM
452 ly_assoc_chain (SCM key, SCM achain)
453 {
454   if (scm_is_pair (achain))
455     {
456       SCM handle = scm_assoc (key, scm_car (achain));
457       if (scm_is_pair (handle))
458         return handle;
459       else
460         return ly_assoc_chain (key, scm_cdr (achain));
461     }
462   else
463     return SCM_BOOL_F;
464 }
465
466 /* looks the key up in the cdrs of the alist-keys
467    - ignoring the car and ignoring non-pair keys.
468    Returns first match found, i.e.
469
470    alist = ((1 . 10)
471                    ((1 . 2) . 11)
472                    ((2 . 1) . 12)
473                    ((3 . 0) . 13)
474                    ((4 . 1) . 14) )
475
476 I would like (ly_assoc_cdr 1) to return 12 - because it's the first
477 element with the cdr of the key = 1.  In other words (alloc_cdr key)
478 corresponds to call
479
480 (alloc (anything . key))
481
482
483
484 */
485 SCM
486 ly_assoc_cdr (SCM key, SCM alist)
487 {
488   if (scm_is_pair (alist))
489     {
490       SCM trykey = scm_caar (alist);
491       if (scm_is_pair (trykey) && to_boolean (scm_equal_p (key, scm_cdr (trykey))))
492         return scm_car (alist);
493       else
494         return ly_assoc_cdr (key, scm_cdr (alist));
495     }
496   return SCM_BOOL_F;
497 }
498
499 /* LST has the form "sym1 sym2 sym3\nsym4\nsym5"
500    i.e. \n and ' ' can be used interchangeably as separators.  */
501 SCM
502 parse_symbol_list (char const *lst)
503 {
504   char *s = strdup (lst);
505   char *orig = s;
506   SCM create_list = SCM_EOL;
507
508   char * e = s + strlen (s) - 1;
509   while (e >= s && isspace (*e))
510     *e-- = 0;
511
512   for (char * p = s; *p; p++)
513     if (*p == '\n')
514       *p = ' ';
515   
516   if (!s[0])
517     s = 0;
518   
519   while (s)
520     {
521       char *next = strchr (s, ' ');
522       if (next)
523         *next++ = 0;
524
525       create_list = scm_cons (ly_symbol2scm (s), create_list);
526       s = next;
527     }
528
529   free (orig);
530   return create_list;
531 }
532
533 SCM
534 ly_truncate_list (int k, SCM lst)
535 {
536   if (k == 0)
537     lst = SCM_EOL;
538   else
539     {
540       SCM s = lst;
541       k--;
542       for (; scm_is_pair (s) && k--; s = scm_cdr (s))
543         ;
544
545       if (scm_is_pair (s))
546         scm_set_cdr_x (s, SCM_EOL);
547     }
548   return lst;
549 }
550
551 String
552 print_scm_val (SCM val)
553 {
554   String realval = ly_scm2string (ly_write2scm (val));
555   if (realval.length () > 200)
556     realval = realval.left_string (100)
557       + "\n :\n :\n"
558       + realval.right_string (100);
559   return realval;        
560 }
561
562 bool
563 type_check_assignment (SCM sym, SCM val,  SCM type_symbol) 
564 {
565   bool ok = true;
566
567   /*
568     Always succeeds.
569
570
571     TODO: should remove #f from allowed vals?
572    */
573   if (val == SCM_EOL || val == SCM_BOOL_F)
574     return ok;
575
576   if (!scm_is_symbol (sym))
577 #if 0
578     return false;
579 #else
580   /*
581     This is used for autoBeamSettings.
582
583     TODO: deprecate the use of \override and \revert for
584     autoBeamSettings?
585
586     or use a symbol autoBeamSettingS?  
587    */
588   return true; 
589 #endif
590   
591   SCM type = scm_object_property (sym, type_symbol);
592
593   if (type != SCM_EOL && !ly_c_procedure_p (type))
594       {
595         warning (_f ("Can't find property type-check for `%s' (%s).",
596                      ly_symbol2string (sym).to_str0 (),
597                      ly_symbol2string (type_symbol).to_str0 ())
598                  + "  " + _ ("Perhaps you made a typing error?"));
599
600         /* Be strict when being anal :) */
601         if (internal_type_checking_global_b)
602           abort ();
603         
604         warning (_ ("Doing assignment anyway."));
605       }
606   else
607     {
608       if (val != SCM_EOL
609           && ly_c_procedure_p (type)
610           && scm_call_1 (type, val) == SCM_BOOL_F)
611         {
612           SCM errport = scm_current_error_port ();
613           ok = false;
614           SCM typefunc = ly_scheme_function ("type-name");
615           SCM type_name = scm_call_1 (typefunc, type);
616
617          
618           scm_puts (_f ("Type check for `%s' failed; value `%s' must be of type `%s'",
619                         ly_symbol2string (sym).to_str0 (),
620                         print_scm_val (val),
621                         ly_scm2string (type_name).to_str0 ()).to_str0 (),
622                     errport);
623           scm_puts ("\n", errport);                   
624         }
625     }
626   return ok;
627 }
628
629
630 /* some SCM abbrevs
631
632    zijn deze nou handig?
633    zijn ze er al in scheme, maar heten ze anders? */
634
635
636 /* Remove doubles from (sorted) list */
637 SCM
638 ly_unique (SCM list)
639 {
640   SCM unique = SCM_EOL;
641   for (SCM i = list; scm_is_pair (i); i = scm_cdr (i))
642     {
643       if (!scm_is_pair (scm_cdr (i))
644           || !ly_c_equal_p (scm_car (i), scm_cadr (i)))
645         unique = scm_cons (scm_car (i), unique);
646     }
647   return scm_reverse_x (unique, SCM_EOL);
648 }
649
650
651 static int
652 scm_default_compare (void const *a, void const *b)
653 {
654   SCM pa = *(SCM*) a;
655   SCM pb = *(SCM*) b;
656   if (pa == pb)
657     return 0;
658   return pa < pb ? -1 : 1;
659 }
660
661 /*  Modify LST in place: qsort it.  */
662 SCM
663 ly_list_qsort_uniq_x (SCM lst)
664 {
665   int len = scm_ilength (lst);
666   SCM *arr = new SCM[len];
667   int k = 0;
668   for (SCM s = lst; SCM_NNULLP (s); s = scm_cdr (s))
669     arr[k++] = scm_car (s);
670
671   assert (k == len);
672   qsort (arr, len, sizeof (SCM), &scm_default_compare);
673
674   SCM *tail = &lst;
675   for (int i = 0; i < len; i++)
676     if (!i || arr[i] != arr[i - 1])
677       {
678         SCM_SETCAR (*tail, arr[i]);
679         tail = SCM_CDRLOC (*tail);
680       }
681
682   *tail = SCM_EOL;
683   delete[] arr;
684
685   return lst; 
686 }
687
688
689 /* tail add */
690 SCM
691 ly_snoc (SCM s, SCM list)
692 {
693   return ly_append2 (list, scm_list_n (s, SCM_UNDEFINED));
694 }
695
696 /* Split list at member s, removing s.
697    Return (BEFORE . AFTER)  */
698 SCM
699 ly_split_list (SCM s, SCM list)
700 {
701   SCM before = SCM_EOL;
702   SCM after = list;
703   for (; scm_is_pair (after);)
704     {
705       SCM i = scm_car (after);
706       after = scm_cdr (after);
707       if (ly_c_equal_p (i, s))
708         break;
709       before = scm_cons (i, before);
710     }
711   return scm_cons ( scm_reverse_x (before, SCM_EOL),  after);
712   
713 }
714
715
716 void
717 taint (SCM *)
718 {
719   /*
720     nop.
721    */
722 }
723
724 /*
725   display stuff without using stack
726  */
727 SCM
728 display_list (SCM s)
729 {
730   SCM p = scm_current_output_port ();
731
732   scm_puts ("(", p);
733   for (; scm_is_pair (s); s =scm_cdr (s))
734     {
735       scm_display (scm_car (s), p);
736       scm_puts (" ", p);      
737     }
738   scm_puts (")", p);
739   return SCM_UNSPECIFIED;
740 }
741
742 Slice
743 int_list_to_slice (SCM l)
744 {
745   Slice s;
746   s.set_empty ();
747   for (; scm_is_pair (l); l = scm_cdr (l))
748     if (scm_is_number (scm_car (l)))
749       s.add_point (scm_to_int (scm_car (l))); 
750   return s;
751 }
752
753 /* Return I-th element, or last elt L. If I < 0, then we take the first
754    element.
755    
756    PRE: length (L) > 0  */
757 SCM
758 robust_list_ref (int i, SCM l)
759 {
760   while (i-- > 0 && scm_is_pair (scm_cdr (l)))
761     l = scm_cdr (l);
762   return scm_car (l);
763 }
764
765 Real
766 robust_scm2double (SCM k, double x)
767 {
768   if (scm_is_number (k))
769     x = scm_to_double (k);
770   return x;
771 }
772
773 Interval
774 robust_scm2interval (SCM k, Drul_array<Real> v)
775 {
776   Interval i;
777   i[LEFT]= v[LEFT];
778   i[RIGHT]= v[RIGHT];
779   if (is_number_pair (k))
780     i = ly_scm2interval (k);
781   return i;
782 }
783
784 Drul_array<Real>
785 robust_scm2drul (SCM k, Drul_array<Real> v)
786 {
787   if (is_number_pair (k))
788     v = ly_scm2interval (k);
789   return v;
790 }
791
792 Offset
793 robust_scm2offset (SCM k, Offset o)
794 {
795   if (is_number_pair (k))
796     o = ly_scm2offset (k);
797   return o;
798 }
799
800 int
801 robust_scm2int (SCM k, int o)
802 {
803   if (scm_integer_p (k) == SCM_BOOL_T)
804     o = scm_to_int (k);
805   return o;
806 }
807
808 SCM
809 alist_to_hashq (SCM alist)
810 {
811   int i = scm_ilength (alist);
812   if (i < 0)
813     return scm_c_make_hash_table (0);
814           
815   SCM tab = scm_c_make_hash_table (i);
816   for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
817     {
818       SCM pt = scm_cdar (s);
819       scm_hashq_set_x (tab, scm_caar (s), pt);
820     }
821   return tab; 
822 }
823
824 #if 1
825 /*
826   Debugging mem leaks:
827  */
828 LY_DEFINE (ly_protects, "ly:protects",
829            0, 0, 0, (),
830           "Return hash of protected objects.")
831 {
832   return scm_protects;
833 }
834 #endif
835
836
837 #if HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC
838
839 #include "pangofc-afm-decoder.hh"
840
841 LY_DEFINE (ly_pango_add_afm_decoder, "ly:pango-add-afm-decoder",
842            1, 0, 0, (SCM font_family),
843            "Add pango afm decoder for FONT-FAMILY.")
844 {
845   SCM_ASSERT_TYPE (scm_is_string (font_family), font_family, SCM_ARG1,
846                    __FUNCTION__, "font_family");
847   pango_fc_afm_add_decoder (ly_scm2newstr (font_family, 0));
848   return SCM_UNSPECIFIED;
849 }
850
851 #endif
852
853 LY_DEFINE (ly_gettext, "ly:gettext",
854            1, 0, 0, (SCM string),
855            "Gettext wrapper.")
856 {
857   SCM_ASSERT_TYPE (scm_is_string (string), string, SCM_ARG1,
858                    __FUNCTION__, "string");
859   return scm_makfrom0str (gettext (scm_i_string_chars (string)));
860 }
861