fixing CFF things to pass FontValidator

This commit is contained in:
notmasteryet 2011-07-06 08:12:41 -05:00
parent 7254d5c2ef
commit 70164163de

24
fonts.js Normal file → Executable file
View File

@ -537,9 +537,9 @@ var Font = (function () {
offsets.virtualOffset++;
// checksum
var checksum = 0;
for (var i = 0; i < length; i+=4)
checksum += int16([data[i], data[i+1], data[i+2], data[i+3]]);
var checksum = 0, n = data.length;
for (var i = 0; i < n; i+=4)
checksum = (checksum + int32([data[i], data[i+1], data[i+2], data[i+3]])) | 0;
var tableEntry = tag + string32(checksum) + string32(offset) + string32(length);
tableEntry = stringToArray(tableEntry);
@ -643,7 +643,7 @@ var Font = (function () {
var firstCharIndex = null;
var lastCharIndex = 0;
for (var i = 1; i < charset.length; i++) {
for (var i = 0; i < charset.length; i++) {
var code = GlyphsUnicode[charset[i]];
if (firstCharIndex > code || !firstCharIndex)
firstCharIndex = code;
@ -993,7 +993,7 @@ var Font = (function () {
platforms[i] + // platform ID
encodings[i] + // encoding ID
languages[i] + // language ID
string16(i) + // name ID
string16(j) + // name ID
string16(str.length) +
string16(strOffset);
nameTable += nameRecord;
@ -1603,8 +1603,8 @@ CFF.prototype = {
// Add another offset after this one because we need a new offset
var relativeOffset = 1;
for (var i = 0; i < count + 1; i++) {
data += String.fromCharCode(relativeOffset >> 24, relativeOffset >> 16,
relativeOffset >> 8, relativeOffset & 0xff);
data += String.fromCharCode((relativeOffset >>> 24) & 0xFF, (relativeOffset >> 16) & 0xFF,
(relativeOffset >> 8) & 0xFF, relativeOffset & 0xFF);
if (objects[i])
relativeOffset += objects[i].length;
@ -1612,7 +1612,7 @@ CFF.prototype = {
for (var i =0; i < count; i++) {
for (var j = 0; j < objects[i].length; j++)
data += isByte ? String.fromCharCode(objects[i][j]) : objects[i][j];
data += isByte ? String.fromCharCode(objects[i][j] & 0xFF) : objects[i][j];
}
return data;
},
@ -1620,13 +1620,13 @@ CFF.prototype = {
encodeNumber: function cff_encodeNumber(value) {
if (value >= -32768 && value <= 32767) {
return "\x1c" +
String.fromCharCode(value >> 8) +
String.fromCharCode((value >> 8) & 0xFF) +
String.fromCharCode(value & 0xFF);
} else if (value >= (-2147483647-1) && value <= 2147483647) {
return "\xff" +
String.fromCharCode(value >> 24) +
String.fromCharCode(value >> 16) +
String.fromCharCode(value >> 8) +
String.fromCharCode((value >>> 24) & 0xFF) +
String.fromCharCode((value >> 16) & 0xFF) +
String.fromCharCode((value >> 8) & 0xFF) +
String.fromCharCode(value & 0xFF);
}
error("Value: " + value + " is not allowed");