diff --git a/addons/xterm-addon-ligatures/src/font.ts b/addons/xterm-addon-ligatures/src/font.ts index 5c5f0a6c..ece22367 100644 --- a/addons/xterm-addon-ligatures/src/font.ts +++ b/addons/xterm-addon-ligatures/src/font.ts @@ -3,8 +3,7 @@ * @license MIT */ -import { FontList } from 'font-finder'; -import { Font, loadBuffer, loadFile } from 'font-ligatures'; +import { Font, loadBuffer } from 'font-ligatures'; import parse from './parse'; @@ -24,7 +23,7 @@ interface IFontAccessNavigator { }; } -let fontsPromise: Promise> | undefined = undefined; +let fontsPromise: Promise> | undefined = undefined; /** * Loads the font ligature wrapper for the specified font family if it could be @@ -81,14 +80,6 @@ export default async function load(fontFamily: string, cacheSize: number): Promi console.error(err.name, err.message); } } - // Node environment or no font access API - else { - try { - fontsPromise = (await import('font-finder')).list(); - } catch (err) { - // No-op - } - } if (!fontsPromise) { fontsPromise = Promise.resolve({}); } @@ -110,7 +101,7 @@ export default async function load(fontFamily: string, cacheSize: number): Promi const buffer = await bytes.arrayBuffer(); return loadBuffer(buffer, { cacheSize }); } - return await loadFile(font.path, { cacheSize }); + return undefined; } } diff --git a/addons/xterm-addon-ligatures/src/index.test.ts b/addons/xterm-addon-ligatures/src/index.test.ts index 0cfe2462..c7bf09ce 100644 --- a/addons/xterm-addon-ligatures/src/index.test.ts +++ b/addons/xterm-addon-ligatures/src/index.test.ts @@ -69,76 +69,6 @@ describe('xterm-addon-ligatures', () => { assert.deepEqual(term.joiner!(input), []); }); - it('returns the correct set of ranges once the font has loaded', done => { - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - - it('handles quoted font names', done => { - term.options.fontFamily = '"Fira Code", monospace'; - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - - it('falls back to later fonts if earlier ones are not present', done => { - term.options.fontFamily = 'notinstalled, Fira Code, monospace'; - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - - it('uses the current font value', done => { - // The first three calls are all synchronous so that we don't allow time for - // any fonts to load while we're switching things around - term.options.fontFamily = 'Fira Code'; - assert.deepEqual(term.joiner!(input), []); - term.options.fontFamily = 'notinstalled'; - assert.deepEqual(term.joiner!(input), []); - term.options.fontFamily = 'Iosevka'; - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4]]); - - // And switch it back to Fira Code for good measure - term.options.fontFamily = 'Fira Code'; - - // At this point, we haven't loaded the new font, so the result reverts - // back to empty until that happens - assert.deepEqual(term.joiner!(input), []); - - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - }); - - it('allows multiple terminal instances that use different fonts', done => { - const onRefresh2 = sinon.stub(); - const term2 = new MockTerminal(onRefresh2); - term2.options.fontFamily = 'Iosevka'; - ligatureSupport.enableLigatures(term2 as any); - - assert.deepEqual(term.joiner!(input), []); - onRefresh.callsFake(() => { - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - assert.deepEqual(term2.joiner!(input), []); - onRefresh2.callsFake(() => { - assert.deepEqual(term2.joiner!(input), [[2, 4]]); - assert.deepEqual(term.joiner!(input), [[2, 4], [7, 10]]); - done(); - }); - }); - }); - it('fails if it finds but cannot load the font', async () => { term.options.fontFamily = 'Nonexistant Font, monospace'; assert.deepEqual(term.joiner!(input), []); diff --git a/addons/xterm-addon-ligatures/src/index.ts b/addons/xterm-addon-ligatures/src/index.ts index 82589e36..82675626 100644 --- a/addons/xterm-addon-ligatures/src/index.ts +++ b/addons/xterm-addon-ligatures/src/index.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal } from 'xterm'; +import type { Terminal } from 'xterm'; import { Font } from 'font-ligatures'; import load from './font'; diff --git a/addons/xterm-addon-ligatures/webpack.config.js b/addons/xterm-addon-ligatures/webpack.config.js index e8066771..5aeebe2e 100644 --- a/addons/xterm-addon-ligatures/webpack.config.js +++ b/addons/xterm-addon-ligatures/webpack.config.js @@ -29,18 +29,19 @@ module.exports = { }, mode: 'production', externals: { - 'font-finder': 'font-finder', + 'fs': 'fs', + 'path': 'path', 'stream': 'stream', - 'os': 'os', 'util': 'util' }, resolve: { // The ligature modules contains fallbacks for node environments, we never want to browserify them fallback: { - stream: false, - util: false, + fs: false, os: false, - path: false + path: false, + stream: false, + util: false } } };