fontconv 0.0.2 → 0.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/README.md +2 -2
- package/esm/cli.js +1 -1
- package/esm/ligature.js +11 -3
- package/package.json +2 -2
- package/script/cli.js +1 -1
- package/script/ligature.js +11 -3
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Convert and compress fonts (.ttf, .otf, .eot, .svg, .woff, .woff2).
|
|
|
7
7
|
### Deno
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
deno install -fr --allow-read --allow-write --name fontconv \
|
|
10
|
+
deno install -fr --allow-read --allow-write --name fontconv -g \
|
|
11
11
|
https://raw.githubusercontent.com/marmooo/fontconv/main/cli.js
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -64,7 +64,7 @@ fontconv --code 0x61,98 in.ttf out.woff2
|
|
|
64
64
|
fontconv --code-file codepoints.lst in.ttf out.woff2
|
|
65
65
|
fontconv --name alarm.box in.otf out.woff
|
|
66
66
|
fontconv --name-file names.lst in.otf out.woff
|
|
67
|
-
fontconv --ligature --remove-ligatures
|
|
67
|
+
fontconv --ligature home,menu --remove-ligatures in.otf out.woff
|
|
68
68
|
fontconv --ligature-file ligatures.lst in.otf out.woff
|
|
69
69
|
```
|
|
70
70
|
|
package/esm/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ const program = new Command();
|
|
|
7
7
|
program
|
|
8
8
|
.name("fontconv")
|
|
9
9
|
.description("Convert and compress fonts (.ttf, .otf, .eot, .svg, .woff, .woff2).")
|
|
10
|
-
.version("0.0.
|
|
10
|
+
.version("0.0.3");
|
|
11
11
|
program
|
|
12
12
|
.argument("<input>", "Path of input font file")
|
|
13
13
|
.argument("<output>", "Path of output font file")
|
package/esm/ligature.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
function* parseCoverageFormat1(subtable, reverseGlyphIndexMap) {
|
|
2
|
+
if (!subtable.ligatureSets)
|
|
3
|
+
return;
|
|
2
4
|
for (let i = 0; i < subtable.ligatureSets.length; i++) {
|
|
3
5
|
for (const ligature of subtable.ligatureSets[i]) {
|
|
4
6
|
const initialIndex = subtable.coverage.glyphs[i];
|
|
@@ -14,6 +16,8 @@ function* parseCoverageFormat1(subtable, reverseGlyphIndexMap) {
|
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
function* parseCoverageFormat2(subtable, reverseGlyphIndexMap) {
|
|
19
|
+
if (!subtable.ligatureSets)
|
|
20
|
+
return;
|
|
17
21
|
const coverage2 = [];
|
|
18
22
|
subtable.coverage.ranges.forEach((coverage) => {
|
|
19
23
|
for (let c = coverage.start; c <= coverage.end; c++) {
|
|
@@ -36,7 +40,8 @@ function* parseCoverageFormat2(subtable, reverseGlyphIndexMap) {
|
|
|
36
40
|
// https://github.com/opentypejs/opentype.js/issues/384
|
|
37
41
|
// https://jsfiddle.net/nvbajtmo/
|
|
38
42
|
export function* parseLigatures(font) {
|
|
39
|
-
|
|
43
|
+
const gsub = font.tables.gsub;
|
|
44
|
+
if (!gsub)
|
|
40
45
|
return;
|
|
41
46
|
const glyphIndexMap = font.tables.cmap.glyphIndexMap;
|
|
42
47
|
const reverseGlyphIndexMap = {};
|
|
@@ -44,9 +49,12 @@ export function* parseLigatures(font) {
|
|
|
44
49
|
const value = glyphIndexMap[codePoint];
|
|
45
50
|
reverseGlyphIndexMap[value] = codePoint;
|
|
46
51
|
});
|
|
47
|
-
for (const lookup of
|
|
52
|
+
for (const lookup of gsub.lookups) {
|
|
48
53
|
for (const subtable of lookup.subtables) {
|
|
49
|
-
|
|
54
|
+
const coverage = subtable.coverage;
|
|
55
|
+
if (!coverage)
|
|
56
|
+
continue;
|
|
57
|
+
if (coverage.format === 1) {
|
|
50
58
|
yield* parseCoverageFormat1(subtable, reverseGlyphIndexMap);
|
|
51
59
|
}
|
|
52
60
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fontconv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Convert and compress fonts (.ttf, .otf, .eot, .svg, .woff, .woff2).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"fontconv": "./esm/cli.js"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@marmooo/ttf2svg": "0.2.
|
|
28
|
+
"@marmooo/ttf2svg": "0.2.1",
|
|
29
29
|
"commander": "12.0.0",
|
|
30
30
|
"opentype.js": "1.3.4",
|
|
31
31
|
"svg2ttf": "6.0.3",
|
package/script/cli.js
CHANGED
|
@@ -32,7 +32,7 @@ const program = new commander_1.Command();
|
|
|
32
32
|
program
|
|
33
33
|
.name("fontconv")
|
|
34
34
|
.description("Convert and compress fonts (.ttf, .otf, .eot, .svg, .woff, .woff2).")
|
|
35
|
-
.version("0.0.
|
|
35
|
+
.version("0.0.3");
|
|
36
36
|
program
|
|
37
37
|
.argument("<input>", "Path of input font file")
|
|
38
38
|
.argument("<output>", "Path of output font file")
|
package/script/ligature.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLigatureMap = exports.parseLigatures = void 0;
|
|
4
4
|
function* parseCoverageFormat1(subtable, reverseGlyphIndexMap) {
|
|
5
|
+
if (!subtable.ligatureSets)
|
|
6
|
+
return;
|
|
5
7
|
for (let i = 0; i < subtable.ligatureSets.length; i++) {
|
|
6
8
|
for (const ligature of subtable.ligatureSets[i]) {
|
|
7
9
|
const initialIndex = subtable.coverage.glyphs[i];
|
|
@@ -17,6 +19,8 @@ function* parseCoverageFormat1(subtable, reverseGlyphIndexMap) {
|
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
function* parseCoverageFormat2(subtable, reverseGlyphIndexMap) {
|
|
22
|
+
if (!subtable.ligatureSets)
|
|
23
|
+
return;
|
|
20
24
|
const coverage2 = [];
|
|
21
25
|
subtable.coverage.ranges.forEach((coverage) => {
|
|
22
26
|
for (let c = coverage.start; c <= coverage.end; c++) {
|
|
@@ -39,7 +43,8 @@ function* parseCoverageFormat2(subtable, reverseGlyphIndexMap) {
|
|
|
39
43
|
// https://github.com/opentypejs/opentype.js/issues/384
|
|
40
44
|
// https://jsfiddle.net/nvbajtmo/
|
|
41
45
|
function* parseLigatures(font) {
|
|
42
|
-
|
|
46
|
+
const gsub = font.tables.gsub;
|
|
47
|
+
if (!gsub)
|
|
43
48
|
return;
|
|
44
49
|
const glyphIndexMap = font.tables.cmap.glyphIndexMap;
|
|
45
50
|
const reverseGlyphIndexMap = {};
|
|
@@ -47,9 +52,12 @@ function* parseLigatures(font) {
|
|
|
47
52
|
const value = glyphIndexMap[codePoint];
|
|
48
53
|
reverseGlyphIndexMap[value] = codePoint;
|
|
49
54
|
});
|
|
50
|
-
for (const lookup of
|
|
55
|
+
for (const lookup of gsub.lookups) {
|
|
51
56
|
for (const subtable of lookup.subtables) {
|
|
52
|
-
|
|
57
|
+
const coverage = subtable.coverage;
|
|
58
|
+
if (!coverage)
|
|
59
|
+
continue;
|
|
60
|
+
if (coverage.format === 1) {
|
|
53
61
|
yield* parseCoverageFormat1(subtable, reverseGlyphIndexMap);
|
|
54
62
|
}
|
|
55
63
|
else {
|