- {
- unsigned outlength = (seglen * 2) + (seglen / 32) + 2;
-
- out = (char *)realloc (out, olen + outlength + 1);
-
- char *outp = out + olen;
- for (int i = seglen; i--;)
- {
- sprintf (outp, "%02x", *p++);
- outp += 2;
- if (! (i % 32))
- *outp++ = '\n';
- }
-
- olen = outp - out;
- }
+ {
+ stringstream ss;
+
+ ss << hex << setfill ('0');
+
+ for (size_t i = seglen; i > 0; --i)
+ {
+ ss << setw (2) << static_cast<int>(static_cast<Byte>(*p++));
+ if (! (i % 32))
+ ss << '\n';
+ }
+
+ string str = ss.str ();
+ copy (str.begin (), str.end (), back_inserter (out));
+ }
+ else
+ {
+ error (_ ("Segment type of the Type 1 (PFB) font is unknown."));
+ break;
+ }