]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/output-def-scheme.cc
remove PDF related files
[lilypond.git] / lily / output-def-scheme.cc
index 5465ef4075e9611b46145e025c8f2b7d19fae396..65505c9b2f0f8a1a0fc9215c25dc3c26e6042a47 100644 (file)
@@ -7,6 +7,9 @@
 
 */
 
+#include "font-metric.hh"
+#include "pango-font.hh"
+#include "modified-font-metric.hh"
 #include "output-def.hh"
 #include "ly-module.hh"
 #include "context-def.hh"
@@ -94,3 +97,76 @@ LY_DEFINE (ly_make_output_def, "ly:make-output-def",
   Output_def *bp = new Output_def ;
   return scm_gc_unprotect_object (bp->self_scm ());
 }
+
+LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 2, 0, 0,
+          (SCM paper_smob, SCM chain),
+
+          "Return a font metric satisfying the font-qualifiers "
+          "in the alist chain @var{chain}.\n"
+          "(An alist chain is a list of alists, "
+          "containing grob properties).\n")
+{
+  Output_def *paper = unsmob_output_def (paper_smob);
+  SCM_ASSERT_TYPE (paper, paper_smob, SCM_ARG1,
+                  __FUNCTION__, "paper definition");
+  
+  Font_metric *fm = select_font (paper, chain);
+  return fm->self_scm ();
+}
+
+LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 2, 0, 0,
+          (SCM layout_smob, SCM name),
+          "Return the layout variable @var{name}.")
+{
+  Output_def *layout = unsmob_output_def (layout_smob);
+  SCM_ASSERT_TYPE (layout, layout_smob, SCM_ARG1,
+                  __FUNCTION__, "layout definition");
+  return scm_make_real (layout->get_dimension (name));
+}
+
+LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
+          1, 0, 0,
+          (SCM bp),
+          "Return fonts from the @code{\\paper} block @var{bp}.")
+{
+  Output_def *b = unsmob_output_def (bp);
+
+  
+  SCM_ASSERT_TYPE (b, bp, SCM_ARG1, __FUNCTION__, "paper");
+
+  SCM tab1 = b->lookup_variable (ly_symbol2scm ("scaled-fonts"));
+  SCM tab2 = b->lookup_variable (ly_symbol2scm ("pango-fonts"));
+
+  SCM alist1 = SCM_EOL;
+  if (scm_hash_table_p (tab1) == SCM_BOOL_T)
+    {
+      alist1 = scm_append (ly_alist_vals (ly_hash2alist (tab1)));
+      
+      alist1 = ly_alist_vals (alist1);
+    }
+
+  SCM alist2 = SCM_EOL;
+  if (scm_hash_table_p (tab2) == SCM_BOOL_T)
+    {
+      // strip original-fonts/pango-font-descriptions
+      alist2 = scm_append (ly_alist_vals (ly_hash2alist (tab2)));
+
+      // strip size factors
+      alist2 = ly_alist_vals (alist2); 
+    }
+
+  SCM alist = scm_append (scm_list_2 (alist1, alist2));
+  SCM font_list = SCM_EOL;
+  for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s))
+    {
+      SCM entry = scm_car (s);
+      
+      Font_metric *fm = unsmob_metrics (entry);
+
+      if (dynamic_cast<Modified_font_metric*> (fm)
+         || dynamic_cast<Pango_font*> (fm))
+       font_list = scm_cons (fm->self_scm (), font_list);
+    }
+  
+  return font_list;
+}