]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-def.cc
* input/regression/new-markup-scheme.ly: oops. font-family=music
[lilypond.git] / lily / paper-def.cc
index 6b89f107cbfa760effb2907bdf6ef8cd101e9816..7b55761d84c3d7825d97c87de05eee1c3e9bcd13 100644 (file)
@@ -10,6 +10,7 @@
 #include "ly-module.hh"
 #include "output-def.hh"
 #include "modified-font-metric.hh"
+#include "pango-font.hh"
 
 Real
 output_scale (Output_def *od)
@@ -17,23 +18,33 @@ output_scale (Output_def *od)
   return scm_to_double (od->lookup_variable (ly_symbol2scm ("outputscale")));
 }
 
+
+SCM
+get_font_table (Output_def *def)
+{
+  SCM font_table = def->lookup_variable (ly_symbol2scm ("scaled-fonts"));
+  if (scm_hash_table_p (font_table) != SCM_BOOL_T)
+    {
+      font_table = scm_c_make_hash_table (11);
+      def->set_variable (ly_symbol2scm ("scaled-fonts"), font_table);
+    }
+  return font_table;
+}
+  
+
+
 /* TODO: should add nesting for Output_def here too. */
 Font_metric *
-find_scaled_font (Output_def *mod, Font_metric *f, Real m,
-                 SCM font_encoding, SCM input_encoding)
+find_scaled_font (Output_def *mod, Font_metric *f, Real m)
 {
   if (mod->parent_)
-    return find_scaled_font (mod->parent_, f, m, font_encoding, input_encoding);
+    return find_scaled_font (mod->parent_, f, m);
   
-  Real lookup_mag = m;
+  Real lookup_mag = m / output_scale (mod);
 
-  SCM font_table = mod->lookup_variable (ly_symbol2scm ("scaled-fonts"));
-  if (scm_hash_table_p (font_table) != SCM_BOOL_T)
-    {
-      font_table = scm_c_make_hash_table (11);
-      mod->set_variable (ly_symbol2scm ("scaled-fonts"), font_table);
-    }
   
+  
+  SCM font_table = get_font_table (mod);
   SCM sizes = scm_hashq_ref (font_table, f->self_scm (), SCM_BOOL_F);
   if (sizes != SCM_BOOL_F)
     {
@@ -44,10 +55,8 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m,
   else
     sizes = SCM_EOL;
   
-  SCM val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag,
-                                                        font_encoding,
-                                                        input_encoding);
-
+  SCM val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag);
+  
   sizes = scm_acons (scm_make_real (lookup_mag), val, sizes);
   scm_gc_unprotect_object (val);
   scm_hashq_set_x (font_table, f->self_scm (), sizes);
@@ -60,7 +69,7 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m,
 Output_def * 
 scale_output_def (Output_def *o, Real amount)
 {
-  SCM proc = ly_scheme_function ("scale-layout");
+  SCM proc = ly_lily_module_constant ("scale-layout");
   SCM new_pap = scm_call_2 (proc, o->self_scm (), scm_double2num (amount));
   scm_gc_protect_object (new_pap);
 
@@ -70,7 +79,7 @@ scale_output_def (Output_def *o, Real amount)
 LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
           1, 0, 0,
           (SCM bp),
-          "Return fonts scaled up BP")
+          "Return fonts from the @code{\\paper} block @var{bp}.")
 {
   Output_def *b = unsmob_output_def (bp);
 
@@ -81,7 +90,7 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
   SCM ell = SCM_EOL;
   if (scm_hash_table_p (font_table) == SCM_BOOL_T)
     {
-      SCM func = ly_scheme_function ("hash-table->alist");
+      SCM func = ly_lily_module_constant ("hash-table->alist");
 
       for (SCM s = scm_call_1 (func, font_table); scm_is_pair (s);
           s = scm_cdr (s))
@@ -91,7 +100,8 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
            {
              Font_metric *fm = unsmob_metrics (scm_cdar (t));
 
-             if (dynamic_cast<Modified_font_metric*> (fm))
+             if (dynamic_cast<Modified_font_metric*> (fm)
+                 || dynamic_cast<Pango_font*> (fm))
                ell = scm_cons (fm->self_scm (), ell);
            }
        }