Remove usage of makeSubStream
from Type1Parser.extractFontProgram
in src/core/type1_parser.js (issue 9735)
This avoids the initialization of, potentially thousands of, unnecessary `Stream` objects, by getting the required number of bytes directly instead. Given the special behaviour, when `length === 0`, of the `getBytes`/`skip` methods, it's also necessary to handle that particular case to prevent errors when encountering empty CharStrings.
This commit is contained in:
parent
91a8027acd
commit
f68f60099e
@ -559,11 +559,9 @@ var Type1Parser = (function Type1ParserClosure() {
|
|||||||
var glyph = this.getToken();
|
var glyph = this.getToken();
|
||||||
length = this.readInt();
|
length = this.readInt();
|
||||||
this.getToken(); // read in 'RD' or '-|'
|
this.getToken(); // read in 'RD' or '-|'
|
||||||
data = stream.makeSubStream(stream.pos, length);
|
data = (length > 0 ? stream.getBytes(length) : new Uint8Array(0));
|
||||||
lenIV = program.properties.privateData['lenIV'];
|
lenIV = program.properties.privateData['lenIV'];
|
||||||
encoded = this.readCharStrings(data.getBytes(), lenIV);
|
encoded = this.readCharStrings(data, lenIV);
|
||||||
// Skip past the required space and binary data.
|
|
||||||
stream.skip(length);
|
|
||||||
this.nextChar();
|
this.nextChar();
|
||||||
token = this.getToken(); // read in 'ND' or '|-'
|
token = this.getToken(); // read in 'ND' or '|-'
|
||||||
if (token === 'noaccess') {
|
if (token === 'noaccess') {
|
||||||
@ -582,11 +580,9 @@ var Type1Parser = (function Type1ParserClosure() {
|
|||||||
var index = this.readInt();
|
var index = this.readInt();
|
||||||
length = this.readInt();
|
length = this.readInt();
|
||||||
this.getToken(); // read in 'RD' or '-|'
|
this.getToken(); // read in 'RD' or '-|'
|
||||||
data = stream.makeSubStream(stream.pos, length);
|
data = (length > 0 ? stream.getBytes(length) : new Uint8Array(0));
|
||||||
lenIV = program.properties.privateData['lenIV'];
|
lenIV = program.properties.privateData['lenIV'];
|
||||||
encoded = this.readCharStrings(data.getBytes(), lenIV);
|
encoded = this.readCharStrings(data, lenIV);
|
||||||
// Skip past the required space and binary data.
|
|
||||||
stream.skip(length);
|
|
||||||
this.nextChar();
|
this.nextChar();
|
||||||
token = this.getToken(); // read in 'NP' or '|'
|
token = this.getToken(); // read in 'NP' or '|'
|
||||||
if (token === 'noaccess') {
|
if (token === 'noaccess') {
|
||||||
|
Loading…
Reference in New Issue
Block a user