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
fix(preset-web-fonts): sort weights as string using localeCompare #2845
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Previously, the weights were converted to Number before sorting. This would lead to conversion of string to NaN.
@arunanshub Is there any downside to using |
@arunanshub I changed the code a bit, feel free to optimize it. By the way can you add a test case for bunny. Need your review. |
@zyyv In UnoCSS docs for Web fonts preset we should ideally be able to selectively choose the font weights along with their italicized versions. This is currently possible using this configuration: {
// ...
fonts: {
sans: 'Roboto',
mono: ['Fira Mono:400,700i'],
}
} However, this method is sub-optimal. It is cleaner if we specify the weights like this: {
// ...
fonts: {
sans: 'Roboto',
mono: {
name: 'Fira Code',
weights: [400, '700i'],
},
}
} However, the current weight sorting function converts all the weight values to numbers, which converts the italicized weights to NaN. |
I see, I will revert my changes. Thank you for your guide. |
@zyyv The removal of italicized font weights undermines the objectives of the pull request. Our intention is to sort all font weights, including the italicized versions. |
I didn't know the weight would carry the italics, thanks again. |
Previously, the weights were converted to Number before sorting. This would lead to conversion of string to NaN.