]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/font-select.cc
* lily/lily-guile.cc (ly_chain_assoc): remove.
[lilypond.git] / lily / font-select.cc
index 262930983e3ff82919c39cbdae9f96c3fd99e9c1..144c0dd0104f49e973b7fe4281af5c1c7a12fa7a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  font-select.cc -- implement property -> font_metric routines. 
+  font-select.cc -- implement property -> font_metric routines.
 
   source file of the GNU LilyPond music typesetter
 
@@ -16,7 +16,6 @@
 #include "pango-font.hh"
 #include "main.hh"
 
-
 Font_metric *
 get_font_by_design_size (Output_def *layout, Real requested,
                         SCM font_vector)
@@ -31,7 +30,7 @@ get_font_by_design_size (Output_def *layout, Real requested,
   for (; i < n; i++)
     {
       SCM entry = scm_c_vector_ref (font_vector, i);
-      
+
       if (scm_promise_p (entry) == SCM_BOOL_T)
        {
          Font_metric *fm = unsmob_metrics (scm_force (entry));
@@ -47,7 +46,7 @@ get_font_by_design_size (Output_def *layout, Real requested,
            = scm_cdr (entry);
        }
 #endif
-      
+
       if (size > requested)
        break;
       last_size = size;
@@ -65,7 +64,7 @@ get_font_by_design_size (Output_def *layout, Real requested,
          pango_description_string = last_pango_description_string;
        }
     }
-  
+
   Font_metric *fm = 0;
   if (scm_is_string (pango_description_string))
     {
@@ -74,7 +73,7 @@ get_font_by_design_size (Output_def *layout, Real requested,
                              pango_description_string,
                              requested / size);
 #else
-      error ("Trying to retrieve pango font without HAVE_PANGO_FT2."); 
+      error ("Trying to retrieve pango font without HAVE_PANGO_FT2.");
 #endif
     }
   else
@@ -103,15 +102,13 @@ properties_to_font_size_family (SCM fonts, SCM alist_chain)
 Font_metric *
 select_encoded_font (Output_def *layout, SCM chain)
 {
-  SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain);
+  SCM name = ly_chain_assoc_get (ly_symbol2scm ("font-name"), chain, SCM_BOOL_F);
 
-  if (!scm_is_pair (name) || !scm_is_string (scm_cdr (name)))
+  if (!scm_is_string (name))
     {
       SCM fonts = layout->lookup_variable (ly_symbol2scm ("fonts"));
       name = properties_to_font_size_family (fonts, chain);
     }
-  else
-    name = scm_cdr (name);
 
 #if HAVE_PANGO_FT2
   if (scm_is_string (name)
@@ -123,24 +120,21 @@ select_encoded_font (Output_def *layout, SCM chain)
 #endif
     if (scm_is_string (name))
       {
-       SCM mag = ly_chain_assoc (ly_symbol2scm ("font-magnification"), chain);
-       Real rmag = (scm_is_pair (mag)
-                    ? robust_scm2double (scm_cdr (mag), 1.0)
-                    : 1);
+       Real rmag =
+         robust_scm2double (ly_chain_assoc_get (ly_symbol2scm ("font-magnification"), chain, SCM_BOOL_F),
+                            1.0);
        Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
-               
+
        return find_scaled_font (layout, fm, rmag);
       }
     else if (scm_instance_p (name))
       {
-       SCM base_size  = scm_slot_ref (name, ly_symbol2scm ("default-size"));
+       SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size"));
        SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector"));
 
-       SCM font_size = ly_chain_assoc (ly_symbol2scm ("font-size"), chain);
-       Real req = 0;
-       if (scm_is_pair (font_size))
-         req = scm_to_double (scm_cdr (font_size));
-
+       Real req = robust_scm2double (ly_chain_assoc_get (ly_symbol2scm ("font-size"), chain, SCM_BOOL_F),
+                                     0.0);
+       
        return get_font_by_mag_step (layout, req, vec,
                                     scm_to_double (base_size));
       }