2 #include "international.hh"
3 #include "program-option.hh"
4 #include "source-file.hh"
5 #include "memory-stream.hh"
6 #include "open-type-font.hh"
10 LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa",
11 1, 0, 0, (SCM pfb_file_name),
12 "Convert the contents of a Type@tie{}1 font in PFB format"
15 LY_ASSERT_TYPE (scm_is_string, pfb_file_name, 1);
17 string file_name = ly_scm2string (pfb_file_name);
19 debug_output ("[" + file_name); // start message on a new line
21 vector<char> pfb_string = gulp_file (file_name, 0);
22 char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ());
24 SCM pfa_scm = scm_from_latin1_string (pfa);
27 debug_output ("]", false);
32 LY_DEFINE (ly_otf_2_cff, "ly:otf->cff",
33 1, 1, 0, (SCM otf_file_name, SCM idx),
34 "Convert the contents of an OTF file to a CFF file,"
35 " returning it as a string. The optional"
36 " @var{idx} argument is useful for OpenType/CFF collections (OTC)"
37 " only; it specifies the font index within the OTC. The default"
38 " value of @var{idx} is@tie{}0.")
40 LY_ASSERT_TYPE (scm_is_string, otf_file_name, 1);
43 if (!SCM_UNBNDP (idx))
45 LY_ASSERT_TYPE (scm_is_integer, idx, 2);
49 warning (_ ("font index must be non-negative, using index 0"));
54 string file_name = ly_scm2string (otf_file_name);
55 debug_output ("[" + file_name); // start message on a new line
58 /* check whether font index is valid */
61 face = open_ft_face (file_name, -1);
62 if (i >= face->num_faces)
64 warning (_f ("font index %d too large for font `%s', using index 0",
65 i, file_name.c_str ()));
71 face = open_ft_face (file_name, i);
72 string table = get_otf_table (face, "CFF ");
74 SCM asscm = scm_from_latin1_stringn ((char *) table.data (),
78 debug_output ("]", false);