2 pfb.cc -- implement pfb conversion.
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
13 #include "program-option.hh"
14 #include "source-file.hh"
15 #include "memory-stream.hh"
16 #include "open-type-font.hh"
21 pfb2pfa (Byte
const *pfb
, int length
)
23 char *out
= new char[1];
27 while (p
< pfb
+ length
)
38 | (p
[2] << 16) | (p
[3] << 24);
43 out
= (char *)realloc (out
, olen
+ seglen
+ 1);
44 char *outp
= out
+ olen
;
45 memcpy (outp
, p
, seglen
);
51 unsigned outlength
= (seglen
* 2) + (seglen
/ 32) + 2;
53 out
= (char *)realloc (out
, olen
+ outlength
+ 1);
55 char *outp
= out
+ olen
;
56 for (int i
= seglen
; i
--;)
58 sprintf (outp
, "%02x", *p
++);
75 LY_DEFINE (ly_pfb_to_pfa
, "ly:pfb->pfa",
76 1, 0, 0, (SCM pfb_file_name
),
77 "Convert the contents of a PFB file to PFA.")
79 SCM_ASSERT_TYPE (scm_is_string (pfb_file_name
), pfb_file_name
,
80 SCM_ARG1
, __FUNCTION__
, "string");
82 String file_name
= ly_scm2string (pfb_file_name
);
85 if (be_verbose_global
)
86 progress_indication ("[" + file_name
);
88 char *str
= gulp_file (file_name
, &len
);
89 char *pfa
= pfb2pfa ((Byte
*)str
, len
);
91 SCM pfa_scm
= scm_makfrom0str (pfa
);
94 if (be_verbose_global
)
95 progress_indication ("]");
102 LY_DEFINE (ly_otf_to_cff
, "ly:otf->cff",
103 1, 0, 0, (SCM otf_file_name
),
104 "Convert the contents of a OTF file to CFF file, returning it as "
107 SCM_ASSERT_TYPE (scm_is_string (otf_file_name
), otf_file_name
,
108 SCM_ARG1
, __FUNCTION__
, "string");
110 String file_name
= ly_scm2string (otf_file_name
);
111 if (be_verbose_global
)
112 progress_indication ("[" + file_name
);
114 FT_Face face
= open_ft_face (file_name
);
115 String table
= get_otf_table (face
, "CFF ");
117 SCM asscm
= scm_from_locale_stringn ((char*) table
.get_bytes (),
120 if (be_verbose_global
)
121 progress_indication ("]");