2 pfb.cc -- implement pfb conversion.
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
14 #include "source-file.hh"
17 pfb2pfa (Byte const * pfb, int length)
19 char * out = new char[1];
23 while (p < pfb + length)
34 | (p[2] << 16) | (p[3] << 24);
39 out = (char*)realloc (out, olen + seglen + 1);
40 char* outp = out + olen ;
41 memcpy (outp, p, seglen);
47 unsigned outlength = (seglen * 2) + (seglen / 32) + 2;
49 out = (char*)realloc (out, olen + outlength + 1);
51 char * outp = out + olen;
52 for (int i = seglen; i--;)
54 sprintf (outp, "%02x", *p++);
71 LY_DEFINE(ly_pfb_to_pfa, "ly:pfb->pfa",
72 1,0,0, (SCM pfb_path),
73 "Convert the contents of a PFB file to PFA."
76 SCM_ASSERT_TYPE(scm_is_string (pfb_path), pfb_path,
77 SCM_ARG1, __FUNCTION__, "string");
79 String path = ly_scm2string (pfb_path);
81 char *str = gulp_file (path, &len);
82 char *pfa = pfb2pfa ((Byte*)str, len);
84 SCM pfa_scm = scm_makfrom0str(pfa);