Skip to content

Commit 6e35021

Browse files
committed
Support for lineHeight in DOM Renderer
1 parent febc3ba commit 6e35021

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/renderer/dom/DomRenderer.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,23 @@ export class DomRenderer extends EventEmitter implements IRenderer {
9494
}
9595

9696
private _updateDimensions(): void {
97-
this.dimensions.scaledCharWidth = this._terminal.charMeasure.width * window.devicePixelRatio;
98-
this.dimensions.scaledCharHeight = this._terminal.charMeasure.height * window.devicePixelRatio;
99-
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth;
100-
this.dimensions.scaledCellHeight = this.dimensions.scaledCharHeight;
97+
this.dimensions.scaledCharWidth = Math.floor(this._terminal.charMeasure.width * window.devicePixelRatio);
98+
this.dimensions.scaledCharHeight = Math.ceil(this._terminal.charMeasure.height * window.devicePixelRatio);
99+
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._terminal.options.letterSpacing);
100+
this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._terminal.options.lineHeight);
101101
this.dimensions.scaledCharLeft = 0;
102102
this.dimensions.scaledCharTop = 0;
103103
this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._terminal.cols;
104104
this.dimensions.scaledCanvasHeight = this.dimensions.scaledCellHeight * this._terminal.rows;
105-
this.dimensions.canvasWidth = this._terminal.charMeasure.width * this._terminal.cols;
106-
this.dimensions.canvasHeight = this._terminal.charMeasure.height * this._terminal.rows;
107-
this.dimensions.actualCellWidth = this._terminal.charMeasure.width;
108-
this.dimensions.actualCellHeight = this._terminal.charMeasure.height;
105+
this.dimensions.canvasWidth = Math.round(this.dimensions.scaledCanvasWidth / window.devicePixelRatio);
106+
this.dimensions.canvasHeight = Math.round(this.dimensions.scaledCanvasHeight / window.devicePixelRatio);
107+
this.dimensions.actualCellWidth = this.dimensions.canvasWidth / this._terminal.cols;
108+
this.dimensions.actualCellHeight = this.dimensions.canvasHeight / this._terminal.rows;
109109

110110
this._rowElements.forEach(element => {
111111
element.style.width = `${this.dimensions.canvasWidth}px`;
112-
element.style.height = `${this._terminal.charMeasure.height}px`;
112+
element.style.height = `${this.dimensions.actualCellHeight}px`;
113+
element.style.lineHeight = `${this.dimensions.actualCellHeight}px`;
113114
});
114115

115116
if (!this._dimensionsStyleElement) {
@@ -290,10 +291,10 @@ export class DomRenderer extends EventEmitter implements IRenderer {
290291
*/
291292
private _createSelectionElement(row: number, colStart: number, colEnd: number, rowCount: number = 1): HTMLElement {
292293
const element = document.createElement('div');
293-
element.style.height = `${rowCount * this._terminal.charMeasure.height}px`;
294-
element.style.top = `${row * this._terminal.charMeasure.height}px`;
295-
element.style.left = `${colStart * this._terminal.charMeasure.width}px`;
296-
element.style.width = `${this._terminal.charMeasure.width * (colEnd - colStart)}px`;
294+
element.style.height = `${rowCount * this.dimensions.actualCellHeight}px`;
295+
element.style.top = `${row * this.dimensions.actualCellHeight}px`;
296+
element.style.left = `${colStart * this.dimensions.actualCellWidth}px`;
297+
element.style.width = `${this.dimensions.actualCellWidth * (colEnd - colStart)}px`;
297298
return element;
298299
}
299300

typings/xterm.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ declare module 'xterm' {
161161
* when canvas is too slow for the environment. The following features do
162162
* not work when the DOM renderer is used:
163163
*
164-
* - Line height
165164
* - Letter spacing
166165
* - Cursor blink
167166
*/

0 commit comments

Comments
 (0)