Skip to content

Commit 00233dd

Browse files
committed
remove debug info of woff2
1 parent d676f12 commit 00233dd

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fonteditor-core",
3-
"version": "2.0.7",
3+
"version": "2.1.0",
44
"description": "fonts (ttf, woff, woff2, eot, svg, otf) parse, write, transform, glyph adjust.",
55
"keywords": [
66
"sfnt",
@@ -34,7 +34,7 @@
3434
}
3535
],
3636
"scripts": {
37-
"publish:npm": "npm run build && npm publish",
37+
"publish:npm": "npm run build && npm publish --registry=https://registry.npmjs.org/",
3838
"test": "./node_modules/.bin/mocha --require @babel/register test/spec/*.spec.js test/spec/**/*.spec.js",
3939
"test:node": "npm run build && ./node_modules/mocha/bin/mocha test/node-spec/**/*.spec.js ",
4040
"dev": "webpack-dev-server --open --config ./config/webpack.dev.js",
@@ -65,6 +65,7 @@
6565
"css-loader": "^3.2.0",
6666
"html-webpack-plugin": "^3.2.0",
6767
"mocha": "^6.2.1",
68+
"pako": "^1.0.10",
6869
"style-loader": "^1.0.0",
6970
"webpack": "^4.41.1",
7071
"webpack-cli": "^3.3.9",

test/spec/ttf/ttf2woff.spec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {readData} from '../data';
88
import TTFReader from 'fonteditor-core/ttf/ttfreader';
99
import ttf2woff from 'fonteditor-core/ttf/ttf2woff';
1010
import woff2ttf from 'fonteditor-core/ttf/woff2ttf';
11+
import pako from 'pako';
12+
import { fstat } from 'fs';
1113

1214
describe('ttf 转 woff', function () {
1315

@@ -48,3 +50,49 @@ describe('ttf 转 woff', function () {
4850
assert.equal(ttf.cmap[57400], 16);
4951
});
5052
});
53+
54+
55+
describe('ttf 转 woff with deflate', function () {
56+
57+
let woffBuffer = ttf2woff(readData('baiduHealth.ttf'), {
58+
deflate: pako.deflate
59+
});
60+
61+
it('test woff format', function () {
62+
assert.ok(woffBuffer.byteLength > 1000);
63+
assert.ok(woffBuffer.byteLength < 10000);
64+
});
65+
require('fs').writeFileSync('baiduHealth-deflate.woff', Buffer.from(woffBuffer));
66+
it('test read woff', function () {
67+
let ttfBuffer = woff2ttf(woffBuffer, {
68+
inflate: pako.inflate
69+
});
70+
let ttf = new TTFReader().read(ttfBuffer);
71+
72+
assert.equal(ttf.version, 1);
73+
74+
assert.equal(ttf.head.magickNumber, 1594834165);
75+
assert.equal(ttf.head.unitsPerEm, 512);
76+
77+
assert.equal(ttf.post.format, 2);
78+
assert.equal(ttf.post.underlinePosition, 0);
79+
assert.equal(ttf.post.underlineThickness, 0);
80+
81+
assert.equal(ttf.hhea.advanceWidthMax, 682);
82+
assert.equal(ttf.hhea.ascent, 480);
83+
assert.equal(ttf.hhea.descent, -33);
84+
85+
assert.equal(ttf.maxp.version, 1);
86+
assert.equal(ttf.maxp.numGlyphs, 17);
87+
88+
assert.equal(ttf.glyf[0].advanceWidth, 512);
89+
assert.equal(ttf.glyf[0].leftSideBearing, 0);
90+
assert.equal(ttf.glyf[0].name, '.notdef');
91+
assert.equal(ttf.glyf[3].contours[0].length, 31);
92+
assert.equal(ttf.glyf[16].compound, true);
93+
assert.equal(ttf.glyf[16].glyfs.length, 2);
94+
95+
assert.equal(ttf.cmap[0], 1);
96+
assert.equal(ttf.cmap[57400], 16);
97+
});
98+
});

woff2/woff2.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

woff2/woff2.wasm

-1.97 KB
Binary file not shown.

0 commit comments

Comments
 (0)