2 pfb.cc -- implement pfb conversion.
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2006 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);
83 if (be_verbose_global)
84 progress_indication ("[" + file_name);
86 char *str = gulp_file (file_name, &len);
87 char *pfa = pfb2pfa ((Byte *)str, len);
89 SCM pfa_scm = scm_makfrom0str (pfa);
92 if (be_verbose_global)
93 progress_indication ("]");
98 LY_DEFINE (ly_otf_to_cff, "ly:otf->cff",
99 1, 0, 0, (SCM otf_file_name),
100 "Convert the contents of a OTF file to CFF file, returning it as "
103 SCM_ASSERT_TYPE (scm_is_string (otf_file_name), otf_file_name,
104 SCM_ARG1, __FUNCTION__, "string");
106 String file_name = ly_scm2string (otf_file_name);
107 if (be_verbose_global)
108 progress_indication ("[" + file_name);
110 FT_Face face = open_ft_face (file_name);
111 String table = get_otf_table (face, "CFF ");
113 SCM asscm = scm_from_locale_stringn ((char *) table.get_bytes (),
116 if (be_verbose_global)
117 progress_indication ("]");