Skip to content

Commit d06d278

Browse files
authored
Merge pull request #5569 from Tyriar/5568_font_ligatures
Merge font-ligatures package into addon-ligatures
2 parents 8e4de23 + f84384c commit d06d278

30 files changed

+2384
-41
lines changed

addons/addon-ligatures/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ node_modules/
33
coverage/
44

55
lib/
6-
fonts/
76

87
.env
98
.vscode/

addons/addon-ligatures/LICENSE

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1+
Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
20+
21+
---
22+
23+
The code that analyzes font ligatures is forked from https://github.com/princjef/font-ligatures with this license:
24+
125
MIT License
226

3-
Copyright (c) 2018
27+
Copyright (c) 2018 Jeffrey Principe
428

529
Permission is hereby granted, free of charge, to any person obtaining a copy
630
of this software and associated documentation files (the "Software"), to deal
156 KB
Binary file not shown.
77.4 KB
Binary file not shown.
201 KB
Binary file not shown.
390 KB
Binary file not shown.

addons/addon-ligatures/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
],
3333
"license": "MIT",
3434
"dependencies": {
35-
"font-finder": "^1.1.0",
36-
"font-ligatures": "^1.4.1"
35+
"lru-cache": "^6.0.0",
36+
"opentype.js": "^0.8.0"
3737
},
3838
"devDependencies": {
39+
"@types/lru-cache": "^5.1.0",
40+
"@types/opentype.js": "^0.7.0",
3941
"axios": "^1.6.0",
42+
"font-finder": "^1.1.0",
4043
"mkdirp": "0.5.5",
4144
"yauzl": "^2.10.0"
4245
}

addons/addon-ligatures/src/font.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @license MIT
44
*/
55

6-
import { Font, loadBuffer } from 'font-ligatures';
6+
import { Font, loadBuffer } from './fontLigatures/index';
77

88
import parse from './parse';
99

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ILookupTree, IFlattenedLookupTree, ILookupTreeEntry, IFlattenedLookupTreeEntry } from './types';
2+
3+
export default function flatten(tree: ILookupTree): IFlattenedLookupTree {
4+
const result: IFlattenedLookupTree = {};
5+
for (const [glyphId, entry] of Object.entries(tree.individual)) {
6+
result[glyphId] = flattenEntry(entry);
7+
}
8+
9+
for (const { range, entry } of tree.range) {
10+
const flattened = flattenEntry(entry);
11+
for (let glyphId = range[0]; glyphId < range[1]; glyphId++) {
12+
result[glyphId] = flattened;
13+
}
14+
}
15+
16+
return result;
17+
}
18+
19+
function flattenEntry(entry: ILookupTreeEntry): IFlattenedLookupTreeEntry {
20+
const result: IFlattenedLookupTreeEntry = {};
21+
22+
if (entry.forward) {
23+
result.forward = flatten(entry.forward);
24+
}
25+
26+
if (entry.reverse) {
27+
result.reverse = flatten(entry.reverse);
28+
}
29+
30+
if (entry.lookup) {
31+
result.lookup = entry.lookup;
32+
}
33+
34+
return result;
35+
}

0 commit comments

Comments
 (0)