How do I load fonts with filenames which begin with numbers, via the FontFace interface in Safari

我们两清 提交于 2021-02-10 17:04:05

问题


I can't get Safari(11.1) to load font files via the FontFace interface, if those files font names begin with numbers.

The same files that show an error in Safari load perfectly fine in Chrome and Firefox. Here is the most simplified version I could create that still produces the error.

var fonty = new FontFace('0Test', 'url(fonts/0Test.woff)');

console.log('This will only show if the Font name does not begin with a number');

Checking the Safari(11.1 is the version I'm using) console, you'll see the error: 'SyntaxError: The string did not match the expected pattern.', and when actual valid fonts that begin with numbers are used, it simply won't load.

Here's a jsfiddle that demonstrates the issue https://jsfiddle.net/0oknd7eL/1/

Is there a workaround to this situation, that still uses the FontFace interface?

Edit - To clarify, the issue is with the names of the fonts, and not the names of the files. For example FontFace('012-This-Beginning-With-Numbers-Is-The-Issue', 'url(fonts/012-This-Seems-Fine.woff)');

来源:https://stackoverflow.com/questions/56639922/how-do-i-load-fonts-with-filenames-which-begin-with-numbers-via-the-fontface-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!