]> git.donarmstrong.com Git - lilypond.git/blob - lily/pfb-scheme.cc
Doc: Included/compile.itexi - CG 4.2 - Updated notes on reqs for compiling
[lilypond.git] / lily / pfb-scheme.cc
1
2 #include "program-option.hh"
3 #include "source-file.hh"
4 #include "memory-stream.hh"
5 #include "open-type-font.hh"
6 #include "main.hh"
7 #include "warn.hh"
8
9 using std::string;
10 using std::vector;
11
12 LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
13            1, 0, 0, (SCM pfb_file_name),
14            "Convert the contents of a Type@tie{}1 font in PFB format"
15            " to PFA format.")
16 {
17   LY_ASSERT_TYPE (scm_is_string, pfb_file_name, 1);
18
19   string file_name = ly_scm2string (pfb_file_name);
20
21   debug_output ("[" + file_name); // start message on a new line
22
23   vector<char> pfb_string = gulp_file (file_name, 0);
24   char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
25
26   SCM pfa_scm = scm_from_latin1_string (pfa);
27   free (pfa);
28
29   debug_output ("]", false);
30
31   return pfa_scm;
32 }
33
34 LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
35            1, 0, 0, (SCM otf_file_name),
36            "Convert the contents of an OTF file to a CFF file,"
37            " returning it as a string.")
38 {
39   LY_ASSERT_TYPE (scm_is_string, otf_file_name, 1);
40
41   string file_name = ly_scm2string (otf_file_name);
42   debug_output ("[" + file_name); // start message on a new line
43
44   FT_Face face = open_ft_face (file_name, 0 /* index */);
45   string table = get_otf_table (face, "CFF ");
46
47   SCM asscm = scm_from_latin1_stringn ((char *) table.data (),
48                                        table.length ());
49
50   debug_output ("]", false);
51
52   return asscm;
53 }