LY_ASSERT_SMOB (Font_metric, font, 1);
LY_ASSERT_TYPE (scm_is_string, text, 2);
- Stencil stc (fm->text_stencil (ly_scm2string (text)));
+ Stencil stc (fm->text_stencil (ly_scm2string (text), false));
return scm_cons (ly_interval2scm (stc.extent (X_AXIS)),
ly_interval2scm (stc.extent (Y_AXIS)));
}
}
Stencil
-Font_metric::word_stencil (string str) const
+Font_metric::word_stencil (string str, bool feta) const
{
- return text_stencil (str);
+ return text_stencil (str, feta);
}
Stencil
-Font_metric::text_stencil (string /* str */) const
+Font_metric::text_stencil (string, bool) const
{
- programming_error("Cannot get a text stencil from this font");
+ programming_error ("Cannot get a text stencil from this font");
return Stencil (Box (), SCM_EOL);
}
SCM description_;
string file_name_;
- virtual Stencil text_stencil (string) const;
- virtual Stencil word_stencil (string) const;
+ virtual Stencil text_stencil (string, bool) const;
+ virtual Stencil word_stencil (string, bool) const;
// ugh.
virtual Box text_dimension (string) const;
public:
Box text_dimension (string) const;
Box word_dimension (string) const;
- Stencil text_stencil (string) const;
+ Stencil text_stencil (string, bool) const;
static SCM make_scaled_font_metric (Font_metric *fm, Real magnification);
size_t count () const;
string description_string () const;
SCM font_file_name () const;
void register_font_file (string, string, int);
- Stencil text_stencil (string, bool tight) const;
+ Stencil text_stencil (string, bool, bool) const;
- Stencil pango_item_string_stencil (PangoItem const *, string, bool tight) const;
+ Stencil pango_item_string_stencil (PangoItem const *, string, bool) const;
- virtual Stencil word_stencil (string) const;
- virtual Stencil text_stencil (string) const;
+ virtual Stencil word_stencil (string, bool) const;
+ virtual Stencil text_stencil (string, bool) const;
virtual void derived_mark () const;
};
}
Stencil
-Modified_font_metric::text_stencil (string text) const
+Modified_font_metric::text_stencil (string text, bool feta) const
{
Box b;
if (Pango_font *pf = dynamic_cast<Pango_font *> (orig_))
{
- Stencil stc = pf->text_stencil (text);
+ Stencil stc = pf->text_stencil (text, feta);
Box b = stc.extent_box ();
return scaled;
}
- return Font_metric::text_stencil (text);
+ return Font_metric::text_stencil (text, feta);
}
Box
}
Stencil
-Pango_font::word_stencil (string str) const
+Pango_font::word_stencil (string str, bool feta) const
{
- return text_stencil (str, true);
+ return text_stencil (str, feta, true);
}
Stencil
-Pango_font::text_stencil (string str) const
+Pango_font::text_stencil (string str, bool feta) const
{
- return text_stencil (str, false);
+ return text_stencil (str, feta, false);
}
Stencil
Pango_font::text_stencil (string str,
+ bool feta,
bool tight) const
{
GList *items
dest.add_stencil (item_stencil);
}
- // UGH. Should have flags per output format signifying supported
- // options.
string name = get_output_backend_name ();
- if (name != "ps" && name != "eps")
+ string output_mod = "scm output-" + name;
+ SCM mod = scm_c_resolve_module (output_mod.c_str ());
+
+ bool has_utf8_string = false;
+
+ if (ly_is_module (mod))
+ {
+ SCM utf8_string = ly_module_lookup (mod, ly_symbol2scm ("utf-8-string"));
+ if (utf8_string != SCM_BOOL_F)
+ has_utf8_string = true;
+ }
+
+ /*
+ The SVG backend only uses utf-8-string for the non-music
+ fonts, hence the check here. --pmccarty
+
+ TODO: use a program option (-dmusic-strings-to-paths) here
+ instead that is enabled only when -dbackend=svg.
+ */
+ if ((name == "svg" && !feta) || (name != "svg" && has_utf8_string))
{
// For Pango based backends, we take a shortcut.
SCM exp = scm_list_3 (ly_symbol2scm ("utf-8-string"),
Font_metric *fm = select_encoded_font (layout, props);
replace_whitespace (&str);
- return fm->word_stencil (str).smobbed_copy ();
+
+ /*
+ We want to use "glyph-string" in the SVG backend for all
+ music fonts (Emmentaler and Aybabtu) that pass through the
+ text interface. Here the font encoding is checked to see if
+ it matches one of the music font encodings. --pmccarty
+ */
+ SCM encoding = ly_chain_assoc_get (ly_symbol2scm ("font-encoding"),
+ props,
+ SCM_BOOL_F);
+ SCM music_encodings = ly_lily_module_constant ("all-music-font-encodings");
+
+ if (scm_memq (encoding, music_encodings) != SCM_BOOL_F)
+ return fm->word_stencil (str, true).smobbed_copy ();
+ else
+ return fm->word_stencil (str, false).smobbed_copy ();
}
MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Text_interface, interpret_markup, 3, 0,