2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
27 #include "international.hh"
28 #include "program-option.hh"
29 #include "source-file.hh"
30 #include "memory-stream.hh"
31 #include "open-type-font.hh"
36 pfb2pfa (const vector<char> &pfb)
40 vector<char>::const_iterator p = pfb.begin ();
41 while (p < pfb.end ())
43 if (static_cast<Byte>(*p++) != 128)
45 error (_ ("Segment header of the Type 1 (PFB) font is broken."));
49 Byte type = static_cast<Byte>(*p++);
53 size_t seglen = static_cast<Byte>(*p++);
54 seglen |= (static_cast<Byte>(*p++) << 8);
55 seglen |= (static_cast<Byte>(*p++) << 16);
56 seglen |= (static_cast<Byte>(*p++) << 24);
57 if ((p + seglen) > pfb.end ())
59 error (_ ("Segment length of the Type 1 (PFB) font is too long."));
65 copy (p, p + seglen, back_inserter (out));
72 ss << hex << setfill ('0');
74 for (size_t i = seglen; i > 0; --i)
76 ss << setw (2) << static_cast<int>(static_cast<Byte>(*p++));
81 string str = ss.str ();
82 copy (str.begin (), str.end (), back_inserter (out));
86 error (_ ("Segment type of the Type 1 (PFB) font is unknown."));