X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ffont-interface.cc;h=ec7fa8ffa7af46a24297c5c74b998819cc93b357;hb=fb7775a3de9977474d17593bd2f298044d648997;hp=0f946a74804384ae896dee25597b83bcc3102325;hpb=94189ec2b8da6d7e89dc619c646a927adead9b19;p=lilypond.git diff --git a/lily/font-interface.cc b/lily/font-interface.cc index 0f946a7480..ec7fa8ffa7 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -15,13 +15,30 @@ #include "warn.hh" +/* + TODO revise font handling. + + +* relative sizes should relate to staff-space, eg. font-staff-space += 1.2 ^ relative-size + +* If a relative size is given, lily should magnify the closest +design size font to match that. (ie. fonts should have variable +scaling) + +(this requires that fonts are stored as (filename , designsize)) + + + + */ + SCM Font_interface::font_alist_chain (Grob *me) { - SCM defaults = gh_cdr (scm_assoc (ly_symbol2scm ("font-defaults"), - me->paper_l ()->style_sheet_ )); + SCM defaults = ly_cdr (scm_assoc (ly_symbol2scm ("font-defaults"), + me->paper_l ()->style_sheet_)); - SCM ch = gh_list (me->mutable_property_alist_, + SCM ch = scm_list_n (me->mutable_property_alist_, me->immutable_property_alist_, defaults, SCM_UNDEFINED); @@ -65,10 +82,10 @@ Font_interface::get_font (Grob *me, SCM chain) SCM ss = me->paper_l ()->style_sheet_; - SCM proc = gh_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"), + SCM proc = ly_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"), ss)); - SCM fonts = gh_cdr (scm_assoc (ly_symbol2scm ("fonts"), ss)); + SCM fonts = ly_cdr (scm_assoc (ly_symbol2scm ("fonts"), ss)); assert (gh_procedure_p (proc)); SCM font_name = gh_call2 (proc, fonts, chain); @@ -84,11 +101,11 @@ Font_interface::add_style (Grob* me, SCM style, SCM chain) SCM sheet = me->paper_l ()->style_sheet_; - SCM style_alist = gh_cdr (scm_assoc (ly_symbol2scm ("style-alist"), sheet)); + SCM style_alist = ly_cdr (scm_assoc (ly_symbol2scm ("style-alist"), sheet)); SCM entry = scm_assoc (style, style_alist); if (gh_pair_p (entry)) { - chain = gh_cons (gh_cdr (entry), chain); + chain = gh_cons (ly_cdr (entry), chain); } return chain; } @@ -113,7 +130,7 @@ so a 14% speedup. */ -static SCM name_sym, shape_sym, family_sym, series_sym, rel_sz_sym, pt_sz_sym, wild_sym; +static SCM name_sym, shape_sym, family_sym, series_sym, rel_sz_sym, design_sz_sym, wild_sym; static void @@ -124,23 +141,24 @@ init_syms () family_sym = scm_permanent_object (ly_symbol2scm ("font-family")); series_sym = scm_permanent_object (ly_symbol2scm ("font-series")); rel_sz_sym = scm_permanent_object (ly_symbol2scm ("font-relative-size")); - pt_sz_sym = scm_permanent_object (ly_symbol2scm ("font-point-size")); + design_sz_sym = scm_permanent_object (ly_symbol2scm ("font-design-size")); wild_sym = scm_permanent_object (ly_symbol2scm ("*")); - scm_make_gsubr ("ly-get-default-font", 1 , 0, 0, (Scheme_function_unknown) ly_font_interface_get_default_font); + scm_c_define_gsubr ("ly-get-default-font", 1 , 0, 0, + (Scheme_function_unknown) ly_font_interface_get_default_font); } bool -Font_interface::wild_compare(SCM field_val, SCM val) +Font_interface::wild_compare (SCM field_val, SCM val) { return (val == SCM_BOOL_F || field_val == wild_sym || field_val == val); } -ADD_SCM_INIT_FUNC(Font_interface_syms,init_syms); +ADD_SCM_INIT_FUNC (Font_interface_syms,init_syms); -MAKE_SCHEME_CALLBACK(Font_interface,properties_to_font_name,2); +MAKE_SCHEME_CALLBACK (Font_interface,properties_to_font_name,2); SCM Font_interface::properties_to_font_name (SCM fonts, SCM alist_chain) { @@ -151,7 +169,7 @@ Font_interface::properties_to_font_name (SCM fonts, SCM alist_chain) SCM series = SCM_BOOL_F; - SCM point_sz = ly_assoc_chain (pt_sz_sym, alist_chain); + SCM point_sz = ly_assoc_chain (design_sz_sym, alist_chain); SCM rel_sz = SCM_BOOL_F; if (!gh_pair_p (name)) @@ -161,41 +179,41 @@ Font_interface::properties_to_font_name (SCM fonts, SCM alist_chain) series = ly_assoc_chain (series_sym, alist_chain); if (gh_pair_p (shape)) - shape = gh_cdr (shape); + shape = ly_cdr (shape); if (gh_pair_p (family)) - family = gh_cdr (family); + family = ly_cdr (family); if (gh_pair_p (series)) - series = gh_cdr (series); + series = ly_cdr (series); } else - name = gh_cdr (name); + name = ly_cdr (name); if (gh_pair_p (point_sz)) - point_sz = gh_cdr (point_sz); + point_sz = ly_cdr (point_sz); else { rel_sz = ly_assoc_chain (rel_sz_sym, alist_chain); if (gh_pair_p (rel_sz)) - rel_sz = gh_cdr (rel_sz); + rel_sz = ly_cdr (rel_sz); } - for (SCM s = fonts ; gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = fonts ; gh_pair_p (s); s = ly_cdr (s)) { - SCM qlist = gh_caar (s); + SCM qlist = ly_caar (s); if (name != SCM_BOOL_F) { - if (!wild_compare(scm_list_ref (qlist, gh_int2scm (4)), name)) + if (!wild_compare (scm_list_ref (qlist, gh_int2scm (4)), name)) continue; } else { - if (!wild_compare(scm_list_ref (qlist, gh_int2scm (1)), series)) + if (!wild_compare (scm_list_ref (qlist, gh_int2scm (1)), series)) continue; - if (!wild_compare(scm_list_ref (qlist, gh_int2scm (2)), shape)) + if (!wild_compare (scm_list_ref (qlist, gh_int2scm (2)), shape)) continue; - if (!wild_compare(scm_list_ref (qlist, gh_int2scm (3)), family)) + if (!wild_compare (scm_list_ref (qlist, gh_int2scm (3)), family)) continue; } @@ -203,23 +221,23 @@ Font_interface::properties_to_font_name (SCM fonts, SCM alist_chain) { // This if statement will always be true since name must // be SCM_BOOL_F here, right? /MB - if (!wild_compare(scm_list_ref (qlist, gh_int2scm (4)), name)) + if (!wild_compare (scm_list_ref (qlist, gh_int2scm (4)), name)) continue; } else { - if (!wild_compare(gh_car (qlist), rel_sz)) + if (!wild_compare (ly_car (qlist), rel_sz)) continue; } - SCM qname = gh_cdar (s); + SCM qname = ly_cdar (s); return qname; } - warning (_("couldn't find any font satisfying ") ); - scm_write (gh_list (name, point_sz, shape, series , family, rel_sz, SCM_UNDEFINED), scm_current_error_port ()); - scm_flush(scm_current_error_port ()); + warning (_ ("couldn't find any font satisfying ")); + scm_write (scm_list_n (name, point_sz, shape, series , family, rel_sz, SCM_UNDEFINED), scm_current_error_port ()); + scm_flush (scm_current_error_port ()); return ly_str02scm ("cmr10");