Skip to content

Commit c4b84d0

Browse files
committed
Add tests for CFF table building
1 parent 2c15a9b commit c4b84d0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/tables/cff.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import assert from 'assert';
2+
import { hex } from '../testutil';
3+
import Glyph from '../../src/glyph';
4+
import glyphset from '../../src/glyphset';
5+
import Path from '../../src/path';
6+
import cff from '../../src/tables/cff';
7+
8+
describe('tables/cff.js', function () {
9+
const data =
10+
'01 00 04 01 00 01 01 01 03 70 73 00 01 01 01 32 ' +
11+
'F8 1B 00 F8 1C 02 F8 1C 03 F8 1D 04 1D 00 00 00 ' +
12+
'55 0F 1D 00 00 00 58 11 8B 1D 00 00 00 80 12 1E ' +
13+
'0A 12 5F 1E 0F 1E 0F 1E 0A 12 5F 1E 0F 1E 0F 0C ' +
14+
'07 00 04 01 01 02 04 06 0B 30 66 6E 77 6E 62 75 ' +
15+
'6D 70 73 00 00 00 01 8A 00 02 01 01 03 23 9B 0E ' +
16+
'9B 8B 8B 15 8C 8D 8B 8B 8C 89 08 89 8B 15 8C 8D ' +
17+
'8B 8B 8C 89 08 89 8B 15 8C 8D 8B 8B 8C 89 08 0E';
18+
19+
it('can make a cff tag table', function () {
20+
const options = {
21+
unitsPerEm: 8,
22+
version: '0',
23+
fullName: 'fn',
24+
postScriptName: 'ps',
25+
familyName: 'fn',
26+
weightName: 'wn',
27+
fontBBox: [0, 0, 0, 0],
28+
};
29+
const path = new Path();
30+
path.moveTo(0, 0);
31+
path.quadraticCurveTo(1, 3, 2, 0);
32+
path.moveTo(0, 0);
33+
path.quadraticCurveTo(1, 3, 2, 0);
34+
path.moveTo(0, 0);
35+
path.quadraticCurveTo(1, 3, 2, 0);
36+
const bumpsGlyph = new Glyph({ name: 'bumps', path, advanceWidth: 16 });
37+
const nodefGlyph = new Glyph({ name: 'nodef', path: new Path(), advanceWidth: 16 });
38+
const glyphSetFont = { unitsPerEm: 8 };
39+
const glyphs = new glyphset.GlyphSet(glyphSetFont, [nodefGlyph, bumpsGlyph]);
40+
41+
assert.deepEqual(data, hex(cff.make(glyphs, options).encode()));
42+
});
43+
44+
});

0 commit comments

Comments
 (0)