A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Hopding/fontkit/commit/968e35c158589294e9543818f56d0b229b95a475 below:

Serialize trie files as JSON · Hopding/fontkit@968e35c · GitHub

File tree Expand file treeCollapse file tree 8 files changed

+70

-44

lines changed

Filter options

Expand file treeCollapse file tree 8 files changed

+70

-44

lines changed Original file line number Diff line number Diff line change

@@ -5,29 +5,29 @@ PATH := ./node_modules/.bin:$(PATH)

5 5 6 6

all: index.js base.js

7 7 8 -

src/opentype/shapers/data.trie:

8 +

src/opentype/shapers/trie.json:

9 9

babel-node src/opentype/shapers/generate-data.js

10 10 11 -

src/opentype/shapers/use.trie:

11 +

src/opentype/shapers/trieUse.json:

12 12

babel-node src/opentype/shapers/gen-use.js

13 13 14 -

src/opentype/shapers/indic.trie:

14 +

src/opentype/shapers/trieIndic.json:

15 15

babel-node src/opentype/shapers/gen-indic.js

16 16 17 -

data.trie: src/opentype/shapers/data.trie

18 -

cp src/opentype/shapers/data.trie data.trie

17 +

trie.json: src/opentype/shapers/trie.json

18 +

cp src/opentype/shapers/trie.json trie.json

19 19 20 -

use.trie: src/opentype/shapers/use.trie

21 -

cp src/opentype/shapers/use.trie use.trie

20 +

trieUse.json: src/opentype/shapers/trieUse.json

21 +

cp src/opentype/shapers/trieUse.json trieUse.json

22 22 23 -

indic.trie: src/opentype/shapers/indic.trie

24 -

cp src/opentype/shapers/indic.trie indic.trie

23 +

trieIndic.json: src/opentype/shapers/trieIndic.json

24 +

cp src/opentype/shapers/trieIndic.json trieIndic.json

25 25 26 -

index.js: $(SOURCES) data.trie use.trie indic.trie

26 +

index.js: $(SOURCES) trie.json trieUse.json trieIndic.json

27 27

rollup -c -m -i src/index.js -o index.js

28 28 29 -

base.js: $(SOURCES) data.trie use.trie indic.trie

29 +

base.js: $(SOURCES) trie.json trieUse.json trieIndic.json

30 30

rollup -c -m -i src/base.js -o base.js

31 31 32 32

clean:

33 -

rm -f index.js base.js data.trie indic.trie use.trie src/opentype/shapers/data.trie src/opentype/shapers/use.trie src/opentype/shapers/use.json src/opentype/shapers/indic.trie src/opentype/shapers/indic.json

33 +

rm -f index.js base.js trie.json trieIndic.json trieUse.json src/opentype/shapers/trie.json src/opentype/shapers/trieUse.json src/opentype/shapers/use.json src/opentype/shapers/trieIndic.json src/opentype/shapers/indic.json

Original file line number Diff line number Diff line change

@@ -1,5 +1,5 @@

1 1

import r from 'restructure';

2 -

const fs = require('fs');

2 +

// const fs = require('fs');

3 3 4 4

var fontkit = {};

5 5

export default fontkit;

@@ -11,31 +11,31 @@ fontkit.registerFormat = function(format) {

11 11

formats.push(format);

12 12

};

13 13 14 -

fontkit.openSync = function(filename, postscriptName) {

15 -

let buffer = fs.readFileSync(filename);

16 -

return fontkit.create(buffer, postscriptName);

17 -

};

18 - 19 -

fontkit.open = function(filename, postscriptName, callback) {

20 -

if (typeof postscriptName === 'function') {

21 -

callback = postscriptName;

22 -

postscriptName = null;

23 -

}

24 - 25 -

fs.readFile(filename, function(err, buffer) {

26 -

if (err) { return callback(err); }

27 - 28 -

try {

29 -

var font = fontkit.create(buffer, postscriptName);

30 -

} catch (e) {

31 -

return callback(e);

32 -

}

33 - 34 -

return callback(null, font);

35 -

});

36 - 37 -

return;

38 -

};

14 +

// fontkit.openSync = function(filename, postscriptName) {

15 +

// let buffer = fs.readFileSync(filename);

16 +

// return fontkit.create(buffer, postscriptName);

17 +

// };

18 +

//

19 +

// fontkit.open = function(filename, postscriptName, callback) {

20 +

// if (typeof postscriptName === 'function') {

21 +

// callback = postscriptName;

22 +

// postscriptName = null;

23 +

// }

24 +

//

25 +

// fs.readFile(filename, function(err, buffer) {

26 +

// if (err) { return callback(err); }

27 +

//

28 +

// try {

29 +

// var font = fontkit.create(buffer, postscriptName);

30 +

// } catch (e) {

31 +

// return callback(e);

32 +

// }

33 +

//

34 +

// return callback(null, font);

35 +

// });

36 +

//

37 +

// return;

38 +

// };

39 39 40 40

fontkit.create = function(buffer, postscriptName) {

41 41

for (let i = 0; i < formats.length; i++) {

Original file line number Diff line number Diff line change

@@ -2,7 +2,12 @@ import DefaultShaper from './DefaultShaper';

2 2

import unicode from 'unicode-properties';

3 3

import UnicodeTrie from 'unicode-trie';

4 4 5 -

const trie = new UnicodeTrie(require('fs').readFileSync(__dirname + '/data.trie'));

5 +

// Trie is serialized as a Buffer in node, but here

6 +

// we may be running in a browser so we make an Uint8Array

7 +

const trieBuffer = require('./trieData.json');

8 +

const trieData = new Uint8Array(trieBuffer.data);

9 +

const trie = new UnicodeTrie(trieData);

10 +

// const trie = new UnicodeTrie(require('fs').readFileSync(__dirname + '/data.trie'));

6 11

const FEATURES = ['isol', 'fina', 'fin2', 'fin3', 'medi', 'med2', 'init'];

7 12 8 13

const ShapingClasses = {

Original file line number Diff line number Diff line change

@@ -16,7 +16,13 @@ import {

16 16

} from './indic-data';

17 17 18 18

const {decompositions} = useData;

19 -

const trie = new UnicodeTrie(require('fs').readFileSync(__dirname + '/indic.trie'));

19 + 20 +

// Trie is serialized as a Buffer in node, but here

21 +

// we may be running in a browser so we make an Uint8Array

22 +

const trieBuffer = require('./trieIndic.json');

23 +

const trieData = new Uint8Array(trieBuffer.data);

24 +

const trie = new UnicodeTrie(trieData);

25 +

// const trie = new UnicodeTrie(require('fs').readFileSync(__dirname + '/indic.trie'));

20 26

const stateMachine = new StateMachine(indicMachine);

21 27 22 28

/**

Original file line number Diff line number Diff line change

@@ -5,7 +5,13 @@ import GlyphInfo from '../GlyphInfo';

5 5

import useData from './use.json';

6 6 7 7

const {categories, decompositions} = useData;

8 -

const trie = new UnicodeTrie(require('fs').readFileSync(__dirname + '/use.trie'));

8 + 9 +

// Trie is serialized as a Buffer in node, but here

10 +

// we may be running in a browser so we make an Uint8Array

11 +

const trieBuffer = require('./trieUse.json');

12 +

const trieData = new Uint8Array(trieBuffer.data);

13 +

const trie = new UnicodeTrie(trieData);

14 +

// const trie = new UnicodeTrie(require('fs').readFileSync(__dirname + '/use.trie'));

9 15

const stateMachine = new StateMachine(useData);

10 16 11 17

/**

Original file line number Diff line number Diff line change

@@ -200,7 +200,10 @@ for (let i = 0; i < codepoints.length; i++) {

200 200

}

201 201

}

202 202 203 -

fs.writeFileSync(__dirname + '/indic.trie', trie.toBuffer());

203 +

// Trie is serialized suboptimally as JSON so it can be loaded via require,

204 +

// allowing unicode-properties to work in the browser

205 +

fs.writeFileSync(__dirname + '/trieIndic.json', JSON.stringify(trie.toBuffer()));

206 +

// fs.writeFileSync(__dirname + '/indic.trie', trie.toBuffer());

204 207 205 208

let stateMachine = compile(fs.readFileSync(__dirname + '/indic.machine', 'utf8'), symbols);

206 209

fs.writeFileSync(__dirname + '/indic.json', JSON.stringify(stateMachine));

Original file line number Diff line number Diff line change

@@ -274,7 +274,10 @@ function decompose(code) {

274 274

return decomposition;

275 275

}

276 276 277 -

fs.writeFileSync(__dirname + '/use.trie', trie.toBuffer());

277 +

// Trie is serialized suboptimally as JSON so it can be loaded via require,

278 +

// allowing unicode-properties to work in the browser

279 +

fs.writeFileSync(__dirname + '/trieUse.json', JSON.stringify(trie.toBuffer()));

280 +

// fs.writeFileSync(__dirname + '/use.trie', trie.toBuffer());

278 281 279 282

let stateMachine = compile(fs.readFileSync(__dirname + '/use.machine', 'utf8'), symbols);

280 283

let json = Object.assign({

Original file line number Diff line number Diff line change

@@ -30,4 +30,7 @@ for (let i = 0; i < codepoints.length; i++) {

30 30

}

31 31

}

32 32 33 -

fs.writeFileSync(__dirname + '/data.trie', trie.toBuffer());

33 +

// Trie is serialized suboptimally as JSON so it can be loaded via require,

34 +

// allowing unicode-properties to work in the browser

35 +

fs.writeFileSync(__dirname + '/trie.json', JSON.stringify(trie.toBuffer()));

36 +

// fs.writeFileSync(__dirname + '/data.trie', trie.toBuffer());

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4