diff --git a/addons/xterm-addon-ligatures/README.md b/addons/xterm-addon-ligatures/README.md index 892c3ce9..6336bf83 100644 --- a/addons/xterm-addon-ligatures/README.md +++ b/addons/xterm-addon-ligatures/README.md @@ -1,55 +1,31 @@ -# xterm-addon-ligatures +## xterm-addon-ligatures Add support for programming ligatures to [xterm.js] when running in environments with access to [Node.js] APIs (such as [Electron]). -## Requirements +### Requirements * [Node.js] 8.x or higher (present in [Electron] 1.8.3 or higher) * [xterm.js] 4.0.0 or higher using the default canvas renderer -## Usage +### Install -Install in your project by running: - -``` -npm install xterm-addon-ligatures +```bash +npm install --save xterm-addon-ligatures ``` -Then, modify the location where you initialize the terminal to enable ligature support after opening. If you enable ligatures prior to opening the terminal, they will not function properly. - -Your code should look something like this: - -```js -import { Terminal } from 'xterm'; -import * as ligatures from 'xterm-addon-ligatures'; - -Terminal.applyAddon(ligatures); - -const terminal = new Terminal(); -terminal.open(document.getElementById('terminal-mount')); -terminal.enableLigatures(); -``` - -### Importing in TypeScript - -If you use TypeScript, you will need to cast the terminal variable as `any` when you enable ligatures because TypeScript does not know that the addon is available on the terminal object. It will look like this: +### Usage ```ts -(terminal as any).enableLigatures() -``` - -Alternatively, you can import the addon directly as a function and pass the terminal as an argument: - -```js import { Terminal } from 'xterm'; -import { enableLigatures } from 'xterm-addon-ligatures'; +import { LigaturesAddon } from 'xterm-addon-ligatures'; const terminal = new Terminal(); -terminal.open(document.getElementById('terminal-mount')); -enableLigatures(terminal); +const ligaturesAddon = new LigaturesAddon(); +terminal.open(containerElement); +terminal.loadAddon(ligaturesAddon); ``` -## How It Works +### How It Works In a browser environment, font ligature information is read directly by the web browser and used to render text correctly without any intervention from the developer. As of version 3, xterm.js uses the canvas to render characters individually, resulting in a significant performance boost. However, this means that it can no longer lean on the browser to determine when to draw font ligatures. @@ -57,7 +33,7 @@ This package locates the font file on disk for the font currently in use by the Since this package depends on being able to find and resolve a system font from disk, it has to have system access that isn't available in the web browser. As a result, this package is mainly useful in environments that combine browser and Node.js runtimes (such as [Electron]). -## Fonts +### Fonts This package makes use of the following fonts for testing: