-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
support font-family names with numbers in (e.g. Font Awesome 5) #1948
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@grahamkane Is there a need to perform the
indexOf
test, or could we simplify this code by applying quoting to each map entry?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.
FWIW - the W3 has some good reference docs for the
font-family
property - they list a number of invalid property values, and note that quoting is required for any font names that may also be keywords.Given that, it may be easiest to apply quoting to all values.
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.
Edit: the suggested code snippet should be:
(the
join
operation was previously missing)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.
From CSS Fonts Module Level 3 (September, 2018):
So generic families do not require quoting; my mistake earlier.
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.
Would it be possible to use the isIdentToken function to identify built-in font names instead?
It's possible this fix should be pushed down to the
font-family
CSS property parser.I'm seeing slightly different behaviour between Chrome and Firefox with the fix proposed here in #1948 ; in particular I find that performing
styles.fontFamily.join(' ').split(',') ...
helps a little, since this joins all existing font-family tokens and then splits them into individual font names. I don't yet have a perfect solution though...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.
Long story; in the end this train of thought led me to investigate the
font-family
CSS property parser more thoroughly, and the bug is due to the fact thatFont Awesome 5 Free
(four words) parses to the family list["Font", "Awesome", "5", "Free"]
(i.e. four non-existent font names).A parser-level fix is provided in #2219.