Skip to content

Commit

Permalink
update variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlln committed Feb 25, 2025
1 parent 69b38f3 commit deef47b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/grid/src/GridMetricCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1876,19 +1876,21 @@ export class GridMetricCalculator {
const pair = char + nextChar;
const isFirstPair = i === 0;

let add = 0;
let nextCharWidth = 0;
if (charWidths.has(pair)) {
add = isFirstPair
nextCharWidth = isFirstPair
? getOrThrow(charWidths, pair)
: getOrThrow(charWidths, pair) - getOrThrow(charWidths, char);
} else {
context.font = font;
const textMetrics = context.measureText(pair);
const { width } = textMetrics;
charWidths.set(pair, width);
add = isFirstPair ? width : width - getOrThrow(charWidths, char);
nextCharWidth = isFirstPair
? width
: width - getOrThrow(charWidths, char);
}
result += add;
result += nextCharWidth;
if (maxWidth !== undefined && result > maxWidth) {
return maxWidth;
}
Expand Down

0 comments on commit deef47b

Please sign in to comment.