Separate bright and bold

This commit is contained in:
Linus Unnebäck
2018-05-07 22:19:01 +02:00
parent e48b15e859
commit 41fd563144
3 changed files with 19 additions and 14 deletions
+2 -2
View File
@@ -245,7 +245,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
protected drawChar(terminal: ITerminal, char: string, code: number, width: number, x: number, y: number, fg: number, bg: number, bold: boolean, dim: boolean, italic: boolean): void {
let colorIndex = 0;
if (fg < 256) {
colorIndex = fg + 2;
colorIndex = fg + 2 + (bold && terminal.options.enableBold ? 16 : 0);
} else {
// If default color and bold
if (bold && terminal.options.enableBold) {
@@ -273,7 +273,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
if (bold && !terminal.options.enableBold) {
// Ignore default color as it's not touched above
if (colorIndex > 1) {
colorIndex -= 8;
colorIndex -= 16;
}
}
-7
View File
@@ -116,13 +116,6 @@ export class TextRenderLayer extends BaseRenderLayer {
}
}
if (flags & FLAGS.BOLD) {
// Convert the FG color to the bold variant
if (fg < 8) {
fg += 8;
}
}
callback(code, char, width, x, y, fg, bg, flags);
}
}
+17 -5
View File
@@ -27,7 +27,7 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number
const cellHeight = config.scaledCharHeight + CHAR_ATLAS_CELL_SPACING;
const canvas = canvasFactory(
/*255 ascii chars*/255 * cellWidth,
(/*default+default bold*/2 + /*0-15*/16) * cellHeight
(/*default+default bold*/2 + /*0-15*/16 + /*0-15 bold*/16) * cellHeight
);
const ctx = canvas.getContext('2d', {alpha: config.allowTransparency});
@@ -64,10 +64,6 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number
// Colors 0-15
ctx.font = getFont(config.fontWeight, config);
for (let colorIndex = 0; colorIndex < 16; colorIndex++) {
// colors 8-15 are bold
if (colorIndex === 8) {
ctx.font = getFont(config.fontWeightBold, config);
}
const y = (colorIndex + 2) * cellHeight;
// Draw ascii characters
for (let i = 0; i < 256; i++) {
@@ -80,6 +76,22 @@ export function generateCharAtlas(context: Window, canvasFactory: (width: number
ctx.restore();
}
}
// Colors 0-15 bold
ctx.font = getFont(config.fontWeightBold, config);
for (let colorIndex = 0; colorIndex < 16; colorIndex++) {
const y = (colorIndex + 2 + 16) * cellHeight;
// Draw ascii characters
for (let i = 0; i < 256; i++) {
ctx.save();
ctx.beginPath();
ctx.rect(i * cellWidth, y, cellWidth, cellHeight);
ctx.clip();
ctx.fillStyle = config.colors.ansi[colorIndex].css;
ctx.fillText(String.fromCharCode(i), i * cellWidth, y);
ctx.restore();
}
}
ctx.restore();
// Support is patchy for createImageBitmap at the moment, pass a canvas back