Skip to content

Commit

Permalink
Recognize two-word weights with space
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Jan 18, 2022
1 parent 0c02827 commit ccfc67c
Show file tree
Hide file tree
Showing 4 changed files with 11,907 additions and 11 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ module.exports = function(fonts, size, lineHeight) {
style = haveStyle ? style : parts[parts.length - 1].replace(maybeWeight, '');
}
for (var w in fontWeights) {
if (maybeWeight == w || maybeWeight == w.replace('-', '') || maybeWeight == w.replace('-', sp)) {
var previousPart = parts.length > 1 ? parts[parts.length - 2].toLowerCase() : '';
if (maybeWeight == w || maybeWeight == w.replace('-', '') || previousPart + '-' + maybeWeight == w) {
weight = haveWeight ? weight : fontWeights[w];
parts.pop();
if (previousPart && w.startsWith(previousPart)) {
parts.pop();
}
break;
}
}
Expand Down
Loading

0 comments on commit ccfc67c

Please sign in to comment.