Skip to content

Commit 4783a86

Browse files
authored
Merge pull request #1077 from Unlasting1/fix/platform-fontSize-reg
fix(platform): fix `measureText` can't recognize decimal font size
2 parents 379f91f + 76daa1c commit 4783a86

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/platform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const platformApi: Platform = {
7575
text = text || '';
7676
font = font || DEFAULT_FONT;
7777
// Use font size if there is no other method can be used.
78-
const res = /(\d+)px/.exec(font);
78+
const res = /((?:\d+)?\.?\d*)px/.exec(font);
7979
const fontSize = res && +res[1] || DEFAULT_FONT_SIZE;
8080
let width = 0;
8181
if (font.indexOf('mono') >= 0) { // is monospace
@@ -108,4 +108,4 @@ export function setPlatformAPI(newPlatformApis: Partial<Platform>) {
108108
(platformApi as any)[key] = (newPlatformApis as any)[key];
109109
}
110110
}
111-
}
111+
}

0 commit comments

Comments
 (0)