+SCM
+read_afm_file (String nm)
+{
+ FILE *f = fopen (nm.to_str0 (), "r");
+ char s[2048] = "";
+ char *check_key = "Comment TfmCheckSum";
+ char *size_key = "Comment DesignSize";
+
+ unsigned int cs = 0;
+ Real ds = 1.0;
+
+ /* Assume check_key in first 10 lines */
+ for (int i = 0; i < 10; i++)
+ {
+ fgets (s, sizeof (s), f);
+ if (strncmp (s, check_key, strlen (check_key)) == 0)
+ sscanf (s + strlen (check_key), "%ud", &cs);
+ else if (strncmp (s, size_key, strlen (size_key)) == 0)
+ sscanf (s + strlen (size_key), "%lf", &ds);
+ }
+
+ rewind (f);
+
+ AFM_Font_info *fi;
+ int e = AFM_parseFile (f, &fi, ~0);
+
+ if (e)
+ error (_f ("parsing AFM file: `%s'", nm.to_str0 ()));
+ fclose (f);
+
+ return Adobe_font_metric::make_afm (fi, cs, ds);
+}