Add a direct translation to one of the way to format charstring number in flattenCharstring (28, x, y)
This commit is contained in:
parent
fb9fb5e3fa
commit
ac020e26f1
28
PDFFont.js
28
PDFFont.js
@ -1173,24 +1173,13 @@ CFF.prototype = {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
encodeNumber: function(aValue, aIsCharstring) {
|
encodeNumber: function(aValue) {
|
||||||
var x = 0;
|
var x = 0;
|
||||||
if (aIsCharstring && aValue >= -107 && aValue <= 107) {
|
if (aValue >= -32768 && aValue <= 32767) {
|
||||||
return [aValue + 139];
|
return [ 28, aValue >> 8, aValue ];
|
||||||
} else if (aValue >= -32768 && aValue <= 32767) {
|
|
||||||
return [
|
|
||||||
28,
|
|
||||||
FontsUtils.integerToBytes(aValue >> 8, 1),
|
|
||||||
FontsUtils.integerToBytes(aValue, 1)
|
|
||||||
];
|
|
||||||
} else if (aValue >= (-2147483647-1) && aValue <= 2147483647) {
|
} else if (aValue >= (-2147483647-1) && aValue <= 2147483647) {
|
||||||
return [
|
return [
|
||||||
0xFF,
|
0xFF, aValue >> 24, Value >> 16, aValue >> 8, aValue ];
|
||||||
FontsUtils.integerToBytes(aValue >> 24, 1),
|
|
||||||
FontsUtils.integerToBytes(aValue >> 16, 1),
|
|
||||||
FontsUtils.integerToBytes(aValue >> 8, 1),
|
|
||||||
FontsUtils.integerToBytes(aValue, 1)
|
|
||||||
];
|
|
||||||
} else {
|
} else {
|
||||||
error("Value: " + aValue + " is not allowed");
|
error("Value: " + aValue + " is not allowed");
|
||||||
}
|
}
|
||||||
@ -1227,7 +1216,7 @@ CFF.prototype = {
|
|||||||
/*
|
/*
|
||||||
* Flatten the commands by interpreting the postscript code and replacing
|
* Flatten the commands by interpreting the postscript code and replacing
|
||||||
* every 'callsubr', 'callothersubr' by the real commands.
|
* every 'callsubr', 'callothersubr' by the real commands.
|
||||||
*
|
*
|
||||||
* TODO This function also do a string to command number transformation
|
* TODO This function also do a string to command number transformation
|
||||||
* that can probably be avoided if the Type1 decodeCharstring code is smarter
|
* that can probably be avoided if the Type1 decodeCharstring code is smarter
|
||||||
*/
|
*/
|
||||||
@ -1310,11 +1299,8 @@ CFF.prototype = {
|
|||||||
for (var j = 0; j < aCharstring.length; j++) {
|
for (var j = 0; j < aCharstring.length; j++) {
|
||||||
var command = aCharstring[j];
|
var command = aCharstring[j];
|
||||||
if (parseFloat(command) == command) {
|
if (parseFloat(command) == command) {
|
||||||
var number = this.encodeNumber(command, true);
|
aCharstring.splice(j, 1, 28, command >> 8, command);
|
||||||
aCharstring.splice(j, 1);
|
j+= 2;
|
||||||
for (var k = 0; k < number.length; k++)
|
|
||||||
aCharstring.splice(j + k, 0, number[k]);
|
|
||||||
j+= number.length - 1;
|
|
||||||
} else if (command.charAt) {
|
} else if (command.charAt) {
|
||||||
var command = this.commandsMap[command];
|
var command = this.commandsMap[command];
|
||||||
if (IsArray(command)) {
|
if (IsArray(command)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user