mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-24 17:18:07 +02:00
Merge the stream handling changes with the Font code
This commit is contained in:
parent
2c4a0aa269
commit
2dc7bda2bc
2 changed files with 22 additions and 35 deletions
21
pdf.js
21
pdf.js
|
@ -48,26 +48,24 @@ function shadow(obj, prop, value) {
|
|||
}
|
||||
|
||||
var Stream = (function() {
|
||||
function constructor(arrayBuffer, dict) {
|
||||
function constructor(arrayBuffer, start, length, dict) {
|
||||
this.bytes = new Uint8Array(arrayBuffer);
|
||||
this.pos = 0;
|
||||
this.start = 0;
|
||||
this.start = start || 0;
|
||||
this.pos = this.start;
|
||||
this.length = (start + length) || arrayBuffer.byteLength;
|
||||
this.dict = dict;
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
get length() {
|
||||
return this.bytes.length;
|
||||
},
|
||||
getByte: function() {
|
||||
var bytes = this.bytes;
|
||||
if (this.pos >= bytes.length)
|
||||
if (this.pos >= this.length)
|
||||
return -1;
|
||||
return bytes[this.pos++];
|
||||
},
|
||||
lookChar: function() {
|
||||
var bytes = this.bytes;
|
||||
if (this.pos >= bytes.length)
|
||||
if (this.pos >= this.length)
|
||||
return;
|
||||
return String.fromCharCode(bytes[this.pos]);
|
||||
},
|
||||
|
@ -89,11 +87,8 @@ var Stream = (function() {
|
|||
moveStart: function() {
|
||||
this.start = this.pos;
|
||||
},
|
||||
makeSubStream: function(pos, length, dict) {
|
||||
var buffer = this.bytes.buffer;
|
||||
if (length)
|
||||
return new Stream(new Uint8Array(buffer, pos, length), dict);
|
||||
return new Stream(new Uint8Array(buffer, pos), dict);
|
||||
makeSubStream: function(start, length, dict) {
|
||||
return new Stream(this.bytes.buffer, start, length, dict);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue