提交 5b0460a6 编写于 作者: D Daniel Imms

Change terminal dimensions based on renderer type

The canvas and webgl renderers use a flat integer for width whereas
dom uses a floating point number. This was causing canvas/webgl to
be more narrow than they should be. Since changing rendererType is
a pretty infrequent thing it should be fine to resize for this.

Fixes #86425
上级 ddebb299
...@@ -124,9 +124,23 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper { ...@@ -124,9 +124,23 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
fontSize, fontSize,
letterSpacing, letterSpacing,
lineHeight, lineHeight,
charWidth: rect && rect.width ? rect.width : 0, charWidth: 0,
charHeight: rect && rect.height ? Math.ceil(rect.height) : 0 charHeight: 0
}; };
if (rect && rect.width && rect.height) {
this._lastFontMeasurement.charHeight = Math.ceil(rect.height);
// Char width is calculated differently for DOM and the other renderer types. Refer to
// how each renderer updates their dimensions in xterm.js
if (this.config.rendererType === 'dom') {
this._lastFontMeasurement.charWidth = rect.width;
} else {
const scaledCharWidth = rect.width * window.devicePixelRatio;
const scaledCellWidth = scaledCharWidth + Math.round(letterSpacing);
this._lastFontMeasurement.charWidth = Math.round(scaledCellWidth / window.devicePixelRatio);
}
}
return this._lastFontMeasurement; return this._lastFontMeasurement;
} }
...@@ -167,14 +181,14 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper { ...@@ -167,14 +181,14 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
// Get the character dimensions from xterm if it's available // Get the character dimensions from xterm if it's available
if (xtermCore) { if (xtermCore) {
if (xtermCore._charSizeService && xtermCore._charSizeService.width && xtermCore._charSizeService.height) { if (xtermCore._renderService && xtermCore._renderService.dimensions?.actualCellWidth && xtermCore._renderService.dimensions?.actualCellHeight) {
return { return {
fontFamily, fontFamily,
fontSize, fontSize,
letterSpacing, letterSpacing,
lineHeight, lineHeight,
charHeight: xtermCore._charSizeService.height, charHeight: xtermCore._renderService.dimensions.actualCellHeight,
charWidth: xtermCore._charSizeService.width charWidth: xtermCore._renderService.dimensions.actualCellWidth
}; };
} }
} }
......
...@@ -17,6 +17,10 @@ export interface XTermCore { ...@@ -17,6 +17,10 @@ export interface XTermCore {
}; };
_renderService: { _renderService: {
dimensions: {
actualCellWidth: number;
actualCellHeight: number;
},
_renderer: { _renderer: {
_renderLayers: any[]; _renderLayers: any[];
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册