]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/pango-font.cc (text_stencil): allow 'tight' bounds.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 3 Oct 2006 12:29:54 +0000 (12:29 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 3 Oct 2006 12:29:54 +0000 (12:29 +0000)
(pango_item_string_stencil): use logical rect horizontally (to
preserve spaces), ink_rect vertically (for time signatures).

* lily/font-metric.cc (word_stencil): new interface function

* input/regression/utf-8-mixed-text.ly: new file.

* lily/percent-repeat-engraver.cc (listen_percent): remove
spurious warning.

* lily/phrasing-slur-engraver.cc (acknowledge_script): only ack
non-dynamic scripts. Fixes #30.

* lily/pango-font.cc (pango_item_string_stencil): use
logical_rect. This prevents spaces after words from disappearing,
issue #72.

12 files changed:
ChangeLog
input/regression/utf-8-mixed-text.ly [new file with mode: 0644]
lily/font-metric-scheme.cc
lily/font-metric.cc
lily/include/font-metric.hh
lily/include/modified-font-metric.hh
lily/include/pango-font.hh
lily/pango-font.cc
lily/percent-repeat-engraver.cc
lily/phrasing-slur-engraver.cc
lily/slur-engraver.cc
lily/text-interface.cc

index 93f026cae9752d2eacf691219d3cf23365567365..dceae7da4d3af2e30e96fce44c701fa7d5d24c31 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2006-10-03  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * lily/pango-font.cc (text_stencil): allow 'tight' bounds.
+       (pango_item_string_stencil): use logical rect horizontally (to
+       preserve spaces), ink_rect vertically (for time signatures).
+
+       * lily/font-metric.cc (word_stencil): new interface function
+
+       * input/regression/utf-8-mixed-text.ly: new file.
+
+       * lily/percent-repeat-engraver.cc (listen_percent): remove
+       spurious warning.
+
        * lily/phrasing-slur-engraver.cc (acknowledge_script): only ack
        non-dynamic scripts. Fixes #30.
 
diff --git a/input/regression/utf-8-mixed-text.ly b/input/regression/utf-8-mixed-text.ly
new file mode 100644 (file)
index 0000000..60687d4
--- /dev/null
@@ -0,0 +1,10 @@
+\header {
+  texidoc = "words in mixed font in a single string
+ are separated by spaces as in the input string.
+ Here a Russian word followed by a roman word."
+  
+}
+
+\version "2.9.20"
+
+\markup  { "Здравствуйт Hallo" }
index c39d79494a55f02ef15e9e5501fea7639aa80794..64d6f5c40026b76613d83a8dd02505243d73f036 100644 (file)
@@ -73,11 +73,8 @@ LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
   Font_metric *fm = unsmob_metrics (font);
   SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
-#if 1
+
   return scm_from_unsigned_integer (fm->index_to_charcode (fm->name_to_index (ly_scm2string (name))));
-#else
-  return scm_from_unsigned_integer (fm->glyph_name_to_charcode (ly_scm2string (name)));
-#endif
 }
 
 LY_DEFINE (ly_text_dimension, "ly:text-dimension",
index 70017df10c41ca2a20d7eeed092d5715e2a843bc..7cfb8d749ccd1628d958f9ba039102c3d58c8bbf 100644 (file)
@@ -179,6 +179,12 @@ Font_metric::sub_fonts () const
   return SCM_EOL;
 }
 
+Stencil
+Font_metric::word_stencil (string str) const
+{
+  return text_stencil (str);
+}
+
 Stencil
 Font_metric::text_stencil (string str) const
 {
index f5d036f972ea63fd6e01efa2bd053004ba40f231..4217a6e95ea14f76998f17de2803452972a0dde8 100644 (file)
@@ -22,9 +22,12 @@ public:
   SCM description_;
   string file_name_;
 
-
   virtual Stencil text_stencil (string) const;
+  virtual Stencil word_stencil (string) const;
+
+  // ugh.
   virtual Box text_dimension (string) const;
+
   virtual string font_name () const;
   virtual size_t count () const;
   virtual Offset attachment_point (string) const;
index c5e6d3c5bf4e51d9ddb588b394bd4963c74ce357..7d1487d933885f4d532f287ed66836792f19e675 100644 (file)
@@ -16,6 +16,7 @@ struct Modified_font_metric : public Font_metric
 {
 public:
   Box text_dimension (string) const;
+  Box word_dimension (string) const;
   Stencil text_stencil (string) const;
 
   static SCM make_scaled_font_metric (Font_metric *fm, Real magnification);
index 44c2bf4e5b5efc67d82b6d41393742e2b4ac4ade..9e330faeab9c7bef4bd0c6cfdaa0eaeccf6cea2b 100644 (file)
@@ -42,9 +42,12 @@ public:
   string description_string () const; 
   SCM font_file_name () const;
   void register_font_file (string, string);
-  Stencil text_stencil (string) const;
-  Stencil pango_item_string_stencil (PangoItem const *, string) const;
+  Stencil text_stencil (string, bool tight) const;
 
+  Stencil pango_item_string_stencil (PangoItem const *, string, bool tight) const;
+
+  virtual Stencil word_stencil (string) const;
+  virtual Stencil text_stencil (string) const;
   virtual void derived_mark () const;
 };
 
index 12fa4f3da8c03205c01efdc718f647d554d585d4..6c5735fec83d18df443a3a926927979e844e9911 100644 (file)
@@ -99,7 +99,8 @@ get_unicode_name (char*s, FT_ULong code)
 
 
 Stencil
-Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const
+Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
+                                      bool tight_bbox) const
 {
   const int GLYPH_NAME_LEN = 256;
   char glyph_name[GLYPH_NAME_LEN];
@@ -119,9 +120,13 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const
 
   FT_Face ftface = pango_fc_font_lock_face (fcfont);
 
-  PangoRectangle const *which_rect = &logical_rect;
-  Box b (Interval (PANGO_LBEARING (*which_rect),
-                  PANGO_RBEARING (*which_rect)),
+  PangoRectangle const *which_rect
+    = (tight_bbox)
+    ? &ink_rect
+    : &logical_rect;
+    
+  Box b (Interval (PANGO_LBEARING (logical_rect),
+                  PANGO_RBEARING (logical_rect)),
         Interval (-PANGO_DESCENT (*which_rect),
                   PANGO_ASCENT (*which_rect)));
 
@@ -265,8 +270,21 @@ Pango_font::physical_font_tab () const
   return physical_font_tab_;
 }
 
+
+Stencil
+Pango_font::word_stencil (string str) const
+{
+  return text_stencil (str, true);
+}
+  
 Stencil
 Pango_font::text_stencil (string str) const
+{
+  return text_stencil (str, false);
+}
+
+Stencil
+Pango_font::text_stencil (string str, bool tight) const
 {
   GList *items
     = pango_itemize (context_,
@@ -290,7 +308,7 @@ Pango_font::text_stencil (string str) const
     {
       PangoItem *item = (PangoItem *) ptr->data;
 
-      Stencil item_stencil = pango_item_string_stencil (item, str);
+      Stencil item_stencil = pango_item_string_stencil (item, str, tight);
 
       if (text_dir == RIGHT)
        {
index dc6ba4213fc8e983b21ce2c9f6069046bbe8450c..e76bbaeb086c017c8c7b13ac8da8477e70e029ea 100644 (file)
@@ -117,7 +117,10 @@ Percent_repeat_engraver::listen_percent (Stream_event *ev)
        }
       else
        {
-         ev->origin ()->warning (_ ("Junking percent repeat event: Duration must be exactly one or two measures"));
+         /*
+           don't warn about percent repeats: slash repeats are not
+           exactly 1 or 2 measures long.
+          */
          return;
        }
       percent_event_ = ev;
index cb0c2e20bf9aaf646da43f314a9a37299080746d..1c14503adf42ce245749a3ff1ed7dc67ecfedc03 100644 (file)
   It is possible that a slur starts and ends on the same note.  At
   least, it is for phrasing slurs: a note can be both beginning and
   ending of a phrase.
+
 */
 
+/*
+  NOTE NOTE NOTE
+
+  This is largely similar to Slur_engraver. Check if fixes apply there too.  
+
+  (on principle, engravers don't use inheritance for code sharing)
+  
+ */
 class Phrasing_slur_engraver : public Engraver
 {
   Drul_array<Stream_event *> events_;
index 2b2aafafb0ad4907ac81a93ec645ea8977b7ff3c..55080f092b5f219f664f11a3763d4964fc763f0c 100644 (file)
 
 #include "translator.icc"
 
+
+/*
+  NOTE NOTE NOTE
+
+  This is largely similar to Phrasing_slur_engraver. Check if fixes
+  apply there too.
+
+  (on principle, engravers don't use inheritance for code sharing)
+  
+ */
+
 /*
   It is possible that a slur starts and ends on the same note.  At
   least, it is for phrasing slurs: a note can be both beginning and
index 62375fbb9c72f96bca69b7c24b28d82aad23390d..c249052da58a9429d67050fc66e2496fb0848bfa 100644 (file)
@@ -35,7 +35,7 @@ Text_interface::interpret_string (SCM layout_smob,
   string str = ly_scm2string (markup);
 
   Font_metric *fm = select_encoded_font (layout, props);
-  return fm->text_stencil (str).smobbed_copy ();
+  return fm->word_stencil (str).smobbed_copy ();
 }
 
 MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3);