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>
13 #include "source-file.hh"
14 #include "memory-stream.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_file_name),
74 "Convert the contents of a PFB file to PFA.")
76 SCM_ASSERT_TYPE (scm_is_string (pfb_file_name), pfb_file_name,
77 SCM_ARG1, __FUNCTION__, "string");
79 String file_name = ly_scm2string (pfb_file_name);
81 char *str = gulp_file (file_name, &len);
82 char *pfa = pfb2pfa ((Byte *)str, len);
84 SCM pfa_scm = scm_makfrom0str (pfa);
90 LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa",
91 1, 0, 0, (SCM ttf_file_name),
92 "Convert the contents of a TTF file to Type42 PFA, returning it as "
95 SCM_ASSERT_TYPE (scm_is_string (ttf_file_name), ttf_file_name,
96 SCM_ARG1, __FUNCTION__, "string");
98 String file_name = ly_scm2string (ttf_file_name);
100 Memory_out_stream stream;
101 create_type42 (file_name.to_str0 (), stream.get_file ());
102 SCM asscm = scm_from_locale_stringn (stream.get_string (),
103 stream.get_length ());