X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fall-font-metrics.cc;h=440e16ca66fc55002a11d3dfa2e2967ce89cd13a;hb=36342ddfdbf0c112be9cb4ce471417e9c0e8fa1f;hp=6eb62bf103b7a5294aaf56ed910db33f662bbff8;hpb=58bcc84c9480dae1b21bc24d8396b91fe19e0131;p=lilypond.git diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index 6eb62bf103..440e16ca66 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2005 Han-Wen Nienhuys + (c) 1999--2005 Han-Wen Nienhuys */ #include "all-font-metrics.hh" @@ -43,12 +43,12 @@ All_font_metrics::All_font_metrics (String path) All_font_metrics::~All_font_metrics () { - scm_gc_unprotect_object (afm_dict_->self_scm ()); - scm_gc_unprotect_object (tfm_dict_->self_scm ()); - scm_gc_unprotect_object (otf_dict_->self_scm ()); + afm_dict_->unprotect (); + tfm_dict_->unprotect (); + otf_dict_->unprotect (); #if HAVE_PANGO_FT2 - scm_gc_unprotect_object (pango_dict_->self_scm ()); + pango_dict_->unprotect (); g_object_unref (pango_ft2_fontmap_); #endif } @@ -62,35 +62,38 @@ All_font_metrics::All_font_metrics (All_font_metrics const &) Pango_font * All_font_metrics::find_pango_font (PangoFontDescription *description, Real magnification, - Real output_scale) + Real output_scale + ) { pango_font_description_set_size (description, gint (magnification * pango_font_description_get_size (description))); - gchar *fn = pango_font_description_to_filename (description); - SCM key = ly_symbol2scm (fn); + gchar *pango_fn = pango_font_description_to_filename (description); + SCM key = ly_symbol2scm (pango_fn); SCM val; if (!pango_dict_->try_retrieve (key, &val)) { if (be_verbose_global) - progress_indication ("[" + String (fn)); + progress_indication ("[" + String (pango_fn)); + Pango_font *pf = new Pango_font (pango_ft2_fontmap_, - RIGHT, description, - output_scale); + output_scale + ); + val = pf->self_scm (); pango_dict_->set (key, val); - scm_gc_unprotect_object (val); + pf->unprotect (); if (be_verbose_global) progress_indication ("]"); pf->description_ = scm_cons (SCM_BOOL_F, - scm_make_real (1.0)); + scm_from_double (1.0)); } - g_free (fn); + g_free (pango_fn); return dynamic_cast (unsmob_metrics (val)); } @@ -104,10 +107,17 @@ kpathsea_find_file (String name, String ext) if (path.length () > 0) return path; - SCM kpath = ly_lily_module_constant ("ly:kpathsea-find-file"); - if (ly_c_procedure_p (kpath)) + static SCM proc; + if (!proc) + { + SCM module = scm_c_resolve_module ("scm kpathsea"); + proc = scm_c_module_lookup (module, "ly:kpathsea-find-file"); + proc = scm_variable_ref (proc); + } + + if (ly_is_procedure (proc)) { - SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0 ())); + SCM kp_result = scm_call_1 (proc, scm_makfrom0str (name.to_str0 ())); if (scm_is_string (kp_result)) return ly_scm2string (kp_result); } @@ -151,13 +161,13 @@ All_font_metrics::find_afm (String name) unsmob_metrics (val)->file_name_ = file_name; unsmob_metrics (val)->description_ = scm_cons (name_string, - scm_make_real (1.0)); + scm_from_double (1.0)); if (be_verbose_global) progress_indication ("]"); afm_dict_->set (sname, val); - scm_gc_unprotect_object (val); + unsmob_metrics (val)->unprotect (); Adobe_font_metric *afm = dynamic_cast (unsmob_metrics (val)); @@ -221,9 +231,9 @@ All_font_metrics::find_otf (String name) unsmob_metrics (val)->file_name_ = file_name; unsmob_metrics (val)->description_ = scm_cons (name_string, - scm_make_real (1.0)); + scm_from_double (1.0)); otf_dict_->set (sname, val); - scm_gc_unprotect_object (val); + unsmob_metrics (val)->unprotect (); } return dynamic_cast (unsmob_metrics (val)); @@ -263,9 +273,9 @@ All_font_metrics::find_tfm (String name) unsmob_metrics (val)->file_name_ = file_name; unsmob_metrics (val)->description_ = scm_cons (name_string, - scm_make_real (1.0)); + scm_from_double (1.0)); tfm_dict_->set (sname, val); - scm_gc_unprotect_object (val); + unsmob_metrics (val)->unprotect (); } return dynamic_cast (unsmob_metrics (val)); @@ -295,7 +305,7 @@ All_font_metrics::find_font (String name) if (!f) { warning (_f ("can't find font: `%s'", name.to_str0 ())); - warning (_ ("Loading default font")); + warning (_ ("loading default font")); } String def_name = default_font_str0_; @@ -312,7 +322,7 @@ All_font_metrics::find_font (String name) { error (_f ("can't find default font: `%s'", def_name.to_str0 ())); error (_f ("(search path: `%s')", search_path_.to_string ())); - error (_ ("Giving up")); + error (_ ("giving up")); } return f;