]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/pfb-scheme.cc
Release: bump Welcome versions.
[lilypond.git] / lily / pfb-scheme.cc
index f708c098a09329511805f27a1d6f8db4a1409112..37e44da8b05ed7fd1eff145b6c138b40c03c77ea 100644 (file)
@@ -7,22 +7,33 @@
 #include "main.hh"
 #include "warn.hh"
 
-LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
-           1, 0, 0, (SCM pfb_file_name),
+LY_DEFINE (ly_type1_2_pfa, "ly:type1->pfa",
+           1, 0, 0, (SCM type1_file_name),
            "Convert the contents of a Type@tie{}1 font in PFB format"
-           " to PFA format.")
+           " to PFA format.  If the file is already in PFA format,"
+           " pass through it.")
 {
-  LY_ASSERT_TYPE (scm_is_string, pfb_file_name, 1);
+  LY_ASSERT_TYPE (scm_is_string, type1_file_name, 1);
 
-  string file_name = ly_scm2string (pfb_file_name);
+  string file_name = ly_scm2string (type1_file_name);
 
   debug_output ("[" + file_name); // start message on a new line
 
-  vector<char> pfb_string = gulp_file (file_name, 0);
-  char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
+  vector<char> type1_string = gulp_file (file_name, 0);
+  SCM pfa_scm;
 
-  SCM pfa_scm = scm_from_latin1_string (pfa);
-  free (pfa);
+  if ((Byte) type1_string[0] == 0x80)
+    {
+      /* The file is in PFB format. Convert it to PFA format. */
+      vector<char> pfa = pfb2pfa (type1_string);
+      pfa_scm = scm_from_latin1_stringn (&pfa[0], pfa.size ());
+    }
+  else
+    {
+      /* The file is in PFA format. Pass it through. */
+      pfa_scm = scm_from_latin1_stringn (&type1_string[0],
+                                         type1_string.size ());
+    }
 
   debug_output ("]", false);