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.
--- /dev/null
+\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" }
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",
return SCM_EOL;
}
+Stencil
+Font_metric::word_stencil (string str) const
+{
+ return text_stencil (str);
+}
+
Stencil
Font_metric::text_stencil (string str) const
{
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;
{
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);
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;
};
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];
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)));
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_,
{
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)
{
}
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;
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_;
#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
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);