Small changes
This commit is contained in:
parent
4039e3e1e2
commit
9830b09f34
14
PDFFont.js
14
PDFFont.js
@ -41,6 +41,7 @@ var Font = function(aFontName, aFontFile, aFontType) {
|
||||
return;
|
||||
}
|
||||
|
||||
var start = Date.now();
|
||||
switch (aFontType) {
|
||||
case "Type1":
|
||||
// All Type1 font program should begin with the comment %!
|
||||
@ -64,6 +65,7 @@ var Font = function(aFontName, aFontFile, aFontType) {
|
||||
warn("Font " + aFontType + " is not supported");
|
||||
break;
|
||||
}
|
||||
var end = Date.now();
|
||||
|
||||
// Attach the font to the document
|
||||
this.bind();
|
||||
@ -417,7 +419,7 @@ Font.prototype = {
|
||||
for (var i = 0; i < offsets.currentOffset; i++)
|
||||
fontData.push(otf[i]);
|
||||
|
||||
writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".otf");
|
||||
//writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".otf");
|
||||
return fontData;
|
||||
}
|
||||
};
|
||||
@ -477,8 +479,8 @@ var TrueType = function(aFontName, aFontFile) {
|
||||
var PSFonts = new Dict();
|
||||
|
||||
|
||||
var Stack = function() {
|
||||
var innerStack = [];
|
||||
var Stack = function(aStackSize) {
|
||||
var innerStack = new Array(aStackSize || 0);
|
||||
|
||||
this.push = function(aOperand) {
|
||||
innerStack.push(aOperand);
|
||||
@ -695,7 +697,7 @@ var Type1Parser = function(aAsciiStream, aBinaryStream) {
|
||||
* operator returns one or more results, it does so by pushing them on the
|
||||
* operand stack.
|
||||
*/
|
||||
var operandStack = new Stack();
|
||||
var operandStack = new Stack(40);
|
||||
|
||||
// Flag indicating if the topmost operand of the operandStack is an array
|
||||
var operandIsArray = 0;
|
||||
@ -1156,7 +1158,7 @@ var CFF = function(aFontName, aFontFile) {
|
||||
this.font = PSFonts.get(fontName);
|
||||
this.data = this.convertToCFF(this.font);
|
||||
var end = Date.now();
|
||||
log("Time to parse font is:" + (end - start));
|
||||
//log("Time to parse font is:" + (end - start));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1392,7 +1394,7 @@ CFF.prototype = {
|
||||
248, 28, 1, // Notice
|
||||
248, 29, 2, // FullName
|
||||
248, 30, 3, // FamilyName
|
||||
248, 31, 4, // Weight
|
||||
248, 31, 4 // Weight
|
||||
];
|
||||
|
||||
for (var i = 0; i < fontBBox.length; i++)
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* So the code here is useful for dumping the data content of a .cff file in
|
||||
* order to investigate the similarity between a Type1 CharString and a Type2
|
||||
* CharString.
|
||||
* CharString or to understand the structure of the CFF format.
|
||||
*/
|
||||
|
||||
|
||||
@ -216,6 +216,14 @@ function readFontIndexData(aStream, aIsByte) {
|
||||
var Type2Parser = function(aFilePath) {
|
||||
var font = new Dict();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", aFilePath, false);
|
||||
xhr.mozResponseType = xhr.responseType = "arraybuffer";
|
||||
xhr.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200;
|
||||
xhr.send(null);
|
||||
this.data = new Stream(xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
||||
xhr.responseArrayBuffer || xhr.response);
|
||||
|
||||
// Turn on this flag for additional debugging logs
|
||||
var debug = false;
|
||||
|
||||
@ -340,22 +348,16 @@ var Type2Parser = function(aFilePath) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "titi.cff", false);
|
||||
xhr.mozResponseType = xhr.responseType = "arraybuffer";
|
||||
xhr.expected = (document.URL.indexOf("file:") == 0) ? 0 : 200;
|
||||
xhr.send(null);
|
||||
var cffData = xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
||||
xhr.responseArrayBuffer || xhr.response;
|
||||
var cff = new Type2Parser("titi.cff");
|
||||
//cff.parse(new Stream(cffData));
|
||||
/*
|
||||
var cff = new Type2Parser("test.cff");
|
||||
cff.parse();
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Write to a file (works only on Firefox in privilege mode");
|
||||
*/
|
||||
function writeToFile(aBytes, aFilePath) {
|
||||
function writeToFile(aBytes, aFilePath) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var Cc = Components.classes,
|
||||
Ci = Components.interfaces;
|
||||
@ -366,10 +368,10 @@ var cff = new Type2Parser("titi.cff");
|
||||
.createInstance(Ci.nsIFileOutputStream);
|
||||
stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
|
||||
|
||||
var bos = Cc["@mozilla.org/binaryoutputstream;1"]
|
||||
.createInstance(Ci.nsIBinaryOutputStream);
|
||||
var bos = Cc["@mozilla.org/binaryoutputstream;1"]
|
||||
.createInstance(Ci.nsIBinaryOutputStream);
|
||||
bos.setOutputStream(stream);
|
||||
bos.writeByteArray(aBytes, aBytes.length);
|
||||
stream.close();
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -686,3 +686,4 @@ var CFFDictPrivateDataMap = {
|
||||
operand: 0
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
<script type="text/javascript" src="cffStandardStrings.js"></script>
|
||||
<script type="text/javascript" src="glyphlist.js"></script>
|
||||
<script type="text/javascript" src="PDFFontUtils.js"></script>
|
||||
<script type="text/javascript" src="PDFFont.js"></script>
|
||||
</head>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user