]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/paper.scm (layout-set-staff-size): use text-font-size in
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 29 Dec 2004 23:46:05 +0000 (23:46 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 29 Dec 2004 23:46:05 +0000 (23:46 +0000)
dimension less points (ie. 12 = 12 point)

* lily/pango-select.cc (select_pango_font): use find_scaled_font().

* lily/all-font-metrics.cc (find_pango_font): set description_

* lily/pango-font.cc (text_stencil): export size as well.
(text_stencil): fix scaling and extents box.

ChangeLog
lily/all-font-metrics.cc
lily/include/dimensions.hh
lily/include/pango-font.hh
lily/pango-font.cc
lily/pango-select.cc
ly/property-init.ly
scm/output-ps.scm
scm/paper.scm

index dcebb017337ae60ca6b1579ecbaed26d29f8408e..889635c3e9652dc299b5fe4ccdfd9bf65832afa7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-12-30  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * scm/paper.scm (layout-set-staff-size): use text-font-size in
+       dimension less points (ie. 12 = 12 point)
+
+       * lily/pango-select.cc (select_pango_font): use find_scaled_font().
+
+       * lily/all-font-metrics.cc (find_pango_font): set description_
+
+       * lily/pango-font.cc (text_stencil): export size as well.
+       (text_stencil): fix scaling and extents box.
+
 2004-12-29  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * Documentation/topdocs/NEWS.texi (Top): add -f texstr
index c681c03c9db431dc399323625475f0a20bd65198..5425542816d4104014d12565ee21b464dfc9260d 100644 (file)
@@ -26,7 +26,7 @@ All_font_metrics::All_font_metrics (String path)
   otf_dict_ = new Scheme_hash_table;
 
 #if HAVE_PANGO_FT2
-  PangoFontMap*pfm =     pango_ft2_font_map_new ();
+  PangoFontMap*pfm = pango_ft2_font_map_new ();
 
   pango_ft2_fontmap_ =
     G_TYPE_CHECK_INSTANCE_CAST(pfm,
@@ -47,6 +47,11 @@ All_font_metrics::~All_font_metrics ()
   scm_gc_unprotect_object (afm_dict_->self_scm ());
   scm_gc_unprotect_object (tfm_dict_->self_scm ());
   scm_gc_unprotect_object (otf_dict_->self_scm ());
+
+#if HAVE_PANGO_FT2
+  scm_gc_unprotect_object (pango_dict_->self_scm ());
+  g_object_unref (pango_ft2_fontmap_);
+#endif
 }
 
 All_font_metrics::All_font_metrics (All_font_metrics const&)
@@ -66,7 +71,6 @@ All_font_metrics::find_pango_font (PangoFontDescription*description)
       if (verbose_global_b)
        progress_indication ("[" + String (fn));
       Pango_font *pf = new Pango_font (pango_ft2_fontmap_,
-                                      pango_dpi_,
                                       RIGHT,
                                       description);
       val = pf->self_scm ();
@@ -75,6 +79,9 @@ All_font_metrics::find_pango_font (PangoFontDescription*description)
 
       if (verbose_global_b)
        progress_indication ("]");
+
+      pf->description_ = scm_cons (SCM_BOOL_F,
+                                  scm_make_real (1.0));
     }
   g_free (fn); 
   return dynamic_cast<Pango_font*> (unsmob_metrics (val));
index e50c40f46b4a79f9fc370e0123481d05c38a5a75..bc93a975ae590015457352db62bb3f9bd9ba450c 100644 (file)
@@ -40,6 +40,10 @@ const Real PT_TO_MM = (1.0 / MM_TO_PT);
 
 String print_dimen (Real);
 const Real point_constant = 1 PT;
+const Real inch_constant = 1 INCH;
+const Real cm_constant = 1 CM;
+const Real mm_constant = 1 MM;
+const Real bigpoint_constant = 1 BIGPOINT;
 
 #endif /* DIMENSIONS_HH */
 
index 13038a6ee5b489a35da08cfddec0d79e26b8c940..36aa04c391a95a1127b29970e355c680d6945726 100644 (file)
 
 class Pango_font : public Font_metric
 {
-  /** handle to face object */
-  FT_Face face_;
   PangoContext *context_;
   PangoAttrList *attribute_list_;
   Real scale_;
   SCM subfonts_;
-  Index_to_charcode_map index_to_charcode_map_;
-
 public:
   Pango_font (PangoFT2FontMap *,
-             int dpi, 
              Direction leftright,
              PangoFontDescription *);
   ~Pango_font ();
@@ -42,8 +37,6 @@ public:
 
   virtual SCM sub_fonts () const;
   virtual void derived_mark () const;
-  virtual int name_to_index (String) const;
-  virtual unsigned index_to_charcode (int) const;
 };
 
 PangoFontDescription *
@@ -57,7 +50,8 @@ symbols_to_pango_font_description (SCM family,
 Font_metric *
 select_pango_font (Output_def *layout, SCM chain);
 
-#endif /* HAVE_PANGO16 */
+const int PANGO_DPI = 1200;
 
+#endif /* HAVE_PANGO16 */
 #endif /* PANGO_FONT_HH */
 
index 4e9dfd8061c0364273699a2f6439e12ac716835a..dd93df8d6abbdda8a2c3c268dddbdb69d65a49b0 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <pango/pangoft2.h>
 
+#include "dimensions.hh"
 #include "pango-font.hh"
 
 #if HAVE_PANGO_FT2
@@ -19,7 +20,6 @@
 
 
 Pango_font::Pango_font (PangoFT2FontMap *fontmap,
-                       int resolution,
                        Direction dir,
                        PangoFontDescription *description)
 {
@@ -27,9 +27,11 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap,
   PangoDirection pango_dir = (dir == RIGHT)
     ? PANGO_DIRECTION_LTR
     : PANGO_DIRECTION_RTL;
-  context_ = pango_ft2_font_map_create_context (fontmap);  
+  context_ =
+    pango_ft2_get_context (PANGO_DPI, PANGO_DPI);
+  //  context_ = pango_ft2_font_map_create_context (fontmap);  
   attribute_list_= pango_attr_list_new();
-  scale_ = 1.0 / (PANGO_SCALE * resolution * 72.27);
+  scale_ = inch_constant / (Real (PANGO_SCALE) * Real (PANGO_DPI));
   
   pango_context_set_language (context_, pango_language_from_string ("en_US"));
   pango_context_set_base_dir (context_, pango_dir);
@@ -45,8 +47,7 @@ Pango_font::~Pango_font ()
 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_ = scm_cons (scm_makfrom0str (filename.to_str0 ()),
                        subfonts_);
 }
 
@@ -77,30 +78,23 @@ Pango_font::text_stencil (String str) const
       PangoAnalysis *pa = &(item->analysis);
       PangoGlyphString *pgs = pango_glyph_string_new ();
 
-      pango_shape (str.to_str0 (), str.length (), pa, pgs);
+      pango_shape (str.to_str0 () + item->offset,
+                  item->length, pa, pgs);
 
       PangoRectangle logical_rect;
-      pango_glyph_string_extents (pgs, pa->font, NULL, &logical_rect);
+      PangoRectangle ink_rect;
+      pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect);
       
       PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST(pa->font,
                                                       PANGO_TYPE_FC_FONT,
                                                       PangoFcFont);
-      FT_Face ftface = pango_fc_font_lock_face (fcfont);
-      Box b (Interval (0, logical_rect.width),
-            Interval (0, logical_rect.height));
-
-      if (!face_)
-       {
-         /* FIXME.  This obvious shortcut apparently does not work.
-            It seems there are different faces per text string and a
-            map of face_ and charcode mapping is needed.  */
-         Pango_font *barf = (Pango_font*) this;
-         barf->face_ = ftface;
-         barf->index_to_charcode_map_ = make_index_to_charcode_map (face_);
-       }
-
-      b.translate (Offset (- logical_rect.x, -logical_rect.y));
       
+      FT_Face ftface = pango_fc_font_lock_face (fcfont);
+      Box b (Interval (PANGO_LBEARING(logical_rect),
+                      PANGO_RBEARING(logical_rect)),
+            Interval (-PANGO_DESCENT(logical_rect),
+                      PANGO_ASCENT(logical_rect)));
+            
       b.scale (scale_);
 
       SCM glyph_exprs = SCM_EOL;
@@ -111,7 +105,7 @@ Pango_font::text_stencil (String str) const
          
          PangoGlyph pg = pgi->glyph;
          PangoGlyphGeometry ggeo = pgi->geometry;
-         
+
          FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN);
          *tail = scm_cons (scm_list_3 (scm_from_double (ggeo.x_offset * scale_),
                                        scm_from_double (ggeo.y_offset * scale_),
@@ -119,7 +113,10 @@ Pango_font::text_stencil (String str) const
                            SCM_EOL);
          tail = SCM_CDRLOC (*tail);
        }
-
+      PangoFontDescription *descr = pango_font_describe (pa->font);
+      Real size = pango_font_description_get_size (descr)
+        /  (Real (PANGO_SCALE)) ;
+      
       FcPattern *fcpat = fcfont->font_pattern;
       char *filename = 0;
       FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &filename);
@@ -127,8 +124,8 @@ Pango_font::text_stencil (String str) const
       ((Pango_font *) this)->register_font_file (filename, ps_name);
       
       SCM expr = scm_list_4 (ly_symbol2scm ("glyph-string"),
-                            self_scm (),
                             scm_makfrom0str (ps_name),
+                            scm_from_double (size),
                             ly_quote_scm (glyph_exprs));
 
       Stencil item_stencil (b, expr);
@@ -154,21 +151,6 @@ Pango_font::font_file_name () const
   return SCM_BOOL_F;
 }
 
-int
-Pango_font::name_to_index (String nm) const
-{
-  char *nm_str = (char*) nm.to_str0 ();
-  if (int idx = FT_Get_Name_Index (face_, nm_str))
-    return idx;
-  return -1;
-}
-
-unsigned
-Pango_font::index_to_charcode (int i) const
-{
-  return ((Pango_font*) this)->index_to_charcode_map_[i];
-}
-
 LY_DEFINE (ly_pango_font_p, "ly:pango-font?",
           1, 0, 0,
           (SCM f),
index 0e1aa8929cea30fa74a9d3fc4babddeb2c05fd9f..71553a1a9164c70558419722701d5313d4e089a5 100644 (file)
@@ -22,6 +22,13 @@ select_pango_font (Output_def *layout, SCM chain)
     {
       String name_str = ly_scm2string (scm_cdr (name));
       description = pango_font_description_from_string (name_str.to_str0 ());
+      
+      
+      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);
+      pango_font_description_set_size (description,
+                                      gint (size * PANGO_SCALE));
     }
   else
     {
@@ -47,25 +54,9 @@ select_pango_font (Output_def *layout, SCM chain)
 
   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;
+  return find_scaled_font (layout, fm, 1.0,
+                          ly_symbol2scm ("latin1"),
+                          ly_symbol2scm ("latin1")); 
 }
 
 
index f8fc46ef4e0135538b9ee8dbfc789642e65e275d..8103849c651182dbb38f6d082dcae74efd01dcc8 100644 (file)
@@ -135,7 +135,7 @@ arpeggioBracket = \sequential {
 
 glissando = #(make-music 'GlissandoEvent)
 
-fermataMarkup = \markup { \musicglyph #"scripts-ufermata" } 
+fermataMarkup = \markup { \musicglyph #"scripts.ufermata" } 
 
 hideNotes =\sequential {
   % hide notes, accidentals, etc.
index 6899b747807313b59b3cd07de24952db04629977..de24d380638f707fe917321717beb4e2a7d81fa5 100644 (file)
   (string-append (ly:numbers->string (list breapth width depth height))
                 " draw_box"))
 
-(define (glyph-string font postscript-font-name x-y-named-glyphs)
+
+(define (glyph-string
+        postscript-font-name
+        size
+        x-y-named-glyphs)
   (apply
    string-append
    (cons
-    (format #f " /~a findfont setfont " postscript-font-name)
+    (format #f " /~a findfont ~a output-scale div scalefont setfont " postscript-font-name size)
     (map (lambda  (item)
           (format #f " ~a ~a rmoveto /~a glyphshow "
                   (car item)
index 8fd0b9a2f243e7acee3b53181870cb43861b0968..3f997b08852d55b59500fd8aac83e8a3385ce3c6 100644 (file)
@@ -32,7 +32,8 @@
         
         (mm (eval 'mm m)))
 
-    (module-define! m 'text-font-size (* 12 (/ sz 20)))
+    (module-define! m 'text-font-size (* 12 (/ sz (* 20 pt))))
+    
     (module-define! m 'outputscale ss)
     (module-define! m 'fonts (make-cmr-tree (/  sz (* 20 pt))))
     (module-define! m 'staffheight sz)