From: Han-Wen Nienhuys Date: Fri, 2 Apr 2004 22:49:31 +0000 (+0000) Subject: * buildscripts/mf-to-table.py (base): add DesignSize comment. X-Git-Tag: release/2.3.0~112 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ee3df710c5f36b8a5314fa53d4481fd0479c236b;p=lilypond.git * buildscripts/mf-to-table.py (base): add DesignSize comment. * lily/afm.cc (read_afm_file): read design size. --- diff --git a/ChangeLog b/ChangeLog index a35b4c8016..a8482d819a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2004-04-03 Han-Wen Nienhuys + * buildscripts/mf-to-table.py (base): add DesignSize comment. + + * lily/afm.cc (read_afm_file): read design size. + * input/regression/repeat-unfold-tremolo.ly: add dotted case. * scm/music-functions.scm (unfold-repeats): handle dots too. diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py index b78ed88b6b..a28c745ae1 100644 --- a/buildscripts/mf-to-table.py +++ b/buildscripts/mf-to-table.py @@ -92,6 +92,8 @@ def parse_logfile (fn): if 0: #testing tags.append ('Regular') name = tags[1:] + global_info['DesignSize'] = string.atof (tags[4]) + global_info['FontName'] = string.join (name,'-') global_info['FullName'] = string.join (name,' ') global_info['FamilyName'] = string.join (name[1:-1], @@ -275,6 +277,10 @@ for filenm in files: write_afm_header (afm) afm.write ("Comment TfmCheckSum %d\n" % cs) + afm.write ("Comment DesignSize %.2f\n" % g['DesignSize']) + + del g['DesignSize'] + write_afm_metric (afm, g, m) write_tex_defs (open (texfile_nm, 'w'), g, m) diff --git a/lily/afm.cc b/lily/afm.cc index f79ba628bb..b0787ac362 100644 --- a/lily/afm.cc +++ b/lily/afm.cc @@ -20,6 +20,8 @@ Adobe_font_metric::Adobe_font_metric (AFM_Font_info * fi) checksum_ = 0; font_inf_ = fi; + design_size_ = 1.0; + for (int i= 256 >? fi->numOfChars; i--;) ascii_to_metric_idx_.push (-1); @@ -40,10 +42,13 @@ Adobe_font_metric::Adobe_font_metric (AFM_Font_info * fi) SCM -Adobe_font_metric::make_afm (AFM_Font_info *fi, unsigned int checksum) +Adobe_font_metric::make_afm (AFM_Font_info *fi, + unsigned int checksum, + Real design_size) { Adobe_font_metric * fm = new Adobe_font_metric (fi); fm->checksum_ = checksum; + fm->design_size_ = design_size; return fm->self_scm (); } @@ -118,12 +123,13 @@ SCM read_afm_file (String nm) { FILE *f = fopen (nm.to_str0 () , "r"); - char s[2048]; + char s[2048] = ""; char *check_key = "Comment TfmCheckSum"; + char *size_key = "Comment DesignSize"; unsigned int cs = 0; - - s[0] = 0; + Real ds = 1.0; + /* Assume check_key in first 10 lines */ for (int i = 0; i < 10; i++) { @@ -131,7 +137,10 @@ read_afm_file (String nm) if (strncmp (s, check_key, strlen (check_key)) == 0) { sscanf (s + strlen (check_key), "%ud", &cs); - break; + } + else if (strncmp (s, size_key, strlen (size_key)) == 0) + { + sscanf (s + strlen (size_key), "%lf", &ds); } } @@ -147,7 +156,7 @@ read_afm_file (String nm) } fclose (f); - return Adobe_font_metric::make_afm (fi, cs); + return Adobe_font_metric::make_afm (fi, cs, ds); } diff --git a/lily/include/afm.hh b/lily/include/afm.hh index 14ab748e93..ce374f03f5 100644 --- a/lily/include/afm.hh +++ b/lily/include/afm.hh @@ -34,9 +34,10 @@ struct Adobe_font_metric : Font_metric String to_string () const; ~Adobe_font_metric (); - static SCM make_afm (AFM_Font_info*, unsigned); + static SCM make_afm (AFM_Font_info*, unsigned, Real); unsigned int checksum_; + Real design_size_; protected: Array ascii_to_metric_idx_; std::map name_to_metric_dict_;