Use ideographic baseline for canvas

This commit is contained in:
Daniel Imms
2021-04-01 17:10:14 -07:00
parent 62f5b8291d
commit a510ffb3c0
3 changed files with 8 additions and 8 deletions
@@ -224,12 +224,12 @@ export abstract class BaseRenderLayer implements IRenderLayer {
*/ */
protected _fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void { protected _fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void {
this._ctx.font = this._getFont(terminal, false, false); this._ctx.font = this._getFont(terminal, false, false);
this._ctx.textBaseline = 'middle'; this._ctx.textBaseline = 'ideographic';
this._clipRow(terminal, y); this._clipRow(terminal, y);
this._ctx.fillText( this._ctx.fillText(
cell.getChars(), cell.getChars(),
x * this._scaledCellWidth + this._scaledCharLeft, x * this._scaledCellWidth + this._scaledCharLeft,
y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2); y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight);
} }
/** /**
+4 -4
View File
@@ -242,12 +242,12 @@ export abstract class BaseRenderLayer implements IRenderLayer {
*/ */
protected _fillCharTrueColor(cell: CellData, x: number, y: number): void { protected _fillCharTrueColor(cell: CellData, x: number, y: number): void {
this._ctx.font = this._getFont(false, false); this._ctx.font = this._getFont(false, false);
this._ctx.textBaseline = 'middle'; this._ctx.textBaseline = 'ideographic';
this._clipRow(y); this._clipRow(y);
this._ctx.fillText( this._ctx.fillText(
cell.getChars(), cell.getChars(),
x * this._scaledCellWidth + this._scaledCharLeft, x * this._scaledCellWidth + this._scaledCharLeft,
y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2); y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight);
} }
/** /**
@@ -320,7 +320,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
private _drawUncachedChars(cell: ICellData, x: number, y: number, fgOverride?: IColor): void { private _drawUncachedChars(cell: ICellData, x: number, y: number, fgOverride?: IColor): void {
this._ctx.save(); this._ctx.save();
this._ctx.font = this._getFont(!!cell.isBold(), !!cell.isItalic()); this._ctx.font = this._getFont(!!cell.isBold(), !!cell.isItalic());
this._ctx.textBaseline = 'middle'; this._ctx.textBaseline = 'ideographic';
if (cell.isInverse()) { if (cell.isInverse()) {
if (fgOverride) { if (fgOverride) {
@@ -362,7 +362,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx.fillText( this._ctx.fillText(
cell.getChars(), cell.getChars(),
x * this._scaledCellWidth + this._scaledCharLeft, x * this._scaledCellWidth + this._scaledCharLeft,
y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight / 2); y * this._scaledCellHeight + this._scaledCharTop + this._scaledCharHeight);
this._ctx.restore(); this._ctx.restore();
} }
@@ -256,7 +256,7 @@ export class DynamicCharAtlas extends BaseCharAtlas {
const fontStyle = glyph.italic ? 'italic' : ''; const fontStyle = glyph.italic ? 'italic' : '';
this._tmpCtx.font = this._tmpCtx.font =
`${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`; `${fontStyle} ${fontWeight} ${this._config.fontSize * this._config.devicePixelRatio}px ${this._config.fontFamily}`;
this._tmpCtx.textBaseline = 'middle'; this._tmpCtx.textBaseline = 'ideographic';
this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css; this._tmpCtx.fillStyle = this._getForegroundColor(glyph).css;
@@ -265,7 +265,7 @@ export class DynamicCharAtlas extends BaseCharAtlas {
this._tmpCtx.globalAlpha = DIM_OPACITY; this._tmpCtx.globalAlpha = DIM_OPACITY;
} }
// Draw the character // Draw the character
this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight / 2); this._tmpCtx.fillText(glyph.chars, 0, this._config.scaledCharHeight);
this._tmpCtx.restore(); this._tmpCtx.restore();
// clear the background from the character to avoid issues with drawing over the previous // clear the background from the character to avoid issues with drawing over the previous