Varinat -> Variant
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { computeNextVarinatOffset } from 'browser/renderer/shared/RendererUtils';
|
||||
import { computeNextVariantOffset } from 'browser/renderer/shared/RendererUtils';
|
||||
import { assert } from 'chai';
|
||||
|
||||
describe('RendererUtils', () => {
|
||||
it('computeNextVarinatOffset', () => {
|
||||
it('computeNextVariantOffset', () => {
|
||||
const cellWidth = 11;
|
||||
const doubleCellWidth = 22;
|
||||
let line = 1;
|
||||
let varinatOffset = 0;
|
||||
let variantOffset = 0;
|
||||
|
||||
// should line 1
|
||||
// =,_,=_,=_,
|
||||
@@ -19,32 +19,32 @@ describe('RendererUtils', () => {
|
||||
let result = [1, 0, 0, 0];
|
||||
for (let index = 0; index < cells.length; index++) {
|
||||
const cell = cells[index];
|
||||
varinatOffset = computeNextVarinatOffset(cell, line, varinatOffset);
|
||||
assert.equal(varinatOffset, result[index]);
|
||||
variantOffset = computeNextVariantOffset(cell, line, variantOffset);
|
||||
assert.equal(variantOffset, result[index]);
|
||||
}
|
||||
|
||||
// should line 2
|
||||
// ==__==__==_,_==__==__==,__==__==__==__==__==__,==__==__==__==__==__==,
|
||||
line = 2;
|
||||
varinatOffset = 0;
|
||||
variantOffset = 0;
|
||||
cells = [cellWidth, cellWidth, doubleCellWidth, doubleCellWidth];
|
||||
result = [3, 2, 0 ,2];
|
||||
for (let index = 0; index < cells.length; index++) {
|
||||
const cell = cells[index];
|
||||
varinatOffset = computeNextVarinatOffset(cell, line, varinatOffset);
|
||||
assert.equal(varinatOffset, result[index]);
|
||||
variantOffset = computeNextVariantOffset(cell, line, variantOffset);
|
||||
assert.equal(variantOffset, result[index]);
|
||||
}
|
||||
|
||||
// should line 3
|
||||
// ===___===__,_===___===_,__===___===___===___==,=___===___===___===___,
|
||||
line = 3;
|
||||
varinatOffset = 0;
|
||||
variantOffset = 0;
|
||||
cells = [cellWidth, cellWidth, doubleCellWidth, doubleCellWidth];
|
||||
result = [5, 4, 2, 0];
|
||||
for (let index = 0; index < cells.length; index++) {
|
||||
const cell = cells[index];
|
||||
varinatOffset = computeNextVarinatOffset(cell, line, varinatOffset);
|
||||
assert.equal(varinatOffset, result[index]);
|
||||
variantOffset = computeNextVariantOffset(cell, line, variantOffset);
|
||||
assert.equal(variantOffset, result[index]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,6 +57,6 @@ function createDimension(): IDimensions {
|
||||
};
|
||||
}
|
||||
|
||||
export function computeNextVarinatOffset(cellWidth: number, lineWidth: number, currentOffset: number = 0): number {
|
||||
export function computeNextVariantOffset(cellWidth: number, lineWidth: number, currentOffset: number = 0): number {
|
||||
return (cellWidth - (Math.round(lineWidth) * 2 - currentOffset)) % (Math.round(lineWidth) * 2);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { IColorContrastCache } from 'browser/Types';
|
||||
import { DIM_OPACITY, TEXT_BASELINE } from 'browser/renderer/shared/Constants';
|
||||
import { tryDrawCustomChar } from 'browser/renderer/shared/CustomGlyphs';
|
||||
import { computeNextVarinatOffset, excludeFromContrastRatioDemands, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
||||
import { computeNextVariantOffset, excludeFromContrastRatioDemands, isPowerlineGlyph, isRestrictedPowerlineGlyph, throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
|
||||
import { IBoundingBox, ICharAtlasConfig, IRasterizedGlyph, ITextureAtlas } from 'browser/renderer/shared/Types';
|
||||
import { NULL_COLOR, color, rgba } from 'common/Color';
|
||||
import { EventEmitter } from 'common/EventEmitter';
|
||||
@@ -545,7 +545,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 = this._workAttributeData.getUnderlineVarinatOffset();
|
||||
let nextOffset = this._workAttributeData.getUnderlineVariantOffset();
|
||||
|
||||
for (let i = 0; i < chWidth; i++) {
|
||||
this._tmpCtx.save();
|
||||
@@ -610,7 +610,7 @@ export class TextureAtlas implements ITextureAtlas {
|
||||
this._tmpCtx.moveTo(xChLeft + offsetWidth + lineWidth, yTop);
|
||||
this._tmpCtx.lineTo(xChRight, yTop);
|
||||
}
|
||||
nextOffset = computeNextVarinatOffset(xChRight - xChLeft, lineWidth, nextOffset);
|
||||
nextOffset = computeNextVariantOffset(xChRight - xChLeft, lineWidth, nextOffset);
|
||||
break;
|
||||
case UnderlineStyle.DASHED:
|
||||
this._tmpCtx.setLineDash([this._config.devicePixelRatio * 4, this._config.devicePixelRatio * 3]);
|
||||
|
||||
Reference in New Issue
Block a user