Fix non-white colors not being drawn as bold
This commit is contained in:
@@ -251,13 +251,6 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
|||||||
this._ctx.globalAlpha = DIM_OPACITY;
|
this._ctx.globalAlpha = DIM_OPACITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the non-bold version of the same color if bold is not enabled
|
|
||||||
if (bold) {
|
|
||||||
// Ignore default color as it's not touched above
|
|
||||||
if (colorIndex > 1) {
|
|
||||||
colorIndex -= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._ctx.drawImage(this._charAtlas,
|
this._ctx.drawImage(this._charAtlas,
|
||||||
code * charAtlasCellWidth,
|
code * charAtlasCellWidth,
|
||||||
@@ -333,9 +326,9 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
|||||||
/**
|
/**
|
||||||
* Gets the current font.
|
* Gets the current font.
|
||||||
* @param terminal The terminal.
|
* @param terminal The terminal.
|
||||||
* @param isBold The font weight that should be used uses terminal option as fallback.
|
* @param isBold If we should use the bold fontWeight.
|
||||||
*/
|
*/
|
||||||
private _getFont(terminal: ITerminal, isBold: boolean): string {
|
protected _getFont(terminal: ITerminal, isBold: boolean): string {
|
||||||
const fontWeight = isBold ? terminal.options.fontWeightBold : terminal.options.fontWeight;
|
const fontWeight = isBold ? terminal.options.fontWeightBold : terminal.options.fontWeight;
|
||||||
|
|
||||||
return `${fontWeight} ${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;
|
return `${fontWeight} ${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class CharAtlasGenerator {
|
|||||||
|
|
||||||
this._ctx.save();
|
this._ctx.save();
|
||||||
this._ctx.fillStyle = foreground;
|
this._ctx.fillStyle = foreground;
|
||||||
this._ctx.font = `${fontWeight} ${fontSize * window.devicePixelRatio}px ${fontFamily}`;
|
this._ctx.font = this._getFont(fontWeight, fontSize, fontFamily);
|
||||||
this._ctx.textBaseline = 'top';
|
this._ctx.textBaseline = 'top';
|
||||||
|
|
||||||
// Default color
|
// Default color
|
||||||
@@ -157,7 +157,7 @@ class CharAtlasGenerator {
|
|||||||
}
|
}
|
||||||
// Default color bold
|
// Default color bold
|
||||||
this._ctx.save();
|
this._ctx.save();
|
||||||
this._ctx.font = `${fontWeightBold} ${fontSize * window.devicePixelRatio}px ${fontFamily}`;
|
this._ctx.font = this._getFont(fontWeightBold, fontSize, fontFamily);
|
||||||
for (let i = 0; i < 256; i++) {
|
for (let i = 0; i < 256; i++) {
|
||||||
this._ctx.save();
|
this._ctx.save();
|
||||||
this._ctx.beginPath();
|
this._ctx.beginPath();
|
||||||
@@ -169,11 +169,11 @@ class CharAtlasGenerator {
|
|||||||
this._ctx.restore();
|
this._ctx.restore();
|
||||||
|
|
||||||
// Colors 0-15
|
// Colors 0-15
|
||||||
this._ctx.font = `${fontWeight} ${fontSize * window.devicePixelRatio}px ${fontFamily}`;
|
this._ctx.font = this._getFont(fontWeight, fontSize, fontFamily);
|
||||||
for (let colorIndex = 0; colorIndex < 16; colorIndex++) {
|
for (let colorIndex = 0; colorIndex < 16; colorIndex++) {
|
||||||
// colors 8-15 are bold
|
// colors 8-15 are bold
|
||||||
if (colorIndex === 8) {
|
if (colorIndex === 8) {
|
||||||
this._ctx.font = `${fontWeightBold} ${fontSize * window.devicePixelRatio}px ${fontFamily}`;
|
this._ctx.font = this._getFont(fontWeightBold, fontSize, fontFamily);
|
||||||
}
|
}
|
||||||
const y = (colorIndex + 2) * cellHeight;
|
const y = (colorIndex + 2) * cellHeight;
|
||||||
// Draw ascii characters
|
// Draw ascii characters
|
||||||
@@ -225,4 +225,8 @@ class CharAtlasGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getFont(fontWeight: string, fontSize: number, fontFamily: string): string {
|
||||||
|
return `${fontWeight} ${fontSize * window.devicePixelRatio}px ${fontFamily}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export class TextRenderLayer extends BaseRenderLayer {
|
|||||||
super.resize(terminal, dim, charSizeChanged);
|
super.resize(terminal, dim, charSizeChanged);
|
||||||
|
|
||||||
// Clear the character width cache if the font or width has changed
|
// Clear the character width cache if the font or width has changed
|
||||||
const terminalFont = `${terminal.options.fontWeight} ${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;
|
const terminalFont = this._getFont(terminal, false);
|
||||||
if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {
|
if (this._characterWidth !== dim.scaledCharWidth || this._characterFont !== terminalFont) {
|
||||||
this._characterWidth = dim.scaledCharWidth;
|
this._characterWidth = dim.scaledCharWidth;
|
||||||
this._characterFont = terminalFont;
|
this._characterFont = terminalFont;
|
||||||
@@ -166,7 +166,7 @@ export class TextRenderLayer extends BaseRenderLayer {
|
|||||||
|
|
||||||
this._ctx.save();
|
this._ctx.save();
|
||||||
if (flags & FLAGS.BOLD) {
|
if (flags & FLAGS.BOLD) {
|
||||||
this._ctx.font = `bold ${this._ctx.font}`;
|
this._ctx.font = this._getFont(terminal, true);
|
||||||
// Convert the FG color to the bold variant
|
// Convert the FG color to the bold variant
|
||||||
if (fg < 8) {
|
if (fg < 8) {
|
||||||
fg += 8;
|
fg += 8;
|
||||||
|
|||||||
Reference in New Issue
Block a user