Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the strickthough position is wrong when fontsize is different #1919

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading