summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>2006-10-03 12:29:54 +0000
committerHan-Wen Nienhuys <hanwen@xs4all.nl>2006-10-03 12:29:54 +0000
commita10d5423aa39d7c687dc9d3123177c16f82d4336 (patch)
treedc7af6ff62874078eb764a93e735a220c60178c9
parentcac3c1f657606f6dee0badf461c59159f15c9340 (diff)
* 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. * lily/pango-font.cc (pango_item_string_stencil): use logical_rect. This prevents spaces after words from disappearing, issue #72.
-rw-r--r--ChangeLog11
-rw-r--r--input/regression/utf-8-mixed-text.ly10
-rw-r--r--lily/font-metric-scheme.cc5
-rw-r--r--lily/font-metric.cc6
-rw-r--r--lily/include/font-metric.hh5
-rw-r--r--lily/include/modified-font-metric.hh1
-rw-r--r--lily/include/pango-font.hh7
-rw-r--r--lily/pango-font.cc28
-rw-r--r--lily/percent-repeat-engraver.cc5
-rw-r--r--lily/phrasing-slur-engraver.cc9
-rw-r--r--lily/slur-engraver.cc11
-rw-r--r--lily/text-interface.cc2
12 files changed, 86 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 93f026cae9..dceae7da4d 100644
--- 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
index 0000000000..60687d4d81
--- /dev/null
+++ b/input/regression/utf-8-mixed-text.ly
@@ -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" }
diff --git a/lily/font-metric-scheme.cc b/lily/font-metric-scheme.cc
index c39d79494a..64d6f5c400 100644
--- a/lily/font-metric-scheme.cc
+++ b/lily/font-metric-scheme.cc
@@ -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",
diff --git a/lily/font-metric.cc b/lily/font-metric.cc
index 70017df10c..7cfb8d749c 100644
--- a/lily/font-metric.cc
+++ b/lily/font-metric.cc
@@ -180,6 +180,12 @@ Font_metric::sub_fonts () const
}
Stencil
+Font_metric::word_stencil (string str) const
+{
+ return text_stencil (str);
+}
+
+Stencil
Font_metric::text_stencil (string str) const
{
SCM lst = scm_list_3 (ly_symbol2scm ("text"),
diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh
index f5d036f972..4217a6e95e 100644
--- a/lily/include/font-metric.hh
+++ b/lily/include/font-metric.hh
@@ -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;
diff --git a/lily/include/modified-font-metric.hh b/lily/include/modified-font-metric.hh
index c5e6d3c5bf..7d1487d933 100644
--- a/lily/include/modified-font-metric.hh
+++ b/lily/include/modified-font-metric.hh
@@ -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);
diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh
index 44c2bf4e5b..9e330faeab 100644
--- a/lily/include/pango-font.hh
+++ b/lily/include/pango-font.hh
@@ -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;
};
diff --git a/lily/pango-font.cc b/lily/pango-font.cc
index 12fa4f3da8..6c5735fec8 100644
--- a/lily/pango-font.cc
+++ b/lily/pango-font.cc
@@ -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,9 +270,22 @@ 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_,
str.c_str (),
@@ -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)
{
diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc
index dc6ba4213f..e76bbaeb08 100644
--- a/lily/percent-repeat-engraver.cc
+++ b/lily/percent-repeat-engraver.cc
@@ -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;
diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc
index cb0c2e20bf..1c14503adf 100644
--- a/lily/phrasing-slur-engraver.cc
+++ b/lily/phrasing-slur-engraver.cc
@@ -23,8 +23,17 @@
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_;
diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc
index 2b2aafafb0..55080f092b 100644
--- a/lily/slur-engraver.cc
+++ b/lily/slur-engraver.cc
@@ -19,6 +19,17 @@
#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
diff --git a/lily/text-interface.cc b/lily/text-interface.cc
index 62375fbb9c..c249052da5 100644
--- a/lily/text-interface.cc
+++ b/lily/text-interface.cc
@@ -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);