You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Font picker is defined with local fonts only, no google or system fonts, --> googleFonts: false,
User saves a "project" with various text elements, fonts have been selected with this plugin.
User reloads page.
User clicks on an existing text element.
Expected result:
$("#font").val(f).trigger("change"); is called and the font picker displays the element's current font.
Actual result:
"Uncaught TypeError: Cannot read property 'variants' of undefined. jquery.fontpicker.js:5128 "
Line 5128 shows this: var url = 'https://fonts.googleapis.com/css?family=' + font.replace(/ /g,'+') + ':' + this.options.googleFonts[font].variants + '&display=swap';
Upon further inspection I found that this was only happening with local fonts that also appear on the google fonts list with exactly the same name. Specific fonts I had trouble with were Roboto, Cabin, and Quicksliver. Fonts that do not appear on the google fonts list do not throw this error, and work as expected.
Current work around:
Rename the font files; for example I renamed Roboto to Roboto-Regular and this fixed the error. Another solution is to open the font picker modal to force the fonts to load. These solutions seems hacky to me. Furthermore, I don't think I should have to implement onSelected to differentiate types when googleFonts is set to false.
The text was updated successfully, but these errors were encountered:
Please try version 1.3. It should fix your issue.
As for implementing onSelect: this is optional, in your case (not using google Fonts), an on('change', ...) event handler should suffice.
Thanks for your very clear bug report!
Use case:
googleFonts: false,
Expected result:
$("#font").val(f).trigger("change"); is called and the font picker displays the element's current font.
Actual result:
"Uncaught TypeError: Cannot read property 'variants' of undefined. jquery.fontpicker.js:5128 "
Line 5128 shows this:
var url = 'https://fonts.googleapis.com/css?family=' + font.replace(/ /g,'+') + ':' + this.options.googleFonts[font].variants + '&display=swap';
Upon further inspection I found that this was only happening with local fonts that also appear on the google fonts list with exactly the same name. Specific fonts I had trouble with were Roboto, Cabin, and Quicksliver. Fonts that do not appear on the google fonts list do not throw this error, and work as expected.
Current work around:
Rename the font files; for example I renamed Roboto to Roboto-Regular and this fixed the error. Another solution is to open the font picker modal to force the fonts to load. These solutions seems hacky to me. Furthermore, I don't think I should have to implement onSelected to differentiate types when googleFonts is set to false.
The text was updated successfully, but these errors were encountered: