ttf2woff2 1.2.3 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +26 -16
- package/README.md +2 -2
- package/binding.gyp +3 -0
- package/build/Makefile +2 -2
- package/build/Release/.deps/Release/obj.target/addon/csrc/addon.o.d +54 -17
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/backward_references.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/block_splitter.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/brotli_bit_stream.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/encode.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/encode_parallel.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/entropy_encode.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/histogram.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/literal_cost.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/metablock.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/enc/streams.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/font.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/glyph.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/normalize.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/table_tags.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/transform.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/variable_length.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/woff2_common.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon/csrc/woff2/woff2_enc.o.d +1 -1
- package/build/Release/.deps/Release/obj.target/addon.node.d +1 -1
- package/build/Release/addon.node +0 -0
- package/build/Release/obj.target/addon/csrc/addon.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/backward_references.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/block_splitter.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/brotli_bit_stream.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/encode.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/encode_parallel.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/entropy_encode.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/histogram.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/literal_cost.o +0 -0
- package/build/Release/obj.target/addon/csrc/enc/metablock.o +0 -0
- package/build/Release/obj.target/addon/csrc/woff2/font.o +0 -0
- package/build/Release/obj.target/addon/csrc/woff2/glyph.o +0 -0
- package/build/Release/obj.target/addon/csrc/woff2/normalize.o +0 -0
- package/build/Release/obj.target/addon/csrc/woff2/transform.o +0 -0
- package/build/Release/obj.target/addon/csrc/woff2/variable_length.o +0 -0
- package/build/Release/obj.target/addon/csrc/woff2/woff2_enc.o +0 -0
- package/build/Release/obj.target/addon.node +0 -0
- package/build/addon.target.mk +10 -8
- package/csrc/addon.cc +28 -43
- package/csrc/fallback.cc +35 -17
- package/csrc/woff2/port.h +2 -0
- package/jssrc/index.js +7 -9
- package/jssrc/ttf2woff2.js +8 -8
- package/package.json +14 -11
- package/tests/tests.mocha.js +15 -3
- package/build/Release/linker.lock +0 -0
- package/builderror.log +0 -24
package/csrc/fallback.cc
CHANGED
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
// Emscripten wrapper
|
|
2
|
-
|
|
2
|
+
#include <emscripten/bind.h>
|
|
3
3
|
#include <stdlib.h>
|
|
4
4
|
#include "./woff2/woff2_enc.h"
|
|
5
5
|
|
|
6
|
+
using namespace emscripten;
|
|
6
7
|
using std::string;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
int getSizePtr() {
|
|
10
|
+
int* sizePtr = reinterpret_cast<int*>(calloc(1, sizeof(int)));
|
|
11
|
+
return reinterpret_cast<int>(sizePtr);
|
|
12
|
+
}
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
int convert(int inputDataAddress, int inputLength, int outputSizePtrAddress) {
|
|
15
|
+
int* outputSizePtr = reinterpret_cast<int*>(outputSizePtrAddress);
|
|
16
|
+
char* inputData = reinterpret_cast<char*>(inputDataAddress);
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
size_t outputSize = woff2::MaxWOFF2CompressedSize(
|
|
19
|
+
reinterpret_cast<const uint8_t*>(inputData),
|
|
20
|
+
inputLength
|
|
21
|
+
);
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
uint8_t* outputData = reinterpret_cast<uint8_t*>(calloc(outputSize, sizeof(uint8_t)));
|
|
17
24
|
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
if(!woff2::ConvertTTFToWOFF2(
|
|
27
|
+
reinterpret_cast<const uint8_t*>(inputData),
|
|
28
|
+
inputLength,
|
|
29
|
+
outputData,
|
|
30
|
+
&outputSize
|
|
31
|
+
)) {
|
|
32
|
+
// throw an error
|
|
33
|
+
}
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
*outputSizePtr = outputSize;
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
return reinterpret_cast<int>(outputData);
|
|
38
|
+
}
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
void freePtrs(int outputDataAddress, int sizePtrAddress) {
|
|
41
|
+
int* sizePtr = reinterpret_cast<int*>(sizePtrAddress);
|
|
42
|
+
char* outputData = reinterpret_cast<char*>(outputDataAddress);
|
|
43
|
+
free(outputData);
|
|
44
|
+
free(sizePtr);
|
|
45
|
+
}
|
|
32
46
|
|
|
47
|
+
EMSCRIPTEN_BINDINGS(ttf2woff2_fallback) {
|
|
48
|
+
function("getSizePtr", &getSizePtr, allow_raw_pointers());
|
|
49
|
+
function("convert", &convert, allow_raw_pointers());
|
|
50
|
+
function("freePtrs", &freePtrs, allow_raw_pointers());
|
|
33
51
|
}
|
package/csrc/woff2/port.h
CHANGED
package/jssrc/index.js
CHANGED
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
var theTTFToWOFF2Module = require('./ttf2woff2');
|
|
4
4
|
|
|
5
5
|
module.exports = function ttf2woff2(inputContent) {
|
|
6
|
-
var outputSize;
|
|
7
|
-
var outputContent;
|
|
8
|
-
var outputBufferPtr;
|
|
9
|
-
var i;
|
|
10
6
|
|
|
11
7
|
// Prepare input
|
|
12
8
|
var inputBuffer = theTTFToWOFF2Module._malloc(inputContent.length + 1);
|
|
13
9
|
var outputSizePtr = theTTFToWOFF2Module._malloc(4);
|
|
10
|
+
var outputBufferPtr;
|
|
11
|
+
var outputSize;
|
|
12
|
+
var outputContent;
|
|
13
|
+
var i;
|
|
14
14
|
|
|
15
15
|
theTTFToWOFF2Module.writeArrayToMemory(inputContent, inputBuffer);
|
|
16
16
|
|
|
17
17
|
// Run
|
|
18
|
-
outputBufferPtr = theTTFToWOFF2Module.
|
|
19
|
-
inputBuffer, inputContent.length
|
|
18
|
+
outputBufferPtr = theTTFToWOFF2Module.convert(
|
|
19
|
+
inputBuffer, inputContent.length, outputSizePtr
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
// Retrieve output
|
|
@@ -27,9 +27,7 @@ module.exports = function ttf2woff2(inputContent) {
|
|
|
27
27
|
outputContent[i] = theTTFToWOFF2Module.getValue(outputBufferPtr + i, 'i8');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
theTTFToWOFF2Module.
|
|
31
|
-
theTTFToWOFF2Module._free(outputSizePtr);
|
|
32
|
-
theTTFToWOFF2Module._freeTTFToWOFF2(outputBufferPtr);
|
|
30
|
+
theTTFToWOFF2Module.freePtrs(outputBufferPtr, outputSizePtr);
|
|
33
31
|
|
|
34
32
|
return outputContent;
|
|
35
33
|
};
|