mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
Extract Type1Parser
from fonts.js
This commit is contained in:
parent
b961e1d21b
commit
ef551e8266
4 changed files with 748 additions and 700 deletions
|
@ -297,7 +297,7 @@ describe('font', function() {
|
|||
|
||||
it('splits tokens', function() {
|
||||
var stream = new StringStream('/BlueValues[-17 0]noaccess def');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual('/');
|
||||
expect(parser.getToken()).toEqual('BlueValues');
|
||||
expect(parser.getToken()).toEqual('[');
|
||||
|
@ -310,35 +310,35 @@ describe('font', function() {
|
|||
});
|
||||
it('handles glued tokens', function() {
|
||||
var stream = new StringStream('dup/CharStrings');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual('dup');
|
||||
expect(parser.getToken()).toEqual('/');
|
||||
expect(parser.getToken()).toEqual('CharStrings');
|
||||
});
|
||||
it('ignores whitespace', function() {
|
||||
var stream = new StringStream('\nab c\t');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual('ab');
|
||||
expect(parser.getToken()).toEqual('c');
|
||||
});
|
||||
it('parses numbers', function() {
|
||||
var stream = new StringStream('123');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readNumber()).toEqual(123);
|
||||
});
|
||||
it('parses booleans', function() {
|
||||
var stream = new StringStream('true false');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readBoolean()).toEqual(1);
|
||||
expect(parser.readBoolean()).toEqual(0);
|
||||
});
|
||||
it('parses number arrays', function() {
|
||||
var stream = new StringStream('[1 2]');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readNumberArray()).toEqual([1, 2]);
|
||||
// Variation on spacing.
|
||||
stream = new StringStream('[ 1 2 ]');
|
||||
parser = new Type1Parser(stream);
|
||||
parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.readNumberArray()).toEqual([1, 2]);
|
||||
});
|
||||
it('skips comments', function() {
|
||||
|
@ -347,7 +347,7 @@ describe('font', function() {
|
|||
'%%Title: CMSY10\n' +
|
||||
'%Version: 003.002\n' +
|
||||
'FontDirectory');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
expect(parser.getToken()).toEqual('FontDirectory');
|
||||
});
|
||||
it('parses font program', function() {
|
||||
|
@ -359,7 +359,7 @@ describe('font', function() {
|
|||
'/CharStrings 46 dict dup begin\n' +
|
||||
'/.notdef 1 RD x ND' + '\n' +
|
||||
'end');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
var program = parser.extractFontProgram();
|
||||
expect(program.charstrings.length).toEqual(1);
|
||||
expect(program.properties.privateData.ExpansionFactor).toEqual(99);
|
||||
|
@ -367,7 +367,7 @@ describe('font', function() {
|
|||
it('parses font header font matrix', function() {
|
||||
var stream = new StringStream(
|
||||
'/FontMatrix [0.001 0 0 0.001 0 0 ]readonly def\n');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
var props = {};
|
||||
parser.extractFontHeader(props);
|
||||
expect(props.fontMatrix).toEqual([0.001, 0, 0, 0.001, 0, 0]);
|
||||
|
@ -378,7 +378,7 @@ describe('font', function() {
|
|||
'0 1 255 {1 index exch /.notdef put} for\n' +
|
||||
'dup 33 /arrowright put\n' +
|
||||
'readonly def\n');
|
||||
var parser = new Type1Parser(stream);
|
||||
var parser = new Type1Parser(stream, false, SEAC_ANALYSIS_ENABLED);
|
||||
var props = { overridableEncoding: true };
|
||||
parser.extractFontHeader(props);
|
||||
expect(props.builtInEncoding[33]).toEqual('arrowright');
|
||||
|
|
|
@ -48,12 +48,14 @@ function initializePDFJS(callback) {
|
|||
'pdfjs/core/annotation', 'pdfjs/core/crypto', 'pdfjs/core/stream',
|
||||
'pdfjs/core/fonts', 'pdfjs/core/ps_parser', 'pdfjs/core/function',
|
||||
'pdfjs/core/parser', 'pdfjs/core/evaluator', 'pdfjs/core/cmap',
|
||||
'pdfjs/core/worker', 'pdfjs/core/network', 'pdfjs/core/cff_parser',
|
||||
'pdfjs/display/api', 'pdfjs/display/metadata', 'pdfjs/display/dom_utils'],
|
||||
'pdfjs/core/worker', 'pdfjs/core/network', 'pdfjs/core/type1_parser',
|
||||
'pdfjs/core/cff_parser', 'pdfjs/display/api', 'pdfjs/display/metadata',
|
||||
'pdfjs/display/dom_utils'],
|
||||
function (sharedUtil, displayGlobal, corePrimitives, coreAnnotation,
|
||||
coreCrypto, coreStream, coreFonts, corePsParser, coreFunction,
|
||||
coreParser, coreEvaluator, coreCMap, coreWorker, coreNetwork,
|
||||
coreCFFParser, displayAPI, displayMetadata, displayDOMUtils) {
|
||||
coreType1Parser, coreCFFParser, displayAPI, displayMetadata,
|
||||
displayDOMUtils) {
|
||||
|
||||
pdfjsLibs = {
|
||||
sharedUtil: sharedUtil,
|
||||
|
@ -70,6 +72,7 @@ function initializePDFJS(callback) {
|
|||
coreCMap: coreCMap,
|
||||
coreWorker: coreWorker,
|
||||
coreNetwork: coreNetwork,
|
||||
coreType1Parser: coreType1Parser,
|
||||
coreCFFParser: coreCFFParser,
|
||||
displayAPI: displayAPI,
|
||||
displayMetadata: displayMetadata,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue