]> git.donarmstrong.com Git - lilypond.git/blob - lily/pfb-scheme.cc
Doc: NR - spacing.itely: Various improvements
[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 LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
10            1, 0, 0, (SCM pfb_file_name),
11            "Convert the contents of a Type@tie{}1 font in PFB format"
12            " to PFA format.")
13 {
14   LY_ASSERT_TYPE (scm_is_string, pfb_file_name, 1);
15
16   string file_name = ly_scm2string (pfb_file_name);
17
18   debug_output ("[" + file_name); // start message on a new line
19
20   vector<char> pfb_string = gulp_file (file_name, 0);
21   char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
22
23   SCM pfa_scm = scm_from_latin1_string (pfa);
24   free (pfa);
25
26   debug_output ("]", false);
27
28   return pfa_scm;
29 }
30
31 LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
32            1, 0, 0, (SCM otf_file_name),
33            "Convert the contents of an OTF file to a CFF file,"
34            " returning it as a string.")
35 {
36   LY_ASSERT_TYPE (scm_is_string, otf_file_name, 1);
37
38   string file_name = ly_scm2string (otf_file_name);
39   debug_output ("[" + file_name); // start message on a new line
40
41   FT_Face face = open_ft_face (file_name, 0 /* index */);
42   string table = get_otf_table (face, "CFF ");
43
44   SCM asscm = scm_from_latin1_stringn ((char *) table.data (),
45                                        table.length ());
46
47   debug_output ("]", false);
48
49   return asscm;
50 }