X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpango-select.cc;h=29686d44ddce44a8799fa59365870bd34723e3bd;hb=646a2265ea72c4007d9590a5d6d9a10ffc54ef29;hp=708720486ecffea6a713c9452483813bb0392110;hpb=85a4c7ec6a2381d875c9f93a0517999f192c081d;p=lilypond.git diff --git a/lily/pango-select.cc b/lily/pango-select.cc index 708720486e..29686d44dd 100644 --- a/lily/pango-select.cc +++ b/lily/pango-select.cc @@ -3,9 +3,8 @@ source file of the GNU LilyPond music typesetter - (c) 2004--2005 Han-Wen Nienhuys + (c) 2004--2009 Han-Wen Nienhuys */ -#include #include "dimensions.hh" #include "all-font-metrics.hh" @@ -15,13 +14,13 @@ PangoFontDescription * properties_to_pango_description (SCM chain, Real text_size) { - SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain); + SCM name = ly_chain_assoc_get (ly_symbol2scm ("font-name"), chain, SCM_BOOL_F); PangoFontDescription *description = 0; - if (scm_is_pair (name) && scm_is_string (scm_cdr (name))) + if (scm_is_string (name)) { - String name_str = ly_scm2string (scm_cdr (name)); - description = pango_font_description_from_string (name_str.to_str0 ()); + string name_str = ly_scm2string (name); + description = pango_font_description_from_string (name_str.c_str ()); } else { @@ -44,8 +43,7 @@ properties_to_pango_description (SCM chain, Real text_size) 0.0); Real size = text_size * pow (2.0, step / 6.0); - pango_font_description_set_size (description, - gint (size * PANGO_SCALE)); + pango_font_description_set_size (description, gint (size * PANGO_SCALE)); return description; } @@ -58,9 +56,10 @@ select_pango_font (Output_def *layout, SCM chain) * layout->get_dimension (ly_symbol2scm ("text-font-size"))); char *str = pango_font_description_to_string (pfd); - SCM scm_str = scm_makfrom0str (str); + SCM scm_str = scm_from_locale_string (str); g_free (str); - + pango_font_description_free (pfd); + return find_pango_font (layout, scm_str, 1.0); } @@ -69,14 +68,10 @@ symbol_to_pango_style (SCM style) { PangoStyle pstyle = PANGO_STYLE_NORMAL; if (style == ly_symbol2scm ("italic")) - { - pstyle = PANGO_STYLE_ITALIC; - } + pstyle = PANGO_STYLE_ITALIC; else if (style == ly_symbol2scm ("oblique") || style == ly_symbol2scm ("slanted")) - { - pstyle = PANGO_STYLE_OBLIQUE; - } + pstyle = PANGO_STYLE_OBLIQUE; return pstyle; } @@ -86,9 +81,7 @@ symbol_to_pango_variant (SCM variant) { PangoVariant pvariant = PANGO_VARIANT_NORMAL; if (variant == ly_symbol2scm ("caps")) - { - pvariant = PANGO_VARIANT_SMALL_CAPS; - } + pvariant = PANGO_VARIANT_SMALL_CAPS; return pvariant; } @@ -97,25 +90,15 @@ symbol_to_pango_weight (SCM weight) { PangoWeight pw = PANGO_WEIGHT_NORMAL; if (weight == ly_symbol2scm ("bold")) - { - pw = PANGO_WEIGHT_BOLD; - } + pw = PANGO_WEIGHT_BOLD; if (weight == ly_symbol2scm ("heavy")) - { - pw = PANGO_WEIGHT_HEAVY; - } + pw = PANGO_WEIGHT_HEAVY; if (weight == ly_symbol2scm ("ultrabold")) - { - pw = PANGO_WEIGHT_ULTRABOLD; - } + pw = PANGO_WEIGHT_ULTRABOLD; if (weight == ly_symbol2scm ("light")) - { - pw = PANGO_WEIGHT_LIGHT; - } + pw = PANGO_WEIGHT_LIGHT; if (weight == ly_symbol2scm ("ultralight")) - { - pw = PANGO_WEIGHT_ULTRALIGHT; - } + pw = PANGO_WEIGHT_ULTRALIGHT; return pw; } @@ -150,14 +133,14 @@ symbols_to_pango_font_description (SCM family, { PangoFontDescription *description = pango_font_description_new (); - String family_str = "roman"; + string family_str = "roman"; if (scm_is_symbol (family)) family_str = ly_symbol2string (family); else if (scm_is_string (family)) family_str = ly_scm2string (family); pango_font_description_set_family (description, - family_str.to_str0 ()); + family_str.c_str ()); pango_font_description_set_style (description, symbol_to_pango_style (style)); pango_font_description_set_variant (description,