Skip to content

Commit

Permalink
use underlineVariantOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
tisilent committed Nov 18, 2023
1 parent ac7318b commit a619228
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/browser/renderer/shared/CellColorResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let $hasFg = false;
let $hasBg = false;
let $isSelected = false;
let $colors: ReadonlyColorSet | undefined;
let $variantOffset = 0;
// let $variantOffset = 0;
let $underlineVariantOffset = 0;

export class CellColorResolver {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class CellColorResolver {
$hasFg = false;
$isSelected = false;
$colors = this._themeService.colors;
$variantOffset = 0;
// $variantOffset = 0;
$underlineVariantOffset = 0;

const code = cell.getCode();
Expand All @@ -66,7 +66,7 @@ export class CellColorResolver {
if (code !== NULL_CELL_CODE && cell.extended.underlineStyle !== UnderlineStyle.NONE) {
const lineWidth = Math.max(1, Math.floor(this._optionService.rawOptions.fontSize * this._coreBrowserService.dpr / 15));
if (cell.extended.underlineStyle === UnderlineStyle.DOTTED) {
$variantOffset = x * deviceCellWidth % (Math.round(lineWidth) * 2);
$underlineVariantOffset = x * deviceCellWidth % (Math.round(lineWidth) * 2);
} else if (cell.extended.underlineStyle === UnderlineStyle.CURLY) {
$underlineVariantOffset = getCurlyVariantOffset(x, deviceCellWidth, lineWidth);
}
Expand Down Expand Up @@ -154,8 +154,8 @@ export class CellColorResolver {
this.result.fg = $hasFg ? $fg : this.result.fg;

// Reset overrides variantOffset
this.result.ext &= ~ExtFlags.VARIANT_OFFSET;
this.result.ext |= ($variantOffset << 29) & ExtFlags.VARIANT_OFFSET;
// this.result.ext &= ~ExtFlags.VARIANT_OFFSET;
// this.result.ext |= ($variantOffset << 29) & ExtFlags.VARIANT_OFFSET;
this.result.underlineVariantOffset = $underlineVariantOffset;
}
}
25 changes: 13 additions & 12 deletions src/browser/renderer/shared/TextureAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IColorContrastCache } from 'browser/Types';
import { DIM_OPACITY, TEXT_BASELINE } from 'browser/renderer/shared/Constants';
import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
import { computeNextVariantOffset, excludeFromContrastRatioDemands, getCurlyVariant, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from 'browser/renderer/shared/Types';
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas, UnderlineDrawCurlyOp } from 'browser/renderer/shared/Types';
import { NULL_COLOR, color, rgba } from 'common/Color';
import { EventEmitter } from 'common/EventEmitter';
import { FiveKeyMap } from 'common/MultiKeyMap';
Expand Down Expand Up @@ -546,7 +546,7 @@ export class TextureAtlas implements ITextureAtlas {
const yTop = Math.ceil(padding + this._config.deviceCharHeight) - yOffset - (restrictToCellHeight ? lineWidth * 2 : 0);
const yMid = yTop + lineWidth;
const yBot = yTop + lineWidth * 2;
let nextOffset = underlineVariantoffset !== 0 ? underlineVariantoffset : this._workAttributeData.getUnderlineVariantOffset();
let nextOffset = underlineVariantoffset;

for (let i = 0; i < chWidth; i++) {
this._tmpCtx.save();
Expand Down Expand Up @@ -578,53 +578,54 @@ export class TextureAtlas implements ITextureAtlas {
let xOffset = 0;

steps.forEach(step => {
const token = step.substring(0, 1);
const op: UnderlineDrawCurlyOp = step.substring(0, 1) as UnderlineDrawCurlyOp;
const pixels = Number.parseInt(step.substring(1));

// draw join
if (token === 'Y' || token === 'B' || token === 'M' || token === 'Q' || token === 'P' || token === 'Z') {
if (op === 'Y' || op === 'B' || op === 'M' || op === 'Q' || op === 'P' || op === 'Z') {
// TODO recode
if (pixels < lineWidth) {
if (token === 'Q') {
if (op === 'Q') {
for (let index = 0; index < pixels; index++) {
this._tmpCtx.fillRect(xChLeft + xOffset + index, yMidRectOffset - index, 1, lineWidth);
}
xOffset += pixels;
return;
}

if (token === 'P') {
if (op === 'P') {
for (let index = 0; index < pixels; index++) {
this._tmpCtx.fillRect(xChLeft + xOffset + index, yMidRectOffset - (lineWidth - pixels) - index, 1, lineWidth);
}
xOffset += pixels;
return;
}

if (token === 'Z') {
if (op === 'Z') {
for (let index = 0; index < pixels; index++) {
this._tmpCtx.fillRect(xChLeft + xOffset + index, yMidRectOffset - (lineWidth - 1) + index, 1, lineWidth);
}
xOffset += pixels;
return;
}

if (token === 'M') {
if (op === 'M') {
for (let index = 0; index < pixels; index++) {
this._tmpCtx.fillRect(xChLeft + xOffset + index, yMidRectOffset - (lineWidth - 1) + (lineWidth - pixels) + index, 1, lineWidth);
}
xOffset += pixels;
return;
}
} else {
if (token === 'Y') {
if (op === 'Y') {
for (let index = 0; index < pixels; index++) {
this._tmpCtx.fillRect(xChLeft + xOffset + index, yMidRectOffset - index, 1, lineWidth);
}
xOffset += pixels;
return;
}

if (token === 'B') {
if (op === 'B') {
for (let index = 0; index < pixels; index++) {
this._tmpCtx.fillRect(xChLeft + xOffset + index, yMidRectOffset - (lineWidth - 1) + index, 1, lineWidth);
}
Expand All @@ -636,13 +637,13 @@ export class TextureAtlas implements ITextureAtlas {
}

// draw line
if (token === 'U') {
if (op === 'U') {
this._tmpCtx.fillRect(xChLeft + xOffset, yMidRectOffset - lineWidth, pixels, lineWidth);
xOffset += pixels;
return;
}

if (token === 'D') {
if (op === 'D') {
this._tmpCtx.fillRect(xChLeft + xOffset, yMidRectOffset + 1, pixels, lineWidth);
xOffset += pixels;
return;
Expand Down

0 comments on commit a619228

Please sign in to comment.