LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-#define PANGO_ENABLE_BACKEND // ugh, why necessary?
+// Necessary for supporting pango_context_new() and
+// pango_context_set_font_map() in Pango < 1.22
+#define PANGO_ENABLE_BACKEND
+
-Pango_font::Pango_font (PangoFT2FontMap * /* fontmap */,
- PangoFontDescription const *description,
- Real output_scale)
+Pango_font::Pango_font (PangoFT2FontMap *fontmap,
+ PangoFontDescription const *description,
+ Real output_scale)
pango_description_ = pango_font_description_copy (description);
attribute_list_ = pango_attr_list_new ();
pango_description_ = pango_font_description_copy (description);
attribute_list_ = pango_attr_list_new ();
// ugh. Should make this configurable.
pango_context_set_language (context_, pango_language_from_string ("en_US"));
// ugh. Should make this configurable.
pango_context_set_language (context_, pango_language_from_string ("en_US"));
- ly_string2scm (ps_name),
- scm_list_2 (ly_string2scm (filename),
- scm_from_int (face_index)));
+ ly_string2scm (ps_name),
+ scm_list_2 (ly_string2scm (filename),
+ scm_from_int (face_index)));
{
sprintf (s, "glyphIndex%lX", code);
}
void
get_unicode_name (char *s,
{
sprintf (s, "glyphIndex%lX", code);
}
void
get_unicode_name (char *s,
PangoRectangle ink_rect;
pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect);
PangoRectangle ink_rect;
pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect);
- PANGO_RBEARING (logical_rect)),
- Interval (-PANGO_DESCENT (*which_rect),
- PANGO_ASCENT (*which_rect)));
+ PANGO_RBEARING (logical_rect)),
+ Interval (-PANGO_DESCENT (ink_rect),
+ PANGO_ASCENT (ink_rect)));
+
Index_to_charcode_map const *cmap = 0;
bool has_glyph_names = ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES;
if (!has_glyph_names)
Index_to_charcode_map const *cmap = 0;
bool has_glyph_names = ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES;
if (!has_glyph_names)
- cmap = all_fonts_global->get_index_to_charcode_map (
- file_name, face_index, ftface);
+ cmap = all_fonts_global->get_index_to_charcode_map (file_name, face_index, ftface);
- Zero-width characters are valid Unicode characters,
- but glyph lookups need to be skipped.
+ Zero-width characters are valid Unicode characters,
+ but glyph lookups need to be skipped.
- {
- int errorcode = FT_Get_Glyph_Name (ftface, pg, glyph_name,
- GLYPH_NAME_LEN);
- if (errorcode)
- programming_error (
- _f ("FT_Get_Glyph_Name () error: %s",
- freetype_error_string (errorcode).c_str ()));
- }
+ {
+ FT_Error errorcode = FT_Get_Glyph_Name (ftface, pg, glyph_name,
+ GLYPH_NAME_LEN);
+ if (errorcode)
+ programming_error (_f ("FT_Get_Glyph_Name () error: %s",
+ freetype_error_string (errorcode).c_str ()));
+ }
- && cmap
- && is_ttf
- && cmap->find (pg) != cmap->end ())
- {
- FT_ULong char_code = cmap->find (pg)->second;
- get_unicode_name (glyph_name, char_code);
- }
+ && cmap
+ && is_ttf
+ && cmap->find (pg) != cmap->end ())
+ {
+ FT_ULong char_code = cmap->find (pg)->second;
+ get_unicode_name (glyph_name, char_code);
+ }
- {
- programming_error (
- _f ("Glyph has no name, but font supports glyph naming.\n"
- "Skipping glyph U+%0X, file %s",
- pg, file_name.c_str ()));
- continue;
- }
+ {
+ programming_error (_f ("Glyph has no name, but font supports glyph naming.\n"
+ "Skipping glyph U+%0X, file %s",
+ pg, file_name.c_str ()));
+ continue;
+ }
- // Access by glyph index directly.
- get_glyph_index_name (glyph_name, pg);
+ // Access by glyph index directly.
+ get_glyph_index_name (glyph_name, pg);
- scm_from_double (ggeo.x_offset * scale_),
- scm_from_double (ggeo.y_offset * scale_),
- char_id),
- SCM_EOL);
+ scm_from_double (ggeo.x_offset * scale_),
+ scm_from_double (- ggeo.y_offset * scale_),
+ char_id),
+ SCM_EOL);
pango_glyph_string_free (pgs);
pgs = 0;
PangoFontDescription *descr = pango_font_describe (pa->font);
Real size = pango_font_description_get_size (descr)
pango_glyph_string_free (pgs);
pgs = 0;
PangoFontDescription *descr = pango_font_describe (pa->font);
Real size = pango_font_description_get_size (descr)
name = name.substr (0, idx);
ssize slash_idx = name.rfind ('/');
if (slash_idx != NPOS)
name = name.substr (0, idx);
ssize slash_idx = name.rfind ('/');
if (slash_idx != NPOS)
- {
- slash_idx ++;
- name = name.substr (slash_idx,
- name.length () - slash_idx);
- }
+ {
+ slash_idx++;
+ name = name.substr (slash_idx,
+ name.length () - slash_idx);
+ }
string initial = name.substr (0, 1);
initial = String_convert::to_upper (initial);
string initial = name.substr (0, 1);
initial = String_convert::to_upper (initial);
pango_fc_font_unlock_face (fcfont);
SCM expr = scm_list_5 (ly_symbol2scm ("glyph-string"),
pango_fc_font_unlock_face (fcfont);
SCM expr = scm_list_5 (ly_symbol2scm ("glyph-string"),
- ly_string2scm (ps_name),
- scm_from_double (size),
- scm_from_bool (cid_keyed),
- ly_quote_scm (glyph_exprs));
+ ly_string2scm (ps_name),
+ scm_from_double (size),
+ scm_from_bool (cid_keyed),
+ ly_quote_scm (glyph_exprs));
-Stencil
-Pango_font::word_stencil (string str, bool feta) const
-{
- return text_stencil (str, feta, true);
-}
+extern bool music_strings_to_paths;
-Pango_font::text_stencil (string str, bool feta) const
-{
- return text_stencil (str, feta, false);
-}
-
-Stencil
-Pango_font::text_stencil (string str,
- bool feta,
- bool tight) const
+Pango_font::text_stencil (Output_def * /* state */,
+ string str, bool music_string) const
- {
- PangoGlyphItem *item = (PangoGlyphItem *) p->data;
- Stencil item_stencil = pango_item_string_stencil (item, tight);
+ {
+ PangoGlyphItem *item = (PangoGlyphItem *) p->data;
+ Stencil item_stencil = pango_item_string_stencil (item);
- item_stencil.translate_axis (last_x, X_AXIS);
- last_x = item_stencil.extent (X_AXIS)[RIGHT];
+ item_stencil.translate_axis (last_x, X_AXIS);
+ last_x = item_stencil.extent (X_AXIS)[RIGHT];
- if (!item_stencil.extent_box ()[X_AXIS].is_empty ())
- {
- Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1);
- Box empty;
- empty.set_empty ();
- Stencil dimless_frame (empty, frame.expr ());
- dest.add_stencil (frame);
- }
+ if (!item_stencil.extent_box ()[X_AXIS].is_empty ())
+ {
+ Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1);
+ Box empty;
+ empty.set_empty ();
+ Stencil dimless_frame (empty, frame.expr ());
+ dest.add_stencil (frame);
+ }
- has_utf8_string should only be true when utf8_string is a
- variable that is bound to a *named* procedure.
+ has_utf8_string should only be true when utf8_string is a
+ variable that is bound to a *named* procedure, i.e. not a
+ lambda expression.
- TODO: use a program option (-dmusic-strings-to-paths) here
- instead that is enabled only when -dbackend=svg.
+ /*
+ Backends with the utf-8-string expression use it when
+ 1) the -dmusic-strings-to-paths option is set
+ and `str' is not a music string, or
+ 2) the -dmusic-strings-to-paths option is not set.
{
// For Pango based backends, we take a shortcut.
SCM exp = scm_list_3 (ly_symbol2scm ("utf-8-string"),
{
// For Pango based backends, we take a shortcut.
SCM exp = scm_list_3 (ly_symbol2scm ("utf-8-string"),
Box b (Interval (0, 0), Interval (0, 0));
b.unite (dest.extent_box ());
Box b (Interval (0, 0), Interval (0, 0));
b.unite (dest.extent_box ());