Browse Source

Small changes

Vivien Nicolas 14 years ago
parent
commit
9830b09f34
  1. 14
      PDFFont.js
  2. 24
      PDFFontUtils.js
  3. 1
      cffStandardStrings.js
  4. 1
      test.html

14
PDFFont.js

@ -41,6 +41,7 @@ var Font = function(aFontName, aFontFile, aFontType) {
return; return;
} }
var start = Date.now();
switch (aFontType) { switch (aFontType) {
case "Type1": case "Type1":
// All Type1 font program should begin with the comment %! // 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"); warn("Font " + aFontType + " is not supported");
break; break;
} }
var end = Date.now();
// Attach the font to the document // Attach the font to the document
this.bind(); this.bind();
@ -417,7 +419,7 @@ Font.prototype = {
for (var i = 0; i < offsets.currentOffset; i++) for (var i = 0; i < offsets.currentOffset; i++)
fontData.push(otf[i]); fontData.push(otf[i]);
writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".otf"); //writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".otf");
return fontData; return fontData;
} }
}; };
@ -477,8 +479,8 @@ var TrueType = function(aFontName, aFontFile) {
var PSFonts = new Dict(); var PSFonts = new Dict();
var Stack = function() { var Stack = function(aStackSize) {
var innerStack = []; var innerStack = new Array(aStackSize || 0);
this.push = function(aOperand) { this.push = function(aOperand) {
innerStack.push(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 * operator returns one or more results, it does so by pushing them on the
* operand stack. * operand stack.
*/ */
var operandStack = new Stack(); var operandStack = new Stack(40);
// Flag indicating if the topmost operand of the operandStack is an array // Flag indicating if the topmost operand of the operandStack is an array
var operandIsArray = 0; var operandIsArray = 0;
@ -1156,7 +1158,7 @@ var CFF = function(aFontName, aFontFile) {
this.font = PSFonts.get(fontName); this.font = PSFonts.get(fontName);
this.data = this.convertToCFF(this.font); this.data = this.convertToCFF(this.font);
var end = Date.now(); 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, 28, 1, // Notice
248, 29, 2, // FullName 248, 29, 2, // FullName
248, 30, 3, // FamilyName 248, 30, 3, // FamilyName
248, 31, 4, // Weight 248, 31, 4 // Weight
]; ];
for (var i = 0; i < fontBBox.length; i++) for (var i = 0; i < fontBBox.length; i++)

24
PDFFontUtils.js

@ -4,7 +4,7 @@
* *
* So the code here is useful for dumping the data content of a .cff file in * 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 * 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 Type2Parser = function(aFilePath) {
var font = new Dict(); 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 // Turn on this flag for additional debugging logs
var debug = false; var debug = false;
@ -340,16 +348,10 @@ var Type2Parser = function(aFilePath) {
} }
}; };
/*
var xhr = new XMLHttpRequest(); var cff = new Type2Parser("test.cff");
xhr.open("GET", "titi.cff", false); cff.parse();
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));
/** /**

1
cffStandardStrings.js

@ -686,3 +686,4 @@ var CFFDictPrivateDataMap = {
operand: 0 operand: 0
} }
}; };

1
test.html

@ -7,7 +7,6 @@
<script type="text/javascript" src="test.js"></script> <script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="cffStandardStrings.js"></script> <script type="text/javascript" src="cffStandardStrings.js"></script>
<script type="text/javascript" src="glyphlist.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> <script type="text/javascript" src="PDFFont.js"></script>
</head> </head>

Loading…
Cancel
Save