Skip to content

Commit

Permalink
see pr niklasvh#2708
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit d877734
Author: Michael Arthur <michael.arthur@propellerhead.co.nz>
Date:   Mon Sep 20 19:40:23 2021 +1200

    set container and a few other styles so existing css styles dont conflict causing baseline calculation to be wrong
  • Loading branch information
nangelina committed Feb 8, 2024
1 parent f20c9f7 commit f42ae6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/render/font-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,28 @@ export class FontMetrics {
container.style.margin = '0';
container.style.padding = '0';
container.style.whiteSpace = 'nowrap';
container.style.position = 'absolute';
container.style.top = '-1000px';

body.appendChild(container);

img.src = SMALL_IMAGE;
img.width = 1;
img.height = 1;
img.style.width = '1px';
img.style.height = '1px';

img.style.margin = '0';
img.style.padding = '0';
img.style.verticalAlign = 'baseline';
img.style.display = 'inline-block';

span.style.fontFamily = fontFamily;
span.style.fontSize = fontSize;
span.style.margin = '0';
span.style.padding = '0';
span.style.lineHeight = 'normal';
span.style.height = 'auto';

span.appendChild(this._document.createTextNode(SAMPLE_TEXT));
container.appendChild(span);
Expand Down
1 change: 1 addition & 0 deletions tests/reftests/text/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<style>
body {
font-family: Arial;
display: flex;
}

.small {
Expand Down

0 comments on commit f42ae6d

Please sign in to comment.