Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/addon-ligatures/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ node_modules/
coverage/

lib/
fonts/

.env
.vscode/
Expand Down
26 changes: 25 additions & 1 deletion addons/addon-ligatures/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

The code that analyzes font ligatures is forked from https://github.com/princjef/font-ligatures with this license:

MIT License

Copyright (c) 2018
Copyright (c) 2018 Jeffrey Principe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file not shown.
Binary file added addons/addon-ligatures/fonts/Monoid-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file added addons/addon-ligatures/fonts/iosevka-regular.ttf
Binary file not shown.
7 changes: 5 additions & 2 deletions addons/addon-ligatures/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@
],
"license": "MIT",
"dependencies": {
"font-finder": "^1.1.0",
"font-ligatures": "^1.4.1"
"lru-cache": "^6.0.0",
"opentype.js": "^0.8.0"
},
"devDependencies": {
"@types/lru-cache": "^5.1.0",
"@types/opentype.js": "^0.7.0",
"axios": "^1.6.0",
"font-finder": "^1.1.0",
"mkdirp": "0.5.5",
"yauzl": "^2.10.0"
}
Expand Down
2 changes: 1 addition & 1 deletion addons/addon-ligatures/src/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

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

import parse from './parse';

Expand Down
35 changes: 35 additions & 0 deletions addons/addon-ligatures/src/fontLigatures/flatten.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ILookupTree, IFlattenedLookupTree, ILookupTreeEntry, IFlattenedLookupTreeEntry } from './types';

export default function flatten(tree: ILookupTree): IFlattenedLookupTree {
const result: IFlattenedLookupTree = {};
for (const [glyphId, entry] of Object.entries(tree.individual)) {
result[glyphId] = flattenEntry(entry);
}

for (const { range, entry } of tree.range) {
const flattened = flattenEntry(entry);
for (let glyphId = range[0]; glyphId < range[1]; glyphId++) {
result[glyphId] = flattened;
}
}

return result;
}

function flattenEntry(entry: ILookupTreeEntry): IFlattenedLookupTreeEntry {
const result: IFlattenedLookupTreeEntry = {};

if (entry.forward) {
result.forward = flatten(entry.forward);
}

if (entry.reverse) {
result.reverse = flatten(entry.reverse);
}

if (entry.lookup) {
result.lookup = entry.lookup;
}

return result;
}
Loading
Loading