Remove cmap format 100, fixes some nits to merge with upstream
This commit is contained in:
parent
3726686d22
commit
3e78538c1c
27
fonts.js
27
fonts.js
@ -437,25 +437,14 @@ var Font = (function () {
|
|||||||
glyphs.push({ unicode: 0x0000 });
|
glyphs.push({ unicode: 0x0000 });
|
||||||
var ranges = getRanges(glyphs);
|
var ranges = getRanges(glyphs);
|
||||||
|
|
||||||
var numTables = 2;
|
var numTables = 1;
|
||||||
var kFormat100ArraySize = 256;
|
|
||||||
var cmap = "\x00\x00" + // version
|
var cmap = "\x00\x00" + // version
|
||||||
string16(numTables) + // numTables
|
string16(numTables) + // numTables
|
||||||
"\x00\x01" + // platformID
|
|
||||||
"\x00\x00" + // encodingID
|
|
||||||
string32(4 + numTables * 8) + // start of the table record
|
|
||||||
"\x00\x03" + // platformID
|
"\x00\x03" + // platformID
|
||||||
"\x00\x01" + // encodingID
|
"\x00\x01" + // encodingID
|
||||||
string32(4 + numTables * 8 + 6 + kFormat100ArraySize); // start of the table record
|
string32(4 + numTables * 8); // start of the table record
|
||||||
|
|
||||||
var format100 = "\x00\x00" + // format
|
var headerSize = (12 * 2 + (ranges.length * 5 * 2));
|
||||||
string16(6 + kFormat100ArraySize) + // length
|
|
||||||
"\x00\x00"; // language
|
|
||||||
|
|
||||||
for (var i = 0; i < kFormat100ArraySize; i++)
|
|
||||||
format100 += String.fromCharCode(i);
|
|
||||||
|
|
||||||
var headerSize = (12 * 2 + (ranges.length * 4 * 2));
|
|
||||||
var segCount = ranges.length + 1;
|
var segCount = ranges.length + 1;
|
||||||
var segCount2 = segCount * 2;
|
var segCount2 = segCount * 2;
|
||||||
var searchRange = FontsUtils.getMaxPower2(segCount) * 2;
|
var searchRange = FontsUtils.getMaxPower2(segCount) * 2;
|
||||||
@ -481,7 +470,7 @@ var Font = (function () {
|
|||||||
var range = ranges[i];
|
var range = ranges[i];
|
||||||
var start = range[0];
|
var start = range[0];
|
||||||
var end = range[1];
|
var end = range[1];
|
||||||
var delta = (((start - 1) - bias) ^ 0xffff);
|
var delta = (bias - start) % 0xffff;
|
||||||
bias += (end - start + 1);
|
bias += (end - start + 1);
|
||||||
|
|
||||||
startCount += string16(start);
|
startCount += string16(start);
|
||||||
@ -489,7 +478,7 @@ var Font = (function () {
|
|||||||
idDeltas += string16(delta);
|
idDeltas += string16(delta);
|
||||||
idRangeOffsets += string16(0);
|
idRangeOffsets += string16(0);
|
||||||
|
|
||||||
for (var j = start; j < end; j++) {
|
for (var j = start; j <= end; j++) {
|
||||||
glyphsIds += string16(j);
|
glyphsIds += string16(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -501,7 +490,7 @@ var Font = (function () {
|
|||||||
format314 += endCount + "\x00\x00" + startCount +
|
format314 += endCount + "\x00\x00" + startCount +
|
||||||
idDeltas + idRangeOffsets + glyphsIds;
|
idDeltas + idRangeOffsets + glyphsIds;
|
||||||
|
|
||||||
return stringToArray(cmap + format100 + format314);
|
return stringToArray(cmap + format314);
|
||||||
};
|
};
|
||||||
|
|
||||||
function createOS2Table(properties) {
|
function createOS2Table(properties) {
|
||||||
@ -541,7 +530,7 @@ var Font = (function () {
|
|||||||
"\x02\x24" + // xAvgCharWidth
|
"\x02\x24" + // xAvgCharWidth
|
||||||
"\x01\xF4" + // usWeightClass
|
"\x01\xF4" + // usWeightClass
|
||||||
"\x00\x05" + // usWidthClass
|
"\x00\x05" + // usWidthClass
|
||||||
"\x00\x02" + // fstype
|
"\x00\x00" + // fstype (0 to let the font loads via font-face on IE)
|
||||||
"\x02\x8A" + // ySubscriptXSize
|
"\x02\x8A" + // ySubscriptXSize
|
||||||
"\x02\xBB" + // ySubscriptYSize
|
"\x02\xBB" + // ySubscriptYSize
|
||||||
"\x00\x00" + // ySubscriptXOffset
|
"\x00\x00" + // ySubscriptXOffset
|
||||||
@ -1075,7 +1064,7 @@ var Font = (function () {
|
|||||||
var url = "url(data:" + this.mimetype + ";base64," + window.btoa(data) + ");";
|
var url = "url(data:" + this.mimetype + ";base64," + window.btoa(data) + ");";
|
||||||
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + "}";
|
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + "}";
|
||||||
var styleSheet = document.styleSheets[0];
|
var styleSheet = document.styleSheets[0];
|
||||||
styleSheet.insertRule(rule, styleSheet.length);
|
styleSheet.insertRule(rule, styleSheet.cssRules.length);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
11
pdf.js
11
pdf.js
@ -3404,7 +3404,7 @@ var CanvasGraphics = (function() {
|
|||||||
BX: "beginCompat",
|
BX: "beginCompat",
|
||||||
EX: "endCompat",
|
EX: "endCompat",
|
||||||
},
|
},
|
||||||
|
|
||||||
translateFont: function(fontDict, xref, resources) {
|
translateFont: function(fontDict, xref, resources) {
|
||||||
var fd = fontDict.get("FontDescriptor");
|
var fd = fontDict.get("FontDescriptor");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
@ -3545,7 +3545,7 @@ var CanvasGraphics = (function() {
|
|||||||
flags: descriptor.get("Flags"),
|
flags: descriptor.get("Flags"),
|
||||||
italicAngle: descriptor.get("ItalicAngle"),
|
italicAngle: descriptor.get("ItalicAngle"),
|
||||||
fixedPitch: false,
|
fixedPitch: false,
|
||||||
textMatrix: IDENTITY_MATRIX.slice()
|
textMatrix: IDENTITY_MATRIX
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -3870,8 +3870,11 @@ var CanvasGraphics = (function() {
|
|||||||
} else {
|
} else {
|
||||||
text = Fonts.charsToUnicode(text);
|
text = Fonts.charsToUnicode(text);
|
||||||
this.ctx.translate(this.current.x, -1 * this.current.y);
|
this.ctx.translate(this.current.x, -1 * this.current.y);
|
||||||
var matrix = Fonts.lookup(this.current.fontName).properties.textMatrix;
|
|
||||||
this.ctx.transform.apply(this.ctx, matrix);
|
var font = Fonts.lookup(this.current.fontName);
|
||||||
|
if (font)
|
||||||
|
this.ctx.transform.apply(this.ctx, font.properties.textMatrix);
|
||||||
|
|
||||||
this.ctx.fillText(text, 0, 0);
|
this.ctx.fillText(text, 0, 0);
|
||||||
this.current.x += Fonts.measureText(text);
|
this.current.x += Fonts.measureText(text);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Type2 reader code below is only used for debugging purpose since Type2
|
* The Type2 reader code below is only used for debugging purpose since Type2
|
||||||
* is only a CharString format and is never used directly as a Font file.
|
* is only a CharString format and is never used directly as a Font file.
|
||||||
@ -376,6 +378,9 @@ var Type2Parser = function(aFilePath) {
|
|||||||
* writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".cff");
|
* writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".cff");
|
||||||
*/
|
*/
|
||||||
function writeToFile(aBytes, aFilePath) {
|
function writeToFile(aBytes, aFilePath) {
|
||||||
|
if (!("netscape" in window))
|
||||||
|
return;
|
||||||
|
|
||||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||||
var Cc = Components.classes,
|
var Cc = Components.classes,
|
||||||
Ci = Components.interfaces;
|
Ci = Components.interfaces;
|
||||||
@ -384,7 +389,7 @@ function writeToFile(aBytes, aFilePath) {
|
|||||||
|
|
||||||
var stream = Cc["@mozilla.org/network/file-output-stream;1"]
|
var stream = Cc["@mozilla.org/network/file-output-stream;1"]
|
||||||
.createInstance(Ci.nsIFileOutputStream);
|
.createInstance(Ci.nsIFileOutputStream);
|
||||||
stream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
|
stream.init(file, 0x04 | 0x08 | 0x20, 0x180, 0);
|
||||||
|
|
||||||
var bos = Cc["@mozilla.org/binaryoutputstream;1"]
|
var bos = Cc["@mozilla.org/binaryoutputstream;1"]
|
||||||
.createInstance(Ci.nsIBinaryOutputStream);
|
.createInstance(Ci.nsIBinaryOutputStream);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user