fix: strike-through line positions correctly

This commit is contained in:
nunulk 2022-05-18 09:13:27 +09:00
parent 6020386bbe
commit 3650f0da77

View File

@ -37,25 +37,24 @@ export class FontMetrics {
img.style.margin = '0'; img.style.margin = '0';
img.style.padding = '0'; img.style.padding = '0';
img.style.display = 'inline';
img.style.verticalAlign = 'baseline'; img.style.verticalAlign = 'baseline';
span.style.fontFamily = fontFamily; span.style.fontFamily = fontFamily;
span.style.fontSize = fontSize; span.style.fontSize = fontSize;
span.style.margin = '0'; span.style.margin = '0';
span.style.padding = '0'; span.style.padding = '0';
span.style.display = 'inline';
span.appendChild(this._document.createTextNode(SAMPLE_TEXT)); span.appendChild(this._document.createTextNode(SAMPLE_TEXT));
container.appendChild(span); container.appendChild(span);
container.appendChild(img); container.appendChild(img);
const baseline = img.offsetTop - span.offsetTop + 2; const baseline = img.offsetTop - span.offsetTop + 2;
container.removeChild(span);
container.appendChild(this._document.createTextNode(SAMPLE_TEXT));
container.style.lineHeight = 'normal'; container.style.lineHeight = 'normal';
img.style.verticalAlign = 'super'; img.style.verticalAlign = 'super';
const middle = img.offsetTop - container.offsetTop + 2; const middle = img.offsetTop - span.offsetTop + 2;
body.removeChild(container); body.removeChild(container);