From 3650f0da77773e5dbfc7f2b7155b2ebdc5f42273 Mon Sep 17 00:00:00 2001 From: nunulk Date: Wed, 18 May 2022 09:13:27 +0900 Subject: [PATCH] fix: strike-through line positions correctly --- src/render/font-metrics.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/render/font-metrics.ts b/src/render/font-metrics.ts index f40555c..9921e5b 100644 --- a/src/render/font-metrics.ts +++ b/src/render/font-metrics.ts @@ -37,25 +37,24 @@ export class FontMetrics { img.style.margin = '0'; img.style.padding = '0'; + img.style.display = 'inline'; img.style.verticalAlign = 'baseline'; span.style.fontFamily = fontFamily; span.style.fontSize = fontSize; span.style.margin = '0'; span.style.padding = '0'; + span.style.display = 'inline'; span.appendChild(this._document.createTextNode(SAMPLE_TEXT)); container.appendChild(span); container.appendChild(img); const baseline = img.offsetTop - span.offsetTop + 2; - container.removeChild(span); - container.appendChild(this._document.createTextNode(SAMPLE_TEXT)); - container.style.lineHeight = 'normal'; img.style.verticalAlign = 'super'; - const middle = img.offsetTop - container.offsetTop + 2; + const middle = img.offsetTop - span.offsetTop + 2; body.removeChild(container);