2 pfb.cc -- implement pfb conversion.
4 source file of the GNU LilyPond music typesetter
6 (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
14 #include "lily-guile.hh"
15 #include "source-file.hh"
18 pfb2pfa (Byte const * pfb, int length)
20 char * out = new char[1];
24 while (p < pfb + length)
35 | (p[2] << 16) | (p[3] << 24);
40 out = (char*)realloc (out, olen + seglen + 1);
41 char* outp = out + olen ;
42 memcpy (outp, p, seglen);
48 unsigned outlength = (seglen * 2) + (seglen / 32) + 2;
50 out = (char*)realloc (out, olen + outlength + 1);
52 char * outp = out + olen;
53 for (int i = seglen; i--;)
55 sprintf (outp, "%02x", *p++);
72 LY_DEFINE(ly_pfb_to_pfa, "ly:pfb->pfa",
73 1,0,0, (SCM pfb_path),
74 "Convert the contents of a PFB file to PFA."
77 SCM_ASSERT_TYPE(scm_is_string (pfb_path), pfb_path,
78 SCM_ARG1, __FUNCTION__, "string");
80 String path = ly_scm2string (pfb_path);
82 char *str = gulp_file (path, &len);
83 char *pfa = pfb2pfa ((Byte*)str, len);
85 SCM pfa_scm = scm_makfrom0str(pfa);