- SCM key = gh_cons (fn, gh_double2scm (m));
- SCM met = scm_assoc (key, scaled_fonts_);
-
- if (gh_pair_p (met))
- return unsmob_metrics (ly_cdr (met));
-
- /*
- Hmm. We're chaining font - metrics. Should consider wether to merge
- virtual-font and scaled_font.
- */
- Font_metric* f=0;
- if (gh_list_p (fn))
- {
- f = new Virtual_font_metric (fn, m, this);
- }
- else
- {
- SCM var = ly_module_lookup (scope_, ly_symbol2scm ("outputscale"));
- m /= gh_scm2double (scm_variable_ref (var));
-
- f = all_fonts_global->find_font (ly_scm2string (fn));
- SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
- scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
- f = unsmob_metrics (val);
- scm_gc_unprotect_object (val);
- }
-
- return f;
+ if (layout->parent_)
+ return find_pango_font (layout->parent_, descr, factor);
+
+ SCM table = get_pango_font_table (layout);
+ SCM sizes = scm_hash_ref (table, descr, SCM_EOL);
+ SCM size_key = scm_from_double (factor);
+ SCM handle = scm_assoc (size_key, sizes);
+ if (scm_is_pair (handle))
+ return unsmob_metrics (scm_cdr (handle));
+
+ PangoFontDescription *description
+ = pango_font_description_from_string (scm_i_string_chars (descr));
+ Font_metric *fm = all_fonts_global->find_pango_font (description,
+ factor,
+ output_scale (layout));
+
+ sizes = scm_acons (size_key, fm->self_scm (), sizes);
+ scm_hash_set_x (table, descr, sizes);
+
+ return fm;