lilypond-1.3.130
[lilypond.git] / lily / afm-list.cc
blobd22ff0baf74ab4889c21461dd9eaf62f941b6c23
1 #include "pointer.hh"
2 #include "main.hh"
3 #include "all-fonts.hh"
4 #include "debug.hh"
5 #include "warn.hh"
6 #include "afm.hh"
8 const char * default_font_sz_ = "cmr10";
12 All_font_metrics::All_font_metrics (String path)
14 search_path_.parse_path (path);
16 String f = default_font_sz_ + String (".afm");
17 f = search_path_.find (f);
18 if (f.empty_b ())
19 error (_f("Can't find default font (PATH = %s)", path));
22 afm_p_dict_[default_font_sz_] = new Adobe_font_metric (read_afm_file (f));
25 Adobe_font_metric *
26 All_font_metrics::find_font (String name)
28 if (!afm_p_dict_.elem_b (name))
30 String path = name + ".afm";
31 path = search_path_.find (path);
32 if (path.empty_b ())
34 warning (_f ("Can't find `%s'", name));
35 return afm_p_dict_[default_font_sz_];
38 *mlog << "[" << path;
39 Adobe_font_metric
40 * afm_p = new Adobe_font_metric (read_afm_file (path));
41 *mlog << "]" << flush ;
43 afm_p_dict_[name] = afm_p;
46 return afm_p_dict_[name];