]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/parser.yy (assignment_id): allow LYRICS_STRING as
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 4 Feb 2005 11:44:22 +0000 (11:44 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 4 Feb 2005 11:44:22 +0000 (11:44 +0000)
identifier definition too, so foo = \lyrics { ...   } bar = #1
doesn't complain about "bar" being LYRICS_STRING.

* lily/paper-def.cc (find_pango_font): new routine; Store
pango_fonts in hash tab too. This is necessary for retrieving
Pango_fonts::physical_font_tab() later on.

* lily/pango-font.cc (pango_item_string_stencil): bugfix: don't
crash if psname is null.

* lily/lily-guile.cc (ly_hash2alist): new function

* Documentation/user/changing-defaults.itely (Text encoding):
rewrite.

* lily/pango-font.cc (physical_font_tab): new member. Store PSname
-> font_filename mapping.

* lily/pango-font-scheme.cc (LY_DEFINE): new file. New function
ly_pango_font_physical_fonts

* scm/framework-ps.scm (supplies-or-needs): extract names from
physical Pango_fonts.

* utf8.ly: new file.

16 files changed:
ChangeLog
Documentation/user/changing-defaults.itely
input/regression/utf8.ly [new file with mode: 0644]
lily/font-select.cc
lily/include/lily-guile.hh
lily/include/output-def.hh
lily/include/pango-font.hh
lily/lily-guile.cc
lily/main.cc
lily/object-key-undumper.cc
lily/output-def-scheme.cc
lily/pango-font-scheme.cc [new file with mode: 0644]
lily/pango-font.cc
lily/paper-def.cc
lily/parser.yy
scm/framework-ps.scm

index f8ca8ec8ddf71d19d03c20a3a25ff2962a8ef177..51ca633961a987a80f2f1c85fb565c75faf6b35f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-02-04  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * Documentation/user/changing-defaults.itely (Text encoding):
+       rewrite. 
+
+       * lily/pango-font.cc (physical_font_tab): new member. Store PSname
+       -> font_filename mapping.
+
+       * lily/pango-font-scheme.cc (LY_DEFINE): new file. New function
+       ly_pango_font_physical_fonts
+
+       * scm/framework-ps.scm (supplies-or-needs): extract names from
+       physical Pango_fonts.
+
+       * utf8.ly: new file.
+
 2005-02-02  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * Documentation/user/changing-defaults.itely (Page layout): add
index a0ab14bff67c241ab022eee00430e2e7eec085a2..455fa43ee39f7b47b8e00c33792b8ad4190bb0d6 100644 (file)
@@ -1,4 +1,4 @@
-@c -*- coding: latin-1; mode: texinfo; -*-
+@c -*- coding: utf-8; mode: texinfo; -*-
 @node Changing defaults
 @chapter Changing defaults
 
@@ -1123,7 +1123,6 @@ does not amount to much.  The initialization file
      (self-alignment-X . 0)
      (self-alignment-Y . 0)
      (script-priority . 100)
-     (font-encoding . number)
      (font-size . -5)
      (meta . ((interfaces . (finger-interface font-interface
                              text-script-interface text-interface
@@ -1394,11 +1393,12 @@ fonts.
 
 @itemize @bullet
 @item @code{font-encoding}
-is a symbol that sets layout of the glyphs.  Choices include @code{ec}
-for @TeX{} EC font encoding, @code{fetaBraces} for piano staff
-braces, @code{fetaMusic} the standard music font, including ancient
-glyphs, @code{fetaDynamic} for dynamic signs and @code{fetaNumber}
-for the number font.
+is a symbol that sets layout of the glyphs. This should only be set to
+select different types of non-text fonts, eg.
+
+@code{fetaBraces} for piano staff braces, @code{fetaMusic} the
+standard music font, including ancient glyphs, @code{fetaDynamic} for
+dynamic signs and @code{fetaNumber} for the number font.
 
 @item @code{font-family}
 is a symbol indicating the general class of the typeface.  Supported are
@@ -1552,59 +1552,36 @@ Syntax errors for markup mode are confusing.
 @node Text encoding
 @subsection Text encoding
 
-[FIXME: OBSOLETE, use UTF8 for input files.]
+LilyPond uses the Pango library to format multi-lingual texts.  This
+means that any text, be it title, lyric text, or musical instruction
+contaning non-ASCII characters should be entered as Unicode.
 
+@lilypondfile[utf8.ly]
 
-Texts can be entered in different encodings.  The encoding of the
-file can be set with @code{\encoding}.
+The @TeX{} backend does not handle encoding specially at all. Strings
+in the input are put in the output as-is. Extents of text items in the
+@TeX{} backend, are determined by reading a file created via the
+@file{texstr} backend,
 
 @example
-\encoding "latin1"
+  lilypond -b texstr input/les-nereides.ly
+  latex les-nereides.texstr
 @end example
 
-This command may be placed anywhere in the input file.  The current
-encoding is passed as an extra argument to @code{\markup} commands,
-and is passed similarly to lyric syllables.
-
-If no @code{\encoding} has been specified, then the encoding is taken
-from the @code{\layout} block (or @code{\paper}, if @code{\layout}
-does not specify encoding).  The variable @code{inputencoding} may be
-set to a string or symbol specifying the encoding, e.g.,
+The last command produces @file{les-nereides.textmetrics}, which is
+read when you execute
 
 @example
-\layout @{
-  inputencoding = "latin1"
-@} 
+  lilypond -b tex input/les-nereides.ly
 @end example
 
-Normal strings are unaffected by @code{\encoding}.  This means that
-the following will usually not produce `Baßtuba' in the title.
-
-@example
-\header @{
-  title = "Grazing cow"
-  instrument = "Baßtuba"
-@}
-@end example
+Both @file{les-nereides.texstr} and @file{les-nereides.tex} need
+suitable LaTeX wrappers to load appropriate La@TeX{} packages for
+interpreting non-ASCII strings.
 
-@noindent
-Rather, you should say
-@example
-instrument = \markup @{ Baßtuba @}
-@end example
-
-@noindent
-or set @code{inputencoding} in the @code{\paper} block. 
-
-There is a special encoding, called @code{TeX}.  This encoding does not
-reencode text for the font used.  Rather, it tries to guess the width
-of @TeX{} commands, such as @code{\"}.  Strings encoded with @code{TeX}
-are passed to the output back-end verbatim.
+@seealso
 
-@cindex encoding
-@cindex @code{\encoding}
-@cindex inputencoding
-@cindex @TeX{} commands in strings
+@inputfileref{input/regression/,utf8.ly}
 
 
 @node Nested scores
diff --git a/input/regression/utf8.ly b/input/regression/utf8.ly
new file mode 100644 (file)
index 0000000..89e5f76
--- /dev/null
@@ -0,0 +1,64 @@
+\version "2.5.10"
+
+% Edit this file using a Unicode aware editor, such as GVIM, GEDIT, Emacs
+
+%{
+
+I installed some additional font packages to get this working.
+
+taipeifonts 
+fonts-xorg-truetype 
+ttfonts-ja 
+fonts-arabic 
+ttfonts-zh_CN 
+fonts-ja 
+fonts-hebrew 
+
+%} 
+
+\header {
+
+  texidoc = "Various scripts may be used for texts (like titles and
+lyrics) introduced by entering them in UTF-8 encoding, and using a
+Pango based backend. Depending on the fonts installed, this fragment
+will render Japanese, Hebrew and Cyrillic.
+
+"
+  
+}
+
+
+japanese = \lyricsto "melody" \new Lyrics {  
+
+  いろはにほへど ちりぬるを
+  わがよたれぞ つねならむ
+  うゐのおくやまけふこえて
+  あさきゆめみじ ゑひもせず 
+
+ }
+
+
+bulgarian = \lyricsto "melody" \new Lyrics {
+
+    Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
+
+}
+
+hebrew = \lyricsto "melody" \new Lyrics { 
+זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן.
+}
+
+% latin1 section start
+
+ <<
+  \context Voice = "melody" \relative  { 
+     c2 d e f g f e 
+  } 
+  \hebrew
+  \bulgarian
+
+  %% no support for TTF  yet.
+  
+%  \japanese
+  
+>>
index d698cae60f1bca74dd12c17da40bd86ebb4d80e3..189421e339681dbd3af9ecf7430dc285efa9a2c5 100644 (file)
@@ -26,7 +26,7 @@ get_font_by_design_size (Output_def *layout, Real requested,
   Real last_size = -1e6;
   int i = 0;
 
-  String pango_description_string;
+  SCM pango_description_string = SCM_EOL;
   for (; i < n; i++)
     {
       SCM entry = scm_c_vector_ref (font_vector, i);
@@ -43,7 +43,7 @@ get_font_by_design_size (Output_def *layout, Real requested,
        {
          size = scm_to_double (scm_car (entry));
          pango_description_string
-           = ly_scm2string (scm_cdr (entry));
+           = scm_cdr (entry);
        }
 #endif
       
@@ -64,14 +64,12 @@ get_font_by_design_size (Output_def *layout, Real requested,
     }
   
   Font_metric *fm = 0;
-  if (pango_description_string != "")
+  if (scm_is_string (pango_description_string))
     {
 #if HAVE_PANGO_FT2
-      PangoFontDescription *description
-       = pango_font_description_from_string (pango_description_string.to_str0 ());
-      return all_fonts_global->find_pango_font (description,
-                                               requested / size,
-                                               output_scale (layout));
+      return find_pango_font (layout,
+                             pango_description_string,
+                             requested / size);
 #else
       error ("Trying to retrieve pango font without HAVE_PANGO_FT2."); 
 #endif
index 4b23c23ad1c90dc970317a1196e4c19ed559601d..01c6646a0651c2d461a5ea92a9495982c16a5f55 100644 (file)
@@ -61,6 +61,8 @@ SCM parse_symbol_list (char const *);
 SCM robust_list_ref(int i, SCM l);
 SCM alist_to_hashq (SCM);
 
+SCM ly_alist_vals (SCM alist);
+SCM ly_hash2alist (SCM tab);
 
 /* inserts at front, removing dublicates */
 inline SCM ly_assoc_front_x(SCM alist, SCM key, SCM val)
index ee5d459d720e8d649aa962f0f7e1961825dc639b..b5c60c0c59e854ee4d8f4f51376ffba29500ebad 100644 (file)
@@ -74,9 +74,10 @@ Font_metric *select_font (Output_def *layout, SCM chain);
 DECLARE_UNSMOB (Output_def, output_def);
 
 
-Font_metric *find_scaled_font (Output_def *od,
-                              Font_metric *f, Real magnification);
+Font_metric* find_pango_font (Output_def *layout,  SCM descr, Real factor);
+Font_metric *find_scaled_font (Output_def *od, Font_metric *f, Real magnification);
 Output_def *scale_output_def (Output_def *def, Real scale);
+
 Real output_scale (Output_def*);
 
 #endif /* MUSIC_OUTPUT_DEF_HH */
index 08e21edc553c5d6c1613fa59f1e4562f0580a7f8..31b858f14343c9782360360509722175adcd412c 100644 (file)
@@ -25,9 +25,10 @@ class Pango_font : public Font_metric
   PangoFontDescription *pango_description_; 
   PangoAttrList *attribute_list_;
   Real scale_;
-  SCM subfonts_;
-  
+  SCM physical_font_tab_;
+
 public:
+  SCM physical_font_tab () const; 
   Pango_font (PangoFT2FontMap *,
              Direction leftright,
              PangoFontDescription *,
@@ -39,7 +40,6 @@ public:
   Stencil text_stencil (String) const;
   Stencil pango_item_string_stencil (PangoItem*, String, Real) const;
 
-  virtual SCM sub_fonts () const;
   virtual void derived_mark () const;
 };
 
index e0aeccaf3e82eabea3419836bbec7f2f5200e49b..50bb49e841e9eb0a395f14e9e8940fa3a5cff491 100644 (file)
@@ -722,3 +722,23 @@ alist_equal_p (SCM a, SCM b)
     }
   return true;
 }
+
+
+
+SCM
+ly_alist_vals (SCM alist)
+{
+  SCM x = SCM_EOL;
+  for (SCM p = alist; scm_is_pair (p); p = scm_cdr (p))
+    {
+      x = scm_cons (scm_cdar (p), x);
+    }
+  return x;
+}
+
+SCM
+ly_hash2alist (SCM tab)
+{
+  SCM func = ly_lily_module_constant ("hash-table->alist");
+  return scm_call_1 (func, tab);
+}
index d89bfcd1eaf9c4693e6b67386aa4462a63dbb820..514d266d07188a2c989660a418beb518c8546518 100644 (file)
@@ -275,6 +275,10 @@ main_with_guile (void *, int, char **)
   init_global_tweak_registry ();
   init_fontconfig ();
   init_freetype ();
+
+  is_pango_format_global = (output_backend_global != "tex"
+                           && output_backend_global != "texstr");
+
   all_fonts_global = new All_font_metrics (global_path.to_string ());
 
   init_scheme_code_string += ")";
@@ -380,10 +384,9 @@ parse_argv (int argc, char **argv)
          warranty ();
          exit (0);
          break;
+         
        case 'b':
          output_backend_global = option_parser->optional_argument_str0_;
-         is_pango_format_global = (output_backend_global != "tex"
-                                   &&output_backend_global != "texstr");
          break;
 
        case 'f':
index 55f17f923c0d3e4b7703510806b61464bd34e5ec..f990a0fb3dc25cf21c6210f7b9a57c79b75f0bcf 100644 (file)
@@ -30,6 +30,7 @@ Object_key_undumper::mark_smob (SCM smob)
 int
 Object_key_undumper::print_smob (SCM s, SCM port, scm_print_state*)
 {
+  (void) s; 
   scm_puts ("#<Object_key_undumper>", port);
   return 1;
 }
index b22f43407116a807e27d566dda012b65ff2180d8..65505c9b2f0f8a1a0fc9215c25dc3c26e6042a47 100644 (file)
@@ -131,28 +131,42 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts",
 {
   Output_def *b = unsmob_output_def (bp);
 
-  SCM font_table = b->lookup_variable (ly_symbol2scm ("scaled-fonts"));
   
   SCM_ASSERT_TYPE (b, bp, SCM_ARG1, __FUNCTION__, "paper");
 
-  SCM ell = SCM_EOL;
-  if (scm_hash_table_p (font_table) == SCM_BOOL_T)
+  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)
     {
-      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))
-       {
-         SCM entry = scm_car (s);
-         for (SCM t = scm_cdr (entry); scm_is_pair (t); t = scm_cdr (t))
-           {
-             Font_metric *fm = unsmob_metrics (scm_cdar (t));
-
-             if (dynamic_cast<Modified_font_metric*> (fm)
-                 || dynamic_cast<Pango_font*> (fm))
-               ell = scm_cons (fm->self_scm (), ell);
-           }
-       }
+      // strip original-fonts/pango-font-descriptions
+      alist2 = scm_append (ly_alist_vals (ly_hash2alist (tab2)));
+
+      // strip size factors
+      alist2 = ly_alist_vals (alist2); 
     }
-  return ell;
+
+  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;
 }
diff --git a/lily/pango-font-scheme.cc b/lily/pango-font-scheme.cc
new file mode 100644 (file)
index 0000000..2138e95
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+  pango-font-scheme.cc --  implement Pango_font
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+
+#define PANGO_ENABLE_BACKEND // ugh, why necessary?
+
+#include <pango/pangoft2.h>
+
+#include "main.hh"
+#include "lookup.hh"
+#include "dimensions.hh"
+#include "pango-font.hh"
+#include "warn.hh"
+
+#if HAVE_PANGO_FT2
+#include "stencil.hh" 
+
+
+LY_DEFINE (ly_pango_font_p, "ly:pango-font?",
+          1, 0, 0,
+          (SCM f),
+          "Is @var{f} a pango font?")
+{
+  return scm_from_bool (dynamic_cast<Pango_font*> (unsmob_metrics (f)));
+}
+
+
+
+LY_DEFINE (ly_pango_font_physical_fonts, "ly:pango-font-physical-fonts",
+          1, 0, 0,
+          (SCM f),
+          "Return alist of  (PSNAME . FILENAME) tuples.")
+{
+  Pango_font *pf = dynamic_cast<Pango_font*> (unsmob_metrics (f));
+
+  SCM alist = SCM_EOL;
+  if (pf)
+    alist = ly_hash2alist (pf->physical_font_tab ());
+
+  return alist;
+}
+#endif
index 8ff54d23ab7f808b035f1f0f9865b1750728829a..22dfb6b47fc4988e8e56e490fe23b47965a8b788 100644 (file)
@@ -16,6 +16,7 @@
 #include "lookup.hh"
 #include "dimensions.hh"
 #include "pango-font.hh"
+#include "warn.hh"
 
 #if HAVE_PANGO_FT2
 #include "stencil.hh" 
@@ -26,7 +27,7 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap,
                        PangoFontDescription *description,
                        Real output_scale)
 {
-  subfonts_ = SCM_EOL;
+  physical_font_tab_ = scm_c_make_hash_table (11);
   PangoDirection pango_dir = (dir == RIGHT)
     ? PANGO_DIRECTION_LTR
     : PANGO_DIRECTION_RTL;
@@ -61,14 +62,15 @@ Pango_font::~Pango_font ()
 void
 Pango_font::register_font_file (String filename, String ps_name) 
 {
-  subfonts_ = scm_cons (scm_makfrom0str (filename.to_str0 ()),
-                       subfonts_);
+  scm_hash_set_x (physical_font_tab_,
+                 scm_makfrom0str (ps_name.to_str0()),
+                 scm_makfrom0str (filename.to_str0()));
 }
 
 void
 Pango_font::derived_mark () const
 {
-  scm_gc_mark (subfonts_);
+  scm_gc_mark (physical_font_tab_);
 }
 
 Stencil
@@ -124,21 +126,35 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con
   char *filename = 0;
   FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &filename);
   char const *ps_name = FT_Get_Postscript_Name (ftface);
-  ((Pango_font *) this)->register_font_file (filename, ps_name);
-  pango_fc_font_unlock_face (fcfont);
+
+  if (ps_name)
+    {
+      ((Pango_font *) this)->register_font_file (filename, ps_name);
+      pango_fc_font_unlock_face (fcfont);
       
-  SCM expr = scm_list_4 (ly_symbol2scm ("glyph-string"),
-                        scm_makfrom0str (ps_name),
-                        scm_from_double (size),
-                        ly_quote_scm (glyph_exprs));
+      SCM expr = scm_list_4 (ly_symbol2scm ("glyph-string"),
+                            scm_makfrom0str (ps_name),
+                            scm_from_double (size),
+                            ly_quote_scm (glyph_exprs));
 
-  Stencil item_stencil (b, expr);
+      return Stencil (b, expr);
+    }
+  else
+    {
+      warning (_ ("FreeType face has no PostScript font name."));      
+      return Stencil();
+    }
+}
 
-  return item_stencil;  
+SCM
+Pango_font::physical_font_tab () const
+{
+  return physical_font_tab_;
 }
 
 
 Stencil
+
 Pango_font::text_stencil (String str) const
 {
   GList *items = pango_itemize (context_,
@@ -195,11 +211,6 @@ Pango_font::text_stencil (String str) const
   return dest;
 }
 
-SCM
-Pango_font::sub_fonts () const
-{
-  return subfonts_;
-}
 
 SCM 
 Pango_font::font_file_name () const
@@ -207,14 +218,6 @@ Pango_font::font_file_name () const
   return SCM_BOOL_F;
 }
 
-LY_DEFINE (ly_pango_font_p, "ly:pango-font?",
-          1, 0, 0,
-          (SCM f),
-          "Is @var{f} a pango font?")
-{
-  return scm_from_bool (dynamic_cast<Pango_font*> (unsmob_metrics (f)));
-}
-
 
 #endif
 
index 6dd082f9f642e53726fdfcafa7c30c26a766aa08..62b585bb5ab192f5403adbf7d90b61cdd22cef5f 100644 (file)
@@ -10,6 +10,8 @@
 #include "output-def.hh"
 #include "modified-font-metric.hh"
 #include "pango-font.hh"
+#include "all-font-metrics.hh"
+
 
 Real
 output_scale (Output_def *od)
@@ -17,7 +19,6 @@ output_scale (Output_def *od)
   return scm_to_double (od->lookup_variable (ly_symbol2scm ("outputscale")));
 }
 
-
 SCM
 get_font_table (Output_def *def)
 {
@@ -29,8 +30,18 @@ get_font_table (Output_def *def)
     }
   return font_table;
 }
-  
 
+SCM
+get_pango_font_table (Output_def *def)
+{
+  SCM font_table = def->lookup_variable (ly_symbol2scm ("pango-fonts"));
+  if (scm_hash_table_p (font_table) != SCM_BOOL_T)
+    {
+      font_table = scm_c_make_hash_table (11);
+      def->set_variable (ly_symbol2scm ("pango-fonts"), font_table);
+    }
+  return font_table;
+}
 
 /* TODO: should add nesting for Output_def here too. */
 Font_metric *
@@ -42,15 +53,10 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m)
   Real lookup_mag = m / output_scale (mod);
   
   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)
-    {
-      SCM met = scm_assoc (scm_make_real (lookup_mag), sizes);
-      if (scm_is_pair (met))
-       return unsmob_metrics (scm_cdr (met));
-    }
-  else
-    sizes = SCM_EOL;
+  SCM sizes = scm_hashq_ref (font_table, f->self_scm (), SCM_EOL);
+  SCM handle = scm_assoc (scm_make_real (lookup_mag), sizes);
+  if (scm_is_pair (handle))
+    return unsmob_metrics (scm_cdr (handle));
   
   SCM val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag);
   
@@ -60,6 +66,33 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m)
   return unsmob_metrics (val);
 }
 
+Font_metric*
+find_pango_font (Output_def *layout,  SCM descr, Real factor)
+{
+  if (layout->parent_)
+    return find_pango_font (layout->parent_, descr, factor);
+  
+  SCM table = get_pango_font_table (layout);
+  SCM sizes =  scm_hash_ref (table, descr, SCM_EOL);
+  SCM size_key = scm_from_double (factor);
+  SCM handle = scm_assoc (size_key, sizes);
+  if (scm_is_pair (handle))
+    {
+      return unsmob_metrics (scm_cdr (handle));
+    }
+
+  PangoFontDescription *description
+    = pango_font_description_from_string (scm_i_string_chars (descr));
+  Font_metric *fm = all_fonts_global->find_pango_font (description,
+                                                      factor,
+                                                      output_scale (layout));
+
+  sizes = scm_acons (size_key,  fm->self_scm(), sizes);
+  scm_hash_set_x (table, descr, sizes);
+
+  return fm;
+}
+
 /* TODO: this is a nasty interface. During formatting,
    the Output_def should be scaled to the output_scale_
    specified in the toplevel Output_def.  */
index 23407d253976af8013448c01ac24177fa48cd132..722f299c83cc05cd36c9aa02acd68dcec42c8bee 100644 (file)
@@ -418,6 +418,7 @@ or
 %type <outputdef>      output_def_body output_def_head
 %type <outputdef> output_def paper_block 
 
+%type <scm>     assignment_id
 %type <scm>    Music_list
 %type <scm>    chord_body_elements
 %type <scm>    chord_item chord_items chord_separator new_chord
@@ -554,8 +555,13 @@ lilypond_header:
 /*
        DECLARATIONS
 */
+assignment_id:
+       STRING          { $$ = $1; }
+       | LYRICS_STRING { $$ = $1; }
+       ;
+
 assignment:
-       STRING '=' identifier_init  {
+       assignment_id '=' identifier_init  {
                if (! is_regular_identifier ($1))
                {
                        @1.warning (_ ("Identifier should have alphabetic characters only"));
@@ -1280,12 +1286,12 @@ re_rhythmed_music:
                $$ = all;
                scm_gc_unprotect_object (voice->self_scm ());
        }
-       | LYRICSTO {
+       | LYRICSTO simple_string {
                THIS->lexer_->push_lyric_state ();
-       } simple_string Music {
+       } Music {
                THIS->lexer_->pop_state ();
                Music *music = $4;
-               SCM name = $3;
+               SCM name = $2;
                $$ = make_lyric_combine_music (name, music);
                scm_gc_unprotect_object (music->self_scm ());
        }
index a1acc277cfe6bb4371936e7cf094c71b21a31707..ed57823b4300dfec2b5fb4cfb633de2362ca9f2d 100644 (file)
@@ -83,6 +83,7 @@
          (display (list font fontname)))
       (define-font plain fontname scaling)))
 
+
   (apply string-append
         (map (lambda (x) (font-load-command x))
              (filter (lambda (x) (not (ly:pango-font? x)))
   (ly:outputter-dump-stencil outputter page)
   (ly:outputter-dump-string outputter "} stop-system \nshowpage\n"))
 
+
 (define (supplies-or-needs paper load-fonts?)
-  (let* ((fonts (ly:paper-fonts paper)))
+  (define (extract-names font)
+    (if (ly:pango-font? font)
+       (map car (ly:pango-font-physical-fonts font))
+       (list (ly:font-name font))))
+  
+  (let* ((fonts (ly:paper-fonts paper))
+        (names (apply append (map extract-names fonts)))
+        )
+    
     (apply string-append
           (map (lambda (f)
                  (format
                   (if load-fonts?
                    "%%DocumentSuppliedResources: font ~a\n"
                    "%%DocumentNeededResources: font ~a\n")
-                  (ly:font-name f)))
-               fonts))))
+                  f))
+               names))))
 
 (define (eps-header paper bbox load-fonts?)
     (string-append "%!PS-Adobe-2.0 EPSF-2.0\n"
           (all-font-names
            (map
             (lambda (font)
-              (if (string? (ly:font-file-name font))
-                  (list (ly:font-file-name font))
-                  (ly:font-sub-fonts font)))
-
+              (cond
+               ((string? (ly:font-file-name font)) (list (ly:font-file-name font)))
+               ((ly:pango-font? font)
+                (map cdr  (ly:pango-font-physical-fonts font)))
+               (else (ly:font-sub-fonts font))))
+                  
             fonts))
+          
           (font-names
            (uniq-list
             (sort (apply append all-font-names) string<?)))