Skip to content

Commit

Permalink
Fix the ligature support
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Jan 7, 2025
1 parent 75e91c7 commit f0b5f69
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions main/src/terminal/TerminalBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ export class TerminalBlock implements Block {
if (ligatureMarker != null) {
const text = line.getString(0);
ligatureMarker.markLigaturesCharCellLine(line, text);
} else {
line.clearAllLigatures();
}

let hoverLinkID = 0;
Expand Down
13 changes: 13 additions & 0 deletions packages/extraterm-char-cell-line/src/CharCellLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,19 @@ export class CharCellLine {
this.#dirtyFlag = true;
}

clearAllLigatures(): void {
const width = this.width;
for (let i=0; i<width; i++) {
const offset = i * CELL_SIZE_BYTES;
const flags = this.#dataView.getUint8(offset + OFFSET_FLAGS);
if (flags & FLAG_MASK_LIGATURE) {
// Clear ligature flag and set width to 1 (normal)
this.#dataView.setUint8(offset + OFFSET_FLAGS, flags & ~(FLAG_MASK_LIGATURE|FLAG_MASK_WIDTH));
}
}
this.#dirtyFlag = true;
}

getLigature(x: number): number {
const offset = x * CELL_SIZE_BYTES;
const flags = this.#dataView.getUint8(offset + OFFSET_FLAGS);
Expand Down
3 changes: 1 addition & 2 deletions packages/extraterm-char-render-canvas/src/CellPainter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ export class CellPainter {
let isExtra = false;
for (const fontSlice of fontSlices) {
if (fontSlice.containsCodePoint(codePoint)) {
line.setExtraFontsFlag(i, true);
line.setLigature(i, 0);
isExtra = true;
break;
}
}
line.setExtraFontsFlag(i, isExtra);
line.setLigature(i, 0);
}
}
}

0 comments on commit f0b5f69

Please sign in to comment.