Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use beforeAll/afterAll in font_spec.js (issue 6905) #7175

Merged
merged 1 commit into from
Apr 11, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 41 additions & 27 deletions test/unit/font_spec.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
/* globals expect, it, describe, CFFCompiler, CFFParser, CFFIndex, CFFStrings,
Type1Parser, StringStream, SEAC_ANALYSIS_ENABLED */
Type1Parser, StringStream, SEAC_ANALYSIS_ENABLED, Stream, beforeAll,
afterAll */

'use strict';

describe('font', function() {
// This example font comes from the CFF spec:
// http://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5176.CFF.pdf
var exampleFont = '0100040100010101134142434445462b' +
'54696d65732d526f6d616e000101011f' +
'f81b00f81c02f81d03f819041c6f000d' +
'fb3cfb6efa7cfa1605e911b8f1120003' +
'01010813183030312e30303754696d65' +
'7320526f6d616e54696d657300000002' +
'010102030e0e7d99f92a99fb7695f773' +
'8b06f79a93fc7c8c077d99f85695f75e' +
'9908fb6e8cf87393f7108b09a70adf0b' +
'f78e14';
var fontData = [];
for (var i = 0; i < exampleFont.length; i += 2) {
var hex = exampleFont.substr(i, 2);
fontData.push(parseInt(hex, 16));
}
var bytes = new Uint8Array(fontData);
fontData = {
getBytes: function() {
return bytes;
}
};

function createWithNullProto(obj) {
var result = Object.create(null);
for (var i in obj) {
Expand All @@ -36,9 +13,46 @@ describe('font', function() {
return result;
}

var fontData;

beforeAll(function (done) {
// This example font comes from the CFF spec:
// http://www.adobe.com/content/dam/Adobe/en/devnet/font/pdfs/5176.CFF.pdf
var exampleFont = '0100040100010101134142434445462b' +
'54696d65732d526f6d616e000101011f' +
'f81b00f81c02f81d03f819041c6f000d' +
'fb3cfb6efa7cfa1605e911b8f1120003' +
'01010813183030312e30303754696d65' +
'7320526f6d616e54696d657300000002' +
'010102030e0e7d99f92a99fb7695f773' +
'8b06f79a93fc7c8c077d99f85695f75e' +
'9908fb6e8cf87393f7108b09a70adf0b' +
'f78e14';
var fontArr = [];
for (var i = 0, ii = exampleFont.length; i < ii; i += 2) {
var hex = exampleFont.substr(i, 2);
fontArr.push(parseInt(hex, 16));
}
fontData = new Stream(fontArr);
done();
});

afterAll(function () {
fontData = null;
});

describe('CFFParser', function() {
var parser = new CFFParser(fontData, {}, SEAC_ANALYSIS_ENABLED);
var cff = parser.parse();
var parser, cff;

beforeAll(function (done) {
parser = new CFFParser(fontData, {}, SEAC_ANALYSIS_ENABLED);
cff = parser.parse();
done();
});

afterAll(function () {
parser = cff = null;
});

it('parses header', function() {
var header = cff.header;
Expand Down