]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/pango-font.cc
* buildscripts/gen-emmentaler-scripts.py (outdir): capitalize
[lilypond.git] / lily / pango-font.cc
index 87e22e1b367ce3e77e6c7c6975a82b8908bfa04d..1101a8d8d50f2c8dd84377e0c0a75cabdfe5ea4b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 */
 
@@ -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;
@@ -45,7 +46,10 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap,
     --hwn
    */
   scale_ = INCH_TO_BP / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION) * output_scale);
-  
+
+  /*
+    ugh. Should make this configurable.
+  */
   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);
@@ -61,14 +65,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,19 +129,31 @@ 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);
-      
-  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);
+  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));
 
-  return item_stencil;  
+      return Stencil (b, expr);
+    }
+  else
+    {
+      warning (_ ("FreeType face has no PostScript font name."));      
+      return Stencil();
+    }
 }
 
+SCM
+Pango_font::physical_font_tab () const
+{
+  return physical_font_tab_;
+}
 
 Stencil
 Pango_font::text_stencil (String str) const
@@ -195,11 +212,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 +219,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