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

measureText 计算 fontSize 有误 #947

Closed
zhiqingchen opened this issue Sep 7, 2022 · 1 comment · Fixed by #968
Closed

measureText 计算 fontSize 有误 #947

zhiqingchen opened this issue Sep 7, 2022 · 1 comment · Fixed by #968
Labels

Comments

@zhiqingchen
Copy link

text = text || '';
font = font || DEFAULT_FONT;
// Use font size if there is no other method can be used.
const res = /^([0-9]*?)px$/.exec(font);
const fontSize = +(res && res[1]) || DEFAULT_FONT_SIZE;

DEFAULT_FONT 为 12px sans-serif

运行时为 normal normal 12px sans-serif

font = font || DEFAULT_FONT;
const res = /^([0-9]*?)px$/.exec(font);
const fontSize = +(res && res[1]) || DEFAULT_FONT_SIZE;

res 为 null, fontSize 只能为 DEFAULT_FONT_SIZE

@Ovilia
Copy link
Member

Ovilia commented Oct 10, 2022

normal normal 12px sans-serif 是怎么来的?请提供一个调用时的代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants