2 pfb.cc -- implement pfb conversion.
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
14 #include "program-option.hh"
15 #include "source-file.hh"
16 #include "memory-stream.hh"
17 #include "open-type-font.hh"
22 pfb2pfa (Byte const *pfb, int length)
24 char *out = new char[1];
28 while (p < pfb + length)
39 | (p[2] << 16) | (p[3] << 24);
44 out = (char *)realloc (out, olen + seglen + 1);
45 char *outp = out + olen;
46 memcpy (outp, p, seglen);
52 unsigned outlength = (seglen * 2) + (seglen / 32) + 2;
54 out = (char *)realloc (out, olen + outlength + 1);
56 char *outp = out + olen;
57 for (int i = seglen; i--;)
59 sprintf (outp, "%02x", *p++);
73 LY_DEFINE (ly_pfb_to_pfa, "ly:pfb->pfa",
74 1, 0, 0, (SCM pfb_file_name),
75 "Convert the contents of a PFB file to PFA.")
77 SCM_ASSERT_TYPE (scm_is_string (pfb_file_name), pfb_file_name,
78 SCM_ARG1, __FUNCTION__, "string");
80 string file_name = ly_scm2string (pfb_file_name);
82 if (be_verbose_global)
83 progress_indication ("[" + file_name);
85 vector<char> pfb_string = gulp_file (file_name, 0);
86 char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
88 SCM pfa_scm = scm_from_locale_string (pfa);
91 if (be_verbose_global)
92 progress_indication ("]");
97 LY_DEFINE (ly_otf_to_cff, "ly:otf->cff",
98 1, 0, 0, (SCM otf_file_name),
99 "Convert the contents of a OTF file to CFF file, returning it as "
102 SCM_ASSERT_TYPE (scm_is_string (otf_file_name), otf_file_name,
103 SCM_ARG1, __FUNCTION__, "string");
105 string file_name = ly_scm2string (otf_file_name);
106 if (be_verbose_global)
107 progress_indication ("[" + file_name);
109 FT_Face face = open_ft_face (file_name);
110 string table = get_otf_table (face, "CFF ");
112 SCM asscm = scm_from_locale_stringn ((char *) table.data (),
115 if (be_verbose_global)
116 progress_indication ("]");