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"
15 #include "memory-stream.hh"
19 pfb2pfa (Byte const * pfb, int length)
21 char * out = new char[1];
25 while (p < pfb + length)
36 | (p[2] << 16) | (p[3] << 24);
41 out = (char*)realloc (out, olen + seglen + 1);
42 char* outp = out + olen ;
43 memcpy (outp, p, seglen);
49 unsigned outlength = (seglen * 2) + (seglen / 32) + 2;
51 out = (char*)realloc (out, olen + outlength + 1);
53 char * outp = out + olen;
54 for (int i = seglen; i--;)
56 sprintf (outp, "%02x", *p++);
73 LY_DEFINE(ly_pfb_to_pfa, "ly:pfb->pfa",
74 1, 0, 0, (SCM pfb_path),
75 "Convert the contents of a PFB file to PFA."
78 SCM_ASSERT_TYPE(scm_is_string (pfb_path), pfb_path,
79 SCM_ARG1, __FUNCTION__, "string");
81 String path = ly_scm2string (pfb_path);
83 char *str = gulp_file (path, &len);
84 char *pfa = pfb2pfa ((Byte*)str, len);
86 SCM pfa_scm = scm_makfrom0str(pfa);
93 LY_DEFINE(ly_ttf_to_pfa, "ly:ttf->pfa",
94 1, 0, 0, (SCM ttf_path),
95 "Convert the contents of a TTF file to Type42 PFA, returning it as "
99 SCM_ASSERT_TYPE(scm_is_string (ttf_path), ttf_path,
100 SCM_ARG1, __FUNCTION__, "string");
102 String path = ly_scm2string (ttf_path);
104 Memory_out_stream stream;
105 create_type42(path.to_str0 (),
107 SCM asscm = scm_from_locale_stringn (stream.get_string (),
108 stream.get_length ());