csstools / postcss-font-magician

Magically generate all the @font-face rules
Other
1k stars 31 forks source link

"'charCodeAt' is not defined" error with non-string font names #61

Closed JayBauer closed 6 years ago

JayBauer commented 6 years ago

If I have a rule such as font-family: sans-serif;, I'm getting the error Cannot read property 'charCodeAt' of undefined in my console. However, font-family: "Source Sans Pro", sans-serif; gives me no trouble. Seems to be only when there's no string available that the issue occurs.

I have confirmed this is font-magician's doing, and have confirmed that it happens regardless of my PostCSS plugin load order, even when font-magician is the only plugin being used.

This wouldn't be a huge issue for a typical user-generated CSS sheet, but certain libraries such as normalize.css have a lot of these types of rules for resets. Is there a known fix for this problem?

timkelty commented 6 years ago

Having the same issue, in my case with font-family: 'Open Sans'

jhpratt commented 6 years ago

@jonathantneal Confirming with font-family: 'Roboto Mono', using single or double quotes. The actual font name does not seem to matter, just that it's quoted. It's worth noting that even when unquoted, it will build, but does not do anything.

rajdee commented 6 years ago

@JayBauer @timkelty @jhpratt I can't reproduce these issues. The pfm works with font-family: sans-serif or font-family: 'Open Sans as expected. Please provide more information about Postcss and PFM versions and settings