]> git.donarmstrong.com Git - lilypond.git/commitdiff
* flower/file-path.cc (find): try to open directly as well, so we
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 25 Dec 2004 02:38:23 +0000 (02:38 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 25 Dec 2004 02:38:23 +0000 (02:38 +0000)
find absolute path files.

* lily/pango-select.cc: new file.

* scm/framework-ps.scm: remove all encoding code.
load pfb/pfa for PangoFont too.

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

21 files changed:
ChangeLog
Documentation/user/invoking.itely
VERSION
config.hh.in
flower/file-path.cc
lily/all-font-metrics.cc
lily/font-metric.cc
lily/font-select.cc
lily/include/font-metric.hh
lily/include/lily-guile.hh
lily/include/output-def.hh
lily/include/pango-font.hh
lily/lily-guile.cc
lily/pango-font.cc
lily/pango-select.cc [new file with mode: 0644]
lily/paper-def.cc
lily/text-item.cc
ps/lilyponddefs.ps
scm/framework-ps.scm
scm/output-ps.scm
scm/paper.scm

index 7e7fdd754f54cdf1844fe0548ae36d7f6650ec66..c0de0c69356abb7034b89e22d89a801ee793871a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-12-25  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/framework-ps.scm: remove all encoding code. 
+       load pfb/pfa for PangoFont too.
+       
+       * lily/lily-guile.cc (ly_chain_assoc_get): new function.
+
 2004-12-22  Werner Lemberg  <wl@gnu.org>
 
        Prepare glyph shapes for mf2pt1 conversion.
index 7fcc0bcd8e05b8a3ca606c53dcaf9bcf314ddb08..7359b9ac67c48a12e435c1d23a8e11b6c59fe1ef 100644 (file)
@@ -57,7 +57,7 @@ information.
 
 
 @item -f,--format=@var{format}
-A comma separated list of back-end output formats to use.  Choices are
+the output format to use for the back-end.  Choices are
 @table @code
 @item tex
 for @TeX{} output, to be processed with La@TeX{}
@@ -65,7 +65,7 @@ for @TeX{} output, to be processed with La@TeX{}
  for PostScript
 @cindex PostScript output
 @item svg
- for SVG (Scalable Vector Graphics.)
+ for SVG (Scalable Vector Graphics)
 @cindex SVG (Scalable Vector Graphics)
 @item scm
  for a dump of the raw, internal Scheme-based drawing commands.
diff --git a/VERSION b/VERSION
index 509cbde46e451402b1cdbe8667deb657b2b89cc7..189da5b16f6f03efc73b3be62eeee7ba946ef95f 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=5
-PATCH_LEVEL=4
+PATCH_LEVEL=5
 MY_PATCH_LEVEL=
 
index 6dcc94c183f424d95b027312a6c807593176ea77..cb6a64eafe331344ba8e4d6e1aa15315179c6458 100644 (file)
@@ -76,5 +76,8 @@
 /* define if you have pango 1.6 */
 #define HAVE_PANGO16 0
 
+/* define if you have pango FT2 binding */
+#define HAVE_PANGO_FT2 0
+
 /* define if you have pango_fc_font_map_add_decoder_find_func */
 #define HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC 0
index eb08b9251a7702e91672deb9efa4e16807d013fc..25b3931dbc6f07a5a123fe8bf6377c500b3e4809 100644 (file)
@@ -54,8 +54,17 @@ File_path::find (String name) const
 {
   if (!name.length () || (name == "-") )
     return name;
-  int n = size ();
-  for (int i = 0; i < n; i++)
+
+  /*
+    TODO:  should check for absolute path
+   */
+  if (FILE *f =fopen (name.to_str0 (), "r"))
+    {
+      fclose (f);
+      return name;
+    }
+       
+  for (int i = 0; i < size (); i++)
     {
       String file_name = elem (i);
       String sep = ::to_string (DIRSEP);
index a59738536ec31319cfa91c237a08ce1e3a9dc937..c9b4b5d5e08a2a0f07e204e8c87b45c496b60a90 100644 (file)
@@ -25,7 +25,7 @@ All_font_metrics::All_font_metrics (String path)
   tfm_dict_ = new Scheme_hash_table;
   otf_dict_ = new Scheme_hash_table;
 
-#ifdef HAVE_PANGO16
+#if HAVE_PANGO_FT2
   PangoFontMap*pfm =     pango_ft2_font_map_new ();
 
   pango_ft2_fontmap_ =
@@ -53,7 +53,7 @@ All_font_metrics::All_font_metrics (All_font_metrics const&)
 {
 }
 
-#ifdef HAVE_PANGO16
+#if HAVE_PANGO_FT2
 Pango_font *
 All_font_metrics::find_pango_font (PangoFontDescription*description)
 {
index 1a6e215041df7b8e390263a4c275773c559defc7..277c2cadfc25719ae843f5bba527139e0833065a 100644 (file)
@@ -227,7 +227,13 @@ LY_DEFINE (ly_font_file_name, "ly:font-file-name",
 {
   Font_metric *fm = unsmob_metrics (font);
   SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
-  return scm_car (fm->description_);
+  return fm->font_file_name();
+}
+
+SCM 
+Font_metric::font_file_name () const
+{
+  return scm_car (description_);
 }
 
 String
index 3b17dedc2507c3ac13be1da072e33eecfaf7d474..c05f0b1f2016a0ae6fc911a70e7728a22e107fcd 100644 (file)
@@ -109,7 +109,7 @@ properties_to_font_size_family (SCM fonts, SCM alist_chain)
 Font_metric *
 select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding)
 {
-  SCM name = ly_assoc_chain (ly_symbol2scm ("font-name"), chain);
+  SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain);
 
   if (!scm_is_pair (name) || !scm_is_string (scm_cdr (name)))
     {
@@ -121,14 +121,14 @@ select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding)
 
   if (scm_is_string (name))
     {
-      SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain);
+      SCM mag = ly_chain_assoc (ly_symbol2scm ("font-magnification"), chain);
       Real rmag = (scm_is_pair (mag)
                   ? robust_scm2double (scm_cdr (mag), 1.0)
                   : 1);
       Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
                
       SCM font_encoding
-       = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain));
+       = scm_cdr (ly_chain_assoc (ly_symbol2scm ("font-encoding"), chain));
       return find_scaled_font (layout, fm, rmag, font_encoding, input_encoding);
     }
   else if (scm_instance_p (name))
@@ -136,13 +136,13 @@ select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding)
       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_assoc_chain (ly_symbol2scm ("font-size"), chain);
+      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));
 
       SCM font_encoding
-       = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain));
+       = scm_cdr (ly_chain_assoc (ly_symbol2scm ("font-encoding"), chain));
 
       return get_font_by_mag_step (layout, req, vec, scm_to_double (base_size),
                                   font_encoding, input_encoding);
index cb20aa5f5e22200ab2713e454a8625d03209aaef..b9da9002b9435e910275d0d3dab84e12b87acd64 100644 (file)
@@ -38,7 +38,7 @@ public:
   virtual Stencil get_ascii_char_stencil (int k) const;
   virtual String coding_scheme () const;
   virtual SCM sub_fonts () const;
-  
+  virtual SCM font_file_name () const; 
   DECLARE_SMOBS (Font_metric,);
 
 private:
index 40b9bcc13da1e37302f801f059410f6b48c8cc73..d813ed44cfa9d5dc8ffae8dd139e98cd4a2817dd 100644 (file)
@@ -96,7 +96,8 @@ String ly_scm2string (SCM s);
 String ly_symbol2string (SCM);
 SCM ly_offset2scm (Offset);
 Offset ly_scm2offset (SCM);
-SCM ly_assoc_chain (SCM key, SCM achain);
+SCM ly_chain_assoc (SCM key, SCM achain);
+SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault);
 SCM ly_assoc_cdr (SCM key, SCM alist);
 SCM ly_assoc_get (SCM key, SCM alist, SCM def);
 Interval ly_scm2interval (SCM);
index 15b35f1eacbe860722e9dbd122752d83f084d389..92a5f13996961e883546ffc3206ba6d1b57ce7bd 100644 (file)
@@ -58,7 +58,7 @@ public:
   void set_variable (SCM sym, SCM val);
   Real get_dimension (SCM symbol) const;
 };
-
+SCM get_font_table (Output_def *def);
 void assign_context_def (Output_def *m, SCM transdef);
 SCM find_context_def (Output_def const *m, SCM name);
 
index de97e0bf5799dcaa1fec466d20464705985ef11d..e6241c94938ec78fbe796dd7ba6033466d8e8ae6 100644 (file)
@@ -24,7 +24,12 @@ struct Pango_font : Font_metric
   PangoContext *context_;
   PangoAttrList *attribute_list_;
   Real scale_;
+  SCM subfonts_;
 public:
+  virtual SCM sub_fonts () const;
+  SCM font_file_name () const;
+  virtual void derived_mark () const;
+  void register_font_file (String, String);
   Stencil text_stencil (String) const;
   Pango_font (PangoFT2FontMap *,
              int dpi, 
@@ -38,7 +43,10 @@ symbols_to_pango_font_description(SCM family,
                                  SCM variant,
                                  SCM weight,
                                  SCM stretch,
-                                 SCM size);
+                                 Real size);
+
+Font_metric *
+select_pango_font (Output_def *layout, SCM chain);
 
 #endif
 #endif /* PANGO_FONT_HH */
index 2d7455019da2cb4150624332710ac15612cf33f9..a5cd70e2e9f92ebacd1b3642e9438d121af5b3b8 100644 (file)
@@ -446,11 +446,23 @@ ly_deep_copy (SCM src)
   return src;
 }
 
-
-
+SCM
+ly_chain_assoc_get (SCM key, SCM achain, SCM dfault)
+{
+  if (scm_is_pair (achain))
+    {
+      SCM handle = scm_assoc (key, scm_car (achain));
+      if (scm_is_pair (handle))
+       return scm_cdr (handle);
+      else
+       return ly_chain_assoc (key, scm_cdr (achain));
+    }
+  else
+    return dfault;
+}
 
 SCM
-ly_assoc_chain (SCM key, SCM achain)
+ly_chain_assoc (SCM key, SCM achain)
 {
   if (scm_is_pair (achain))
     {
@@ -458,7 +470,7 @@ ly_assoc_chain (SCM key, SCM achain)
       if (scm_is_pair (handle))
        return handle;
       else
-       return ly_assoc_chain (key, scm_cdr (achain));
+       return ly_chain_assoc (key, scm_cdr (achain));
     }
   else
     return SCM_BOOL_F;
index d9944caaab6eb663b310b58dc6bf8d275dcdb570..7529ae8115c40956db79fb4986c26aca906c19db 100644 (file)
 
 */
 
-#include <pango/pangoft2.h>
-
-#include "pango-font.hh"
-#include "stencil.hh" 
-
-PangoStyle
-symbol_to_pango_style (SCM style)
-{
-  PangoStyle pstyle = PANGO_STYLE_NORMAL;
-  if (style == ly_symbol2scm ("italic"))
-    {
-      pstyle = PANGO_STYLE_NORMAL;
-    }
-  else if (style == ly_symbol2scm ("oblique")
-          || style == ly_symbol2scm ("slanted")
-          )
-    {
-      pstyle = PANGO_STYLE_OBLIQUE;
-    }
-
-  return pstyle;
-}
 
-PangoVariant
-symbol_to_pango_variant (SCM variant)
-{
-  PangoVariant pvariant;
-  if (variant == ly_symbol2scm ("caps"))
-    {
-      pvariant = PANGO_VARIANT_SMALL_CAPS;
-    }
-  return pvariant;
-}
-
-
-PangoWeight
-symbol_to_pango_weight (SCM weight)
-{
-  PangoWeight pw = PANGO_WEIGHT_NORMAL;
-  if (weight == ly_symbol2scm ("bold"))
-    {
-      pw = PANGO_WEIGHT_BOLD;
-    }
-  if (weight == ly_symbol2scm ("heavy"))
-    {
-      pw = PANGO_WEIGHT_HEAVY;
-    }
-  if (weight == ly_symbol2scm ("ultrabold"))
-    {
-      pw = PANGO_WEIGHT_ULTRABOLD;
-    }
-  if (weight == ly_symbol2scm ("light"))
-    {
-      pw = PANGO_WEIGHT_LIGHT;
-    }
-  if (weight == ly_symbol2scm ("ultralight"))
-    {
-      pw = PANGO_WEIGHT_ULTRALIGHT;
-    }
-
-  return pw;
-}
+#define PANGO_ENABLE_BACKEND // ugh, why necessary?
 
-PangoStretch
-symbol_to_pango_stretch (SCM stretch)
-{
-  PangoStretch ps = PANGO_STRETCH_NORMAL;
-
-  /*
-    // TODO
-    
-  PANGO_STRETCH_ULTRA_CONDENSED,
-  PANGO_STRETCH_EXTRA_CONDENSED,
-  PANGO_STRETCH_CONDENSED,
-  PANGO_STRETCH_SEMI_CONDENSED,
-  
-  PANGO_STRETCH_SEMI_EXPANDED,
-  PANGO_STRETCH_EXPANDED,
-  PANGO_STRETCH_EXTRA_EXPANDED,
-  PANGO_STRETCH_ULTRA_EXPANDED
-  */ 
-  return ps;
-}
+#include <pango/pangoft2.h>
 
+#include "pango-font.hh"
 
+#if HAVE_PANGO_FT2
+#include "stencil.hh" 
 
-PangoFontDescription* 
-symbols_to_pango_font_description(SCM family,
-                                 SCM style,
-                                 SCM variant,
-                                 SCM weight,
-                                 SCM stretch,
-                                 SCM size)
-{
-  PangoFontDescription * description = pango_font_description_new ();
-
-  pango_font_description_set_family (description,
-                                    ly_symbol2string (family).to_str0 ());
-  pango_font_description_set_style (description,
-                                   symbol_to_pango_style (style));
-  pango_font_description_set_variant (description,
-                                     symbol_to_pango_variant (variant));
-  pango_font_description_set_weight (description,
-                                    symbol_to_pango_weight (weight));
-  pango_font_description_set_stretch (description,
-                                     symbol_to_pango_stretch (stretch));
-  pango_font_description_set_size (description,
-                                  gint (scm_to_double (size) * PANGO_SCALE));
-
-  return description;
-}
 
 Pango_font::Pango_font (PangoFT2FontMap *fontmap,
                        int resolution,
                        Direction dir,
                        PangoFontDescription * description)
 {
+  subfonts_ = SCM_EOL;
   PangoDirection pango_dir = (dir==RIGHT)
     ? PANGO_DIRECTION_LTR
     : PANGO_DIRECTION_RTL;
   context_ = pango_ft2_font_map_create_context (fontmap);  
   attribute_list_= pango_attr_list_new();
-  scale_ = PANGO_SCALE * resolution * 72.27;
+  scale_ = 1.0 / (PANGO_SCALE * resolution * 72.27);
   
   pango_context_set_language (context_, pango_language_from_string ("en_US"));
   pango_context_set_base_dir (context_, pango_dir);
   pango_context_set_font_description (context_, description);
 }
 
+
 Pango_font::~Pango_font ()
 {
   g_object_unref (context_);
   pango_attr_list_unref (attribute_list_);
 }
 
+void
+Pango_font::register_font_file (String filename, String ps_name) 
+{
+  subfonts_ = scm_cons (//scm_cons (scm_makfrom0str (ps_name.to_str0 ()),
+                       scm_makfrom0str (filename.to_str0 ()),
+                       subfonts_);
+}
 
+void
+Pango_font::derived_mark () const
+{
+  scm_gc_mark (subfonts_);
+}
 Stencil
 Pango_font::text_stencil (String str) const
 {
@@ -154,15 +67,14 @@ Pango_font::text_stencil (String str) const
   const int GLYPH_NAME_LEN = 256;
   char glyph_name[GLYPH_NAME_LEN];
   
-  Box dest_extent;
-  dest_extent.set_empty ();
   GList * ptr = items;
-  SCM glyph_exprs = SCM_EOL;
+  Stencil dest;  
   while (ptr)
     {
       PangoItem *item = (PangoItem*) ptr->data;
       PangoAnalysis *pa = &(item->analysis);
       PangoGlyphString *pgs = pango_glyph_string_new();
+
       pango_shape (str.to_str0 (), str.length (), pa, pgs);
 
       PangoRectangle logical_rect;
@@ -178,8 +90,9 @@ Pango_font::text_stencil (String str) const
       b.translate (Offset (- logical_rect.x, -logical_rect.y));
       
       b.scale (scale_);
-      dest_extent.unite (b);
-      
+
+      SCM glyph_exprs = SCM_EOL;
+      SCM *tail = &glyph_exprs;
       for (int i = 0; i < pgs->num_glyphs; i++)
        {
          PangoGlyphInfo *pgi = pgs->glyphs + i;
@@ -188,19 +101,53 @@ Pango_font::text_stencil (String str) const
          PangoGlyphGeometry ggeo = pgi->geometry;
          
          FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN);
-         glyph_exprs = scm_cons (scm_list_5 (ly_symbol2scm ("named-ps-glyph"),
-                                             scm_from_int (ggeo.x_offset),
-                                             scm_from_int (ggeo.y_offset),
-                                             scm_makfrom0str (glyph_name),
-                                             scm_makfrom0str (FT_Get_Postscript_Name (ftface))),
-                                 glyph_exprs);
+         *tail = scm_cons (scm_list_3 (scm_from_double (ggeo.x_offset * scale_),
+                                       scm_from_double (ggeo.y_offset * scale_),
+                                       scm_makfrom0str (glyph_name)),
+                           SCM_EOL);
+         tail = SCM_CDRLOC(*tail);
        }
 
+      FcPattern *fcpat = fcfont->font_pattern;
+      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);
+      
+      SCM expr = scm_list_3 (ly_symbol2scm ("glyph-string"),
+                            scm_makfrom0str (ps_name),
+                            ly_quote_scm (glyph_exprs));
+
+      Stencil item_stencil (b, expr);
+
+      dest.add_stencil (item_stencil);
+      
+      pango_fc_font_unlock_face (fcfont);
       ptr = ptr->next;      
     }
 
-  Stencil dest (dest_extent,
-               scm_cons (ly_symbol2scm ("combine-stencil"),
-                         glyph_exprs));
   return dest;
 }
+
+SCM
+Pango_font::sub_fonts () const
+{
+  return subfonts_;
+}
+
+SCM 
+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
diff --git a/lily/pango-select.cc b/lily/pango-select.cc
new file mode 100644 (file)
index 0000000..0e1aa89
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+  pango-select.cc --  implement lily font selection for Pango_fonts.
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+#include <math.h>
+
+#include "all-font-metrics.hh"
+#include "output-def.hh"
+#include "pango-font.hh"
+
+Font_metric *
+select_pango_font (Output_def *layout, SCM chain)
+{
+  SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain);
+
+  PangoFontDescription *description = 0;
+  if (scm_is_pair (name) && scm_is_string (scm_cdr (name)))
+    {
+      String name_str = ly_scm2string (scm_cdr (name));
+      description = pango_font_description_from_string (name_str.to_str0 ());
+    }
+  else
+    {
+      SCM family = ly_chain_assoc_get (ly_symbol2scm ("font-family"), chain,
+                                      SCM_BOOL_F);
+      SCM variant = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain,
+                                       SCM_BOOL_F);
+       
+      SCM style = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain,
+                                     SCM_BOOL_F);
+      SCM weight = ly_chain_assoc_get (ly_symbol2scm ("font-series"), chain,
+                                      SCM_BOOL_F);
+      
+      Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0);
+      Real size = layout->get_dimension (ly_symbol2scm ("text-font-size"))
+       * pow (2.0, step / 6.0);
+
+      description
+       = symbols_to_pango_font_description (family, style, variant, weight,
+                                            SCM_BOOL_F,
+                                            size);
+    }
+
+  Font_metric * fm = all_fonts_global->find_pango_font (description);
+
+  /*
+    Klutz the pango font into font table, otherwise it doesn't show up
+    in the output.
+   */
+  SCM font_table = get_font_table (layout);
+  SCM sizes = scm_hashq_ref (font_table, fm->self_scm (), SCM_BOOL_F);
+  if (sizes != SCM_BOOL_F)
+    {
+      SCM met = scm_assoc (scm_make_real (1.0), sizes);
+      if (scm_is_pair (met))
+       return unsmob_metrics (scm_cdr (met));
+    }
+  else
+    sizes = SCM_EOL;
+
+  sizes = scm_acons (scm_make_real (1.0), fm->self_scm(), sizes);
+  scm_hashq_set_x (font_table, fm->self_scm (), sizes);
+  
+  return fm;
+}
+
+
+PangoStyle
+symbol_to_pango_style (SCM style)
+{
+  PangoStyle pstyle = PANGO_STYLE_NORMAL;
+  if (style == ly_symbol2scm ("italic"))
+    {
+      pstyle = PANGO_STYLE_NORMAL;
+    }
+  else if (style == ly_symbol2scm ("oblique")
+          || style == ly_symbol2scm ("slanted")
+          )
+    {
+      pstyle = PANGO_STYLE_OBLIQUE;
+    }
+
+  return pstyle;
+}
+
+PangoVariant
+symbol_to_pango_variant (SCM variant)
+{
+  PangoVariant pvariant;
+  if (variant == ly_symbol2scm ("caps"))
+    {
+      pvariant = PANGO_VARIANT_SMALL_CAPS;
+    }
+  return pvariant;
+}
+
+
+PangoWeight
+symbol_to_pango_weight (SCM weight)
+{
+  PangoWeight pw = PANGO_WEIGHT_NORMAL;
+  if (weight == ly_symbol2scm ("bold"))
+    {
+      pw = PANGO_WEIGHT_BOLD;
+    }
+  if (weight == ly_symbol2scm ("heavy"))
+    {
+      pw = PANGO_WEIGHT_HEAVY;
+    }
+  if (weight == ly_symbol2scm ("ultrabold"))
+    {
+      pw = PANGO_WEIGHT_ULTRABOLD;
+    }
+  if (weight == ly_symbol2scm ("light"))
+    {
+      pw = PANGO_WEIGHT_LIGHT;
+    }
+  if (weight == ly_symbol2scm ("ultralight"))
+    {
+      pw = PANGO_WEIGHT_ULTRALIGHT;
+    }
+
+  return pw;
+}
+
+PangoStretch
+symbol_to_pango_stretch (SCM) //  stretch)
+{
+  PangoStretch ps = PANGO_STRETCH_NORMAL;
+
+  /*
+    // TODO
+    
+  PANGO_STRETCH_ULTRA_CONDENSED,
+  PANGO_STRETCH_EXTRA_CONDENSED,
+  PANGO_STRETCH_CONDENSED,
+  PANGO_STRETCH_SEMI_CONDENSED,
+  
+  PANGO_STRETCH_SEMI_EXPANDED,
+  PANGO_STRETCH_EXPANDED,
+  PANGO_STRETCH_EXTRA_EXPANDED,
+  PANGO_STRETCH_ULTRA_EXPANDED
+  */ 
+  return ps;
+}
+
+
+
+PangoFontDescription* 
+symbols_to_pango_font_description(SCM family,
+                                 SCM style,
+                                 SCM variant,
+                                 SCM weight,
+                                 SCM stretch,
+                                 Real size)
+{
+  PangoFontDescription * description = pango_font_description_new ();
+
+  String family_str = scm_is_symbol (family)
+    ? ly_symbol2string (family)
+    : String("roman");
+  pango_font_description_set_family (description,
+                                    family_str.to_str0 ());
+  pango_font_description_set_style (description,
+                                   symbol_to_pango_style (style));
+  pango_font_description_set_variant (description,
+                                     symbol_to_pango_variant (variant));
+  pango_font_description_set_weight (description,
+                                    symbol_to_pango_weight (weight));
+  pango_font_description_set_stretch (description,
+                                     symbol_to_pango_stretch (stretch));
+  pango_font_description_set_size (description,
+                                  gint (size * PANGO_SCALE));
+
+  return description;
+}
index 84ef5f298db1ace1ebcf96c41220aa6a2bf949a8..bfe6e5c13bdfc7d629a8da890f01b661db4d8255 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,6 +18,21 @@ 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,
@@ -27,14 +43,9 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real 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)
     {
@@ -92,7 +103,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);
            }
        }
index 505b2ec7cd66448c88ef66e422daa66002706843..7203d7b8e049d0b0b4a5eb286e57ce652a14250b 100644 (file)
@@ -11,6 +11,9 @@
 
 #include <math.h>
 
+#include "main.hh" 
+#include "config.hh"
+#include "pango-font.hh"
 #include "warn.hh"
 #include "grob.hh"
 #include "font-interface.hh"
@@ -18,6 +21,7 @@
 #include "modified-font-metric.hh"
 #include "ly-module.hh"
 
+
 MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 4)
 SCM
 Text_interface::interpret_string (SCM layout_smob,
@@ -32,12 +36,17 @@ Text_interface::interpret_string (SCM layout_smob,
 
   String str = ly_scm2string (markup);
 
-#if 0
+#if HAVE_PANGO_FT2
+  if (output_format_global != "tex")
+    {
+      Font_metric *fm = select_pango_font (layout, props);
+      return fm->text_stencil (str).smobbed_copy ();
+    }
+#endif
+  
   SCM_ASSERT_TYPE (input_encoding == SCM_EOL || scm_is_symbol (input_encoding),
                   input_encoding, SCM_ARG2, __FUNCTION__, "symbol");
-  
 
-  String str = ly_scm2string (markup);
   if (!scm_is_symbol (input_encoding))
     {
       SCM enc = layout->lookup_variable (ly_symbol2scm ("inputencoding"));
@@ -49,33 +58,9 @@ Text_interface::interpret_string (SCM layout_smob,
   
   Font_metric *fm = select_encoded_font (layout, props, input_encoding);
 
-  SCM lst = SCM_EOL;      
-  Box b;
-  if (Modified_font_metric* mf = dynamic_cast<Modified_font_metric*> (fm))
-    {
-      lst = scm_list_3 (ly_symbol2scm ("text"),
-                       mf->self_scm (),
-                       markup);
-       
-      b = mf->text_dimension (str);
-    }
-  else
-    {
-      /* ARGH. */
-      programming_error ("Must have Modified_font_metric for text.");
-      scm_display (fm->description_, scm_current_error_port ());
-    }
-      
-  return Stencil (b, lst).smobbed_copy ();
-#else
-  
-  
-  Font_metric *fm = select_encoded_font (layout, props, input_encoding);
-  return fm->text_stencil (str).smobbed_copy (); 
-#endif
+  return fm->text_stencil (str).smobbed_copy();
 }
 
-
 MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3)
 SCM
 Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup)
index f4897127c964af090db4603d2d5cdd38ac0927cf..542513c4e2a5bb0501403f636f810543c8af6e50 100644 (file)
@@ -85,6 +85,6 @@ staff-line-thickness setlinewidth
 
 staff-height init-paper
  
-
+pstack
 
 % end lilyponddefs.ps
index ade34dcba03460f019c895c9554b87bdd34bae23..4bab9cb734b8f4d5a478bb79e7829ba1e8db2102 100644 (file)
 
 (define-public (ps-font-command font . override-coding)
   (let* ((name (ly:font-file-name font))
-        (magnify (ly:font-magnification font))
-        (coding-alist (ly:font-encoding-alist font))
-        (input-encoding (assoc-get 'input-name coding-alist))
-        (font-encoding (assoc-get 'output-name coding-alist))
-        (coding-command (if (null? override-coding)
-                            (if (equal? input-encoding font-encoding)
-                                #f font-encoding)
-                            (car override-coding))))
+        (magnify (ly:font-magnification font)))
 
     (string-append
      "magfont" (string-encode-integer (hashq  name 1000000))
      "m" (string-encode-integer (inexact->exact (round (* 1000 magnify))))
-     (if (not coding-command) "" (string-append "e" coding-command)))))
+     )))
 
 (define (tex-font? fontname)
   (or
@@ -67,7 +60,7 @@
     font-set-name font-set-name version (string-length binary-data)
     )
     binary-data
-   "%%EndData
+   "\n%%EndData
 %%EndResource
 %%EOF
 "
 
 (define (load-fonts paper)
   (let* ((fonts (ly:paper-fonts paper))
-        (font-names (uniq-list (sort (map ly:font-file-name fonts) string<?)))
+        (all-font-names
+          (map
+                    (lambda (font)
+                      (if (string? (ly:font-file-name font))
+                          (list (ly:font-file-name font))
+                          (ly:font-sub-fonts font)))
+
+                    fonts))
+        (font-names
+         (uniq-list
+          (sort (apply append all-font-names) string<?)))
         (pfas (map
                (lambda (x)
-                 (let* ((cffname (string-append x ".cff"))
+                 (let* ((bare-file-name (ly:find-file x))
+                        (cffname (string-append x ".cff"))
                         (aname (string-append x ".pfa"))
                         (bname (string-append x ".pfb"))
                         (cff-file-name (ly:find-file cffname))
                         (a-file-name (ly:kpathsea-find-file aname))
                         (b-file-name (ly:kpathsea-find-file bname)))
                    (cond
+                    (bare-file-name (if (string-match "\\.pfb" bare-file-name)
+                                        (ly:pfb->pfa bare-file-name)
+                                        (ly:gulp-file bare-file-name)))
                     (cff-file-name (ps-embed-cff (ly:gulp-file cff-file-name) x 0))
                     (a-file-name (ly:gulp-file a-file-name))
                     (b-file-name (ly:pfb->pfa b-file-name))
     (string-join pfas "\n")))
 
 (define (define-fonts paper)
-
+  
   (define font-list (ly:paper-fonts paper))
   (define (define-font command fontname scaling)
     (string-append
      "/" command " { /" fontname " findfont "
      (ly:number->string scaling) " output-scale div scalefont } bind def\n"))
 
-  (define (reencode-font fontname encoding scaling command)
-    (let ((coding-vector (get-coding-command encoding)))
-      (string-append
-       "/" fontname " findfont " coding-vector " /" command " reencode-font\n"
-       "/" command "{ /" command " findfont " (ly:number->string scaling) " output-scale div scalefont } bind def\n")))
-
   (define (standard-tex-font? x)
     (or (equal? (substring x 0 2) "ms")
        (equal? (substring x 0 2) "cm")))
           (fontname (if specced-font-name
                         specced-font-name
                         (ly:font-file-name font)))
-       
-          (coding-alist (ly:font-encoding-alist font))
-          (input-encoding (assoc-get 'input-name coding-alist))
-          (font-encoding (assoc-get 'output-name coding-alist))
           (command (ps-font-command font))
+          
           ;; FIXME -- see (ps-font-command )
           (plain (ps-font-command font #f))
           (designsize (ly:font-design-size font))
           (ops (ly:output-def-lookup paper 'outputscale))
           (scaling (* ops magnification designsize)))
 
+      
       ;; Bluesky pfbs have UPCASE names (sigh.)
       ;;
       (if (standard-tex-font? fontname)
          (set! fontname (string-upcase fontname)))
       
-      ;; debugging: [output]encoding is broken
-      ;; found so far: coding-alist is empty!
-      (pdebug "font: ~S\n" font)
-      (pdebug "fontname: ~S\n" fontname)
-      (pdebug "input-encoding:~S\n" input-encoding)
-      (pdebug "font-encoding:~S\n" font-encoding)
-
-      (pdebug "coding-alist:~S\n" coding-alist)
       
-      (string-append
-       (define-font plain fontname scaling)
-       (if (equal? input-encoding font-encoding)
-          ""
-          (reencode-font fontname input-encoding scaling command)))))
-
-  (define (font-load-encoding encoding)
-    (let ((file-name (get-coding-file-name encoding)))
-      (ly:gulp-file (ly:kpathsea-find-file file-name))))
-
-  (let* ((encoding-list (map (lambda (x)
-                              (assoc-get 'input-name
-                                         (ly:font-encoding-alist x)))
-                            font-list))
-        (encodings (uniq-list (sort-list (filter string? encoding-list)
-                                         string<?))))
-
-    (pdebug "encodings:~S\n" encodings)
-    (string-append
-     (apply string-append (map font-load-encoding encodings))
-     (apply string-append
-           (map (lambda (x) (font-load-command x)) font-list)))))
+      (define-font plain fontname scaling)))
+
+  (apply string-append
+        (map (lambda (x) (font-load-command x))
+             (filter (lambda (x) (not (ly:pango-font? x)))
+                     font-list))))
 
 ;; FIXME: duplicated in other output backends
 ;; FIXME: silly interface name
index 2f585a767e4e91c2c069bcbc61ead9772b396c22..d36cb6a1d40142117e40887662f9cb1fbc83dba6 100644 (file)
 
 (define (no-origin)
   "")
+
+(define-public (glyph-string psname items)
+  (apply
+   string-append
+   (cons
+    (format " /~a findfont setfont " psname)
+    (map (lambda  (item)
+          (format " ~a ~a rmoveto /~a glyphshow "
+                  (car item)
+                  (cadr item)
+                  (caddr item)))
+        items))))
index 0f747a15649e3e68f6e8b56d8cf8ab7f1969253c..8fd0b9a2f243e7acee3b53181870cb43861b0968 100644 (file)
@@ -32,6 +32,7 @@
         
         (mm (eval 'mm m)))
 
+    (module-define! m 'text-font-size (* 12 (/ sz 20)))
     (module-define! m 'outputscale ss)
     (module-define! m 'fonts (make-cmr-tree (/  sz (* 20 pt))))
     (module-define! m 'staffheight sz)