Skip to content

Commit

Permalink
fix: the strickthough position is wrong when fontsize is different (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Apr 17, 2024
1 parent 039e5e2 commit 2564456
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/engine-render/src/components/docs/extensions/line.ts
Expand Up @@ -65,7 +65,7 @@ export class Line extends docExtension {

if (strikethrough) {
// strikethrough position is the middle of bounding box ascent and descent.
let startY = strikeoutPosition - DELTA;
let startY = asc + bd - strikeoutPosition - DELTA;

/**
* --------- superscript strikethrough position -------
Expand All @@ -75,9 +75,9 @@ export class Line extends docExtension {
* --------- subscript offset -----------------------
*/
if (baselineOffset === BaselineOffset.SUPERSCRIPT) {
startY = asc + bd - spo - strikeoutPosition;
startY -= spo;
} else if (baselineOffset === BaselineOffset.SUBSCRIPT) {
startY = asc + bd + sbo - strikeoutPosition;
startY += sbo;
}

this._drawLine(ctx, span, strikethrough, startY, scale);
Expand Down
Expand Up @@ -369,7 +369,7 @@ export class FontCache {
bd,
aba,
abd,
sp: (ba + bd) / 2,
sp: (fontBoundingBoxAscent + fontBoundingBoxDescent) / 2,
sbr: 0.6,
spr: 0.6,
// https://en.wikipedia.org/wiki/Subscript_and_superscript Microsoft Word 2015
Expand Down

0 comments on commit 2564456

Please sign in to comment.