error(obj + " parsing is not implemented (yet)");
break;
- case "vstem3":
- operandStack.push("vstem");
+ case "closepath":
+ case "return":
break;
+ case "vstem3":
case "vstem":
- //log(obj + " is not converted (yet?)");
operandStack.push("vstem");
break;
- case "closepath":
- case "return":
- break;
-
- case "hlineto":
- case "vlineto":
- case "rlineto":
- case "rrcurveto":
- aggregateCommand(obj);
+ case "hstem":
+ case "hstem3":
+ operandStack.push("hstem");
break;
case "rmoveto":
operandStack.push("rmoveto");
break;
- case "hstem":
- case "hstem3":
- var dy = operandStack.pop();
- var y = operandStack.pop();
- if (operandStack.peek() == "hstem" ||
- operandStack.peek() == "hstem3")
- operandStack.pop();
-
- operandStack.push(y - lastPoint);
- lastPoint = y + dy;
-
- operandStack.push(dy);
- operandStack.push("hstem");
- break;
case "callsubr":
var index = operandStack.pop();
var charset = [
0x00
];
- var limit = 30;
for (var glyph in charstrings.map) {
- if (!limit--)
- break;
var index = CFFStrings.indexOf(glyph);
var bytes = integerToBytes(index, 2);
charset.push(bytes[0]);
"rrcurveto": 8,
"endchar": 14,
"rmoveto": 21,
+ "hmoveto": 22,
"vhcurveto": 30,
"hvcurveto": 31,
};
// Encode the glyph and add it to the FUX
var r = [[0x40, 0xEA]];
- var limit = 30;
for (var glyph in glyphs) {
- if (!limit--)
- break;
var data = glyphs[glyph].slice();
var charstring = [];
for (var i = 0; i < data.length; i++) {
var file = new Uint8Array(cff, 0, currentOffset);
var parser = new Type2Parser();
- log("parse");
- parser.parse(new Stream(file));
- var file64 = Base64Encoder.encode(file);
- console.log(file64);
+
+ log("==================== debug ====================");
+ log("== parse");
+ parser.parse(new Stream(file));
var data = [];
for (var i = 0; i < currentOffset; i++)
data.push(cff[i]);
- log(data);
+
+ log("== write to file");
+ writeToFile(data, "/tmp/pdf.js.cff");
},
createCFFIndexHeader: function(aObjects, aIsByte) {
xhr.responseArrayBuffer || xhr.response;
var cff = new Type2Parser("titi.cff");
//cff.parse(new Stream(cffData));
+
+
+/**
+ * Write to a file (works only on Firefox in privilege mode");
+ */
+ function writeToFile(aBytes, aFilePath) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var Cc = Components.classes,
+ Ci = Components.interfaces;
+ var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
+ file.initWithPath(aFilePath);
+
+ var stream = Cc["@mozilla.org/network/file-output-stream;1"]
+ .createInstance(Ci.nsIFileOutputStream);
+ stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
+
+ var bos = Cc["@mozilla.org/binaryoutputstream;1"]
+ .createInstance(Ci.nsIBinaryOutputStream);
+ bos.setOutputStream(stream);
+ bos.writeByteArray(aBytes, aBytes.length);
+ stream.close();
+ };
+