From: Han-Wen Nienhuys Date: Fri, 7 Jan 2005 13:15:01 +0000 (+0000) Subject: (LY_DEFINE): new file. X-Git-Tag: release/2.5.14~301 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=477969652aa0d12bb3d9c75516515e1a140ea763;p=lilypond.git (LY_DEFINE): new file. --- diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index 750515b648..ebfb68d8e5 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -52,6 +52,7 @@ Font_metric * select_pango_font (Output_def *layout, SCM chain); const int PANGO_RESOLUTION = 1200; +PangoFontDescription *properties_to_pango_description (SCM chain, Real text_size); #endif /* HAVE_PANGO16 */ #endif /* PANGO_FONT_HH */ diff --git a/lily/pango-select-scheme.cc b/lily/pango-select-scheme.cc new file mode 100644 index 0000000000..7c755e05f0 --- /dev/null +++ b/lily/pango-select-scheme.cc @@ -0,0 +1,20 @@ +#include "config.hh" + +#if HAVE_PANGO_FT2 +#include "pango-font.hh" + +LY_DEFINE(ly_make_pango_description_string, "ly:make-pango-description-string", + 2,0,0, (SCM chain, SCM size), + "Make a PangoFontDescription string for the property alist @var{chain} at size @var{size}.") +{ + SCM_ASSERT_TYPE(scm_is_number (size), size, SCM_ARG1, __FUNCTION__, "number"); + PangoFontDescription *pfd = properties_to_pango_description (chain, scm_to_double (size)); + char *str = pango_font_description_to_string (pfd); + + SCM scm_str = scm_makfrom0str (str); + g_free (str); + pango_font_description_free (pfd); + return scm_str; +} + +#endif diff --git a/lily/pango-select.cc b/lily/pango-select.cc index c49c63cf37..3fa18f2de9 100644 --- a/lily/pango-select.cc +++ b/lily/pango-select.cc @@ -13,8 +13,9 @@ #include "output-def.hh" #include "pango-font.hh" -Font_metric * -select_pango_font (Output_def *layout, SCM chain) + +PangoFontDescription * +properties_to_pango_description (SCM chain, Real text_size) { SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain); @@ -42,17 +43,25 @@ select_pango_font (Output_def *layout, SCM chain) } Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0); - Real size = layout->get_dimension (ly_symbol2scm ("text-font-size")) + Real size = text_size * pow (2.0, step / 6.0) * point_constant; + pango_font_description_set_size (description, gint (size * PANGO_SCALE)); - - Font_metric * fm = all_fonts_global->find_pango_font (description); + return description; +} + +Font_metric * +select_pango_font (Output_def *layout, SCM chain) +{ + PangoFontDescription *pfd =properties_to_pango_description (chain, + layout->get_dimension (ly_symbol2scm ("text-font-size"))); + + Font_metric * fm = all_fonts_global->find_pango_font (pfd); return find_scaled_font (layout, fm, 1.0); } - PangoStyle symbol_to_pango_style (SCM style) {