]> git.donarmstrong.com Git - lilypond.git/blob - lily/pfb-scheme.cc
730442ef05bf781b130ed7d6b0397f5c16a2ef8f
[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 PFB file to PFA.")
12 {
13   LY_ASSERT_TYPE (scm_is_string, pfb_file_name, 1);
14
15   string file_name = ly_scm2string (pfb_file_name);
16
17   if (be_verbose_global)
18     progress_indication ("\n[" + file_name);
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_locale_string (pfa);
24   free (pfa);
25
26   if (be_verbose_global)
27     progress_indication ("]");
28
29   return pfa_scm;
30 }
31
32 LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
33            1, 0, 0, (SCM otf_file_name),
34            "Convert the contents of an OTF file to a CFF file,"
35            " returning it as a string.")
36 {
37   LY_ASSERT_TYPE (scm_is_string, otf_file_name, 1);
38
39   string file_name = ly_scm2string (otf_file_name);
40   if (be_verbose_global)
41     progress_indication ("\n[" + file_name);
42
43   FT_Face face = open_ft_face (file_name, 0 /* index */);
44   string table = get_otf_table (face, "CFF ");
45
46   SCM asscm = scm_from_locale_stringn ((char *) table.data (),
47                                        table.length ());
48
49   if (be_verbose_global)
50     progress_indication ("]");
51
52   return asscm;
53 }