@ot-builder/io-bin-name 1.7.9 → 1.8.0
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/lib/main/index.d.ts +3 -3
- package/lib/meta/index.d.ts +1 -1
- package/lib/meta/index.js +4 -3
- package/lib/name/index.d.ts +1 -1
- package/lib/name/index.js +10 -8
- package/lib/stat/read.js +2 -1
- package/lib/stat/write.js +2 -1
- package/package.json +15 -15
package/lib/main/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SfntIoTableSink } from "@ot-builder/io-bin-sfnt";
|
|
2
|
-
import { OtNameData } from "@ot-builder/ot-name";
|
|
3
|
-
import { Sfnt } from "@ot-builder/ot-sfnt";
|
|
1
|
+
import type { SfntIoTableSink } from "@ot-builder/io-bin-sfnt";
|
|
2
|
+
import { type OtNameData } from "@ot-builder/ot-name";
|
|
3
|
+
import type { Sfnt } from "@ot-builder/ot-sfnt";
|
|
4
4
|
export declare function readNames(sfnt: Sfnt): OtNameData;
|
|
5
5
|
export declare function writeNames(sink: SfntIoTableSink, nd: OtNameData): void;
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/meta/index.d.ts
CHANGED
package/lib/meta/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MetaTableIo = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const errors_1 = require("@ot-builder/errors");
|
|
5
6
|
const ot_name_1 = require("@ot-builder/ot-name");
|
|
6
7
|
const primitive_1 = require("@ot-builder/primitive");
|
|
7
|
-
const
|
|
8
|
+
const iconv_lite_1 = tslib_1.__importDefault(require("iconv-lite"));
|
|
8
9
|
exports.MetaTableIo = {
|
|
9
10
|
read(view) {
|
|
10
11
|
const version = view.uint32();
|
|
@@ -25,7 +26,7 @@ const DataMap = {
|
|
|
25
26
|
const vwData = view.ptr32();
|
|
26
27
|
const dataLength = view.uint32();
|
|
27
28
|
if (KnownTextTags.has(tag)) {
|
|
28
|
-
return [tag,
|
|
29
|
+
return [tag, iconv_lite_1.default.decode(vwData.bytes(dataLength), KnownTextTags.get(tag))];
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
31
32
|
return [tag, vwData.bytes(dataLength)];
|
|
@@ -35,7 +36,7 @@ const DataMap = {
|
|
|
35
36
|
frag.push(primitive_1.Tag, tag);
|
|
36
37
|
const fData = frag.ptr32New();
|
|
37
38
|
if (typeof data === "string") {
|
|
38
|
-
const bufData =
|
|
39
|
+
const bufData = iconv_lite_1.default.encode(data, KnownTextTags.get(tag) || "utf8");
|
|
39
40
|
fData.bytes(bufData);
|
|
40
41
|
frag.uint32(bufData.byteLength);
|
|
41
42
|
}
|
package/lib/name/index.d.ts
CHANGED
package/lib/name/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NameIo = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const bin_util_1 = require("@ot-builder/bin-util");
|
|
5
6
|
const errors_1 = require("@ot-builder/errors");
|
|
6
7
|
const ot_name_1 = require("@ot-builder/ot-name");
|
|
7
|
-
const
|
|
8
|
+
const iconv_lite_1 = tslib_1.__importDefault(require("iconv-lite"));
|
|
8
9
|
// TODO: add more encodings
|
|
9
10
|
function SupportedEncoding(platformID, encodingID) {
|
|
10
11
|
if (platformID === 3 && encodingID === 1)
|
|
@@ -42,7 +43,7 @@ const NameRecord = {
|
|
|
42
43
|
const offset = view.uint16();
|
|
43
44
|
const buf = Buffer.from(strings.lift(offset).bytes(length));
|
|
44
45
|
const encName = SupportedEncoding(platformID, encodingID);
|
|
45
|
-
const value = encName ?
|
|
46
|
+
const value = encName ? iconv_lite_1.default.decode(buf, encName) : buf;
|
|
46
47
|
return { platformID, encodingID, languageID, nameID, value };
|
|
47
48
|
},
|
|
48
49
|
write(frag, rec, alloc) {
|
|
@@ -54,7 +55,7 @@ const NameRecord = {
|
|
|
54
55
|
if (typeof rec.value === "string") {
|
|
55
56
|
const enc = SupportedEncoding(rec.platformID, rec.encodingID);
|
|
56
57
|
if (enc)
|
|
57
|
-
buf =
|
|
58
|
+
buf = iconv_lite_1.default.encode(rec.value, enc);
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
61
|
buf = rec.value;
|
|
@@ -79,10 +80,10 @@ const LangTagRecord = {
|
|
|
79
80
|
const length = view.uint16();
|
|
80
81
|
const offset = view.uint16();
|
|
81
82
|
const buf = Buffer.from(strings.lift(offset).bytes(length));
|
|
82
|
-
return
|
|
83
|
+
return iconv_lite_1.default.decode(buf, `utf16-be`);
|
|
83
84
|
},
|
|
84
85
|
write(frag, ltr, alloc) {
|
|
85
|
-
const buf =
|
|
86
|
+
const buf = iconv_lite_1.default.encode(ltr, `utf16-be`);
|
|
86
87
|
frag.uint16(buf.byteLength);
|
|
87
88
|
frag.uint16(alloc.add(buf));
|
|
88
89
|
}
|
|
@@ -107,7 +108,8 @@ exports.NameIo = {
|
|
|
107
108
|
return table;
|
|
108
109
|
},
|
|
109
110
|
write(frag, table) {
|
|
110
|
-
|
|
111
|
+
var _a, _b;
|
|
112
|
+
const format = ((_a = table.langTagMap) === null || _a === void 0 ? void 0 : _a.length) ? 1 : 0;
|
|
111
113
|
const frStrings = new bin_util_1.Frag();
|
|
112
114
|
const noa = new NameOffsetAllocator();
|
|
113
115
|
const sortedRecords = Array.from(table.records).sort(NameRecord.compare);
|
|
@@ -118,13 +120,13 @@ exports.NameIo = {
|
|
|
118
120
|
frag.push(NameRecord, rec, noa);
|
|
119
121
|
}
|
|
120
122
|
if (format === 1) {
|
|
121
|
-
if (!table.langTagMap ||
|
|
123
|
+
if (!((_b = table.langTagMap) === null || _b === void 0 ? void 0 : _b.length))
|
|
122
124
|
throw errors_1.Errors.Unreachable();
|
|
123
125
|
frag.uint16(table.langTagMap.length);
|
|
124
126
|
for (const lt of table.langTagMap)
|
|
125
127
|
frag.push(LangTagRecord, lt, noa);
|
|
126
128
|
}
|
|
127
|
-
noa.add(
|
|
129
|
+
noa.add(iconv_lite_1.default.encode("\n", "utf-8")); // Ensure that the frStrings will not be empty
|
|
128
130
|
frStrings.bytes(noa.getBuffer());
|
|
129
131
|
}
|
|
130
132
|
};
|
package/lib/stat/read.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatRead = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const bin_util_1 = require("@ot-builder/bin-util");
|
|
5
|
-
const ImpLib = require("@ot-builder/common-impl");
|
|
6
|
+
const ImpLib = tslib_1.__importStar(require("@ot-builder/common-impl"));
|
|
6
7
|
const errors_1 = require("@ot-builder/errors");
|
|
7
8
|
const ot_name_1 = require("@ot-builder/ot-name");
|
|
8
9
|
const primitive_1 = require("@ot-builder/primitive");
|
package/lib/stat/write.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatWrite = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const bin_util_1 = require("@ot-builder/bin-util");
|
|
5
|
-
const ImpLib = require("@ot-builder/common-impl");
|
|
6
|
+
const ImpLib = tslib_1.__importStar(require("@ot-builder/common-impl"));
|
|
6
7
|
const errors_1 = require("@ot-builder/errors");
|
|
7
8
|
const ot_name_1 = require("@ot-builder/ot-name");
|
|
8
9
|
const primitive_1 = require("@ot-builder/primitive");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ot-builder/io-bin-name",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,23 +23,23 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ot-builder/bin-util": "1.
|
|
27
|
-
"@ot-builder/common-impl": "1.
|
|
28
|
-
"@ot-builder/errors": "1.
|
|
29
|
-
"@ot-builder/ot-glyphs": "1.
|
|
30
|
-
"@ot-builder/ot-metadata": "1.
|
|
31
|
-
"@ot-builder/ot-name": "1.
|
|
32
|
-
"@ot-builder/prelude": "1.
|
|
33
|
-
"@ot-builder/primitive": "1.
|
|
34
|
-
"@ot-builder/ot-sfnt": "1.
|
|
35
|
-
"@ot-builder/io-bin-sfnt": "1.
|
|
36
|
-
"iconv-lite": "0.7.
|
|
26
|
+
"@ot-builder/bin-util": "1.8.0",
|
|
27
|
+
"@ot-builder/common-impl": "1.8.0",
|
|
28
|
+
"@ot-builder/errors": "1.8.0",
|
|
29
|
+
"@ot-builder/ot-glyphs": "1.8.0",
|
|
30
|
+
"@ot-builder/ot-metadata": "1.8.0",
|
|
31
|
+
"@ot-builder/ot-name": "1.8.0",
|
|
32
|
+
"@ot-builder/prelude": "1.8.0",
|
|
33
|
+
"@ot-builder/primitive": "1.8.0",
|
|
34
|
+
"@ot-builder/ot-sfnt": "1.8.0",
|
|
35
|
+
"@ot-builder/io-bin-sfnt": "1.8.0",
|
|
36
|
+
"iconv-lite": "^0.7.2",
|
|
37
37
|
"tslib": "^2.8.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ot-builder/io-bin-glyph-store": "1.
|
|
41
|
-
"@ot-builder/io-bin-metadata": "1.
|
|
42
|
-
"@ot-builder/test-util": "1.
|
|
40
|
+
"@ot-builder/io-bin-glyph-store": "1.9.0",
|
|
41
|
+
"@ot-builder/io-bin-metadata": "1.8.0",
|
|
42
|
+
"@ot-builder/test-util": "1.8.0",
|
|
43
43
|
"@types/jest": "^30.0.0",
|
|
44
44
|
"jest": "^30.2.0"
|
|
45
45
|
}
|