-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat: support measuring text with font weight #884
Conversation
} else { | ||
g.font = `${t['font-size']} ${t['font-family']}`; | ||
} | ||
g.font = [t['font-style'], t['font-weight'], t['font-size'], t['font-family']].filter((v) => !!v).join(' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking here but it does not seem optional from a performance perspective to
- Create an array
filter
to create another arrayjoin
array
...everytime we render a text.
I would think string concat is a faster and provides a somewhat clean syntax. Some simpified tested in the browser console at least gave to a 50% performance increase compered to current method.
Example:
g.font = (t["font-style"] ?? "").concat(t['font-weight'] ?? ", t['font-size'] ?? "", t['font-family'] ?? "")
This PR to support measure text with styling e.g bold and/or italic
Checklist