我在各种平台上测试网络字体时遇到了一个奇怪的问题。我正在Windows Chrome font rendering issues使用Javascript navigator.appVersion
检查加上一个webkit媒体查询(因为Chrome和Safari是Webkit,如果在Windows Safari上可以排除),并创建了一个新问题过程
我在隐身测试中作为一种快速查看没有保存图像等的页面的方法,但对我来说这是一个新的。
我在if(navigator.appVersion.indexOf("Win")>-1
之后的else子句中的操作之前和之后都添加了控制台调试,所以我可以看到循环没有被任何错误的语法打破,并且没有抛出任何错误。
我认为这可能是Chrome操作系统中的一个错误,但在Linux Mint上,这两种类型的Chrome窗口都不会加载字体。清除缓存,cookie和映像文件对任一操作系统都没有影响。
屏幕截图:
"loaded"
,<style>
元素会按预期插入到DOM中。我对如何协调这里的不一致感到有点失落,因为我的Javascript在某些情况下运行,我对于什么是错误感到困惑。我很愿意联系任何有关此问题的专家论坛,但请告诉我,对于某些Chrome开发团队,我是否会更好。
如果有人想自己测试here's the page in the screenshots。
我还尝试以隐身身份登录GitHub和我的Google帐户,以防我看到与权限相关的问题,但它没有改变任何内容,无论如何仍然无法解释与Windows的不一致(两者都隐姓埋名) /定期)。这些文件存储在公共GitHub存储库中,即使在我的网站上没有字体渲染的情况下,我也可以在浏览器中访问它们。
<script>
if (navigator.appVersion.indexOf("Win")>-1) {
console.log("Win test")
chromeQuery = document.createElement('style');
chromeQuery.setAttribute('type','text/css');
chromeQuery.innerHTML = "@media screen and (-webkit-min-device-pixel-ratio:0) { /* Chrome-specific SVG font */ @font-face{ font-family: \"SEGOEUIL\"; src: local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.svg') format(\"svg\"), local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.woff') format('woff'), local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.ttf') format('truetype'); font-weight: normal; } @font-face{ font-family: \"SEGOEUIL\"; src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.svg') format(\"svg\"), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.woff') format('woff'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.ttf') format('truetype'); font-weight: bold; font-style: normal; } @font-face{ font-family: \"SEGOEUIL\"; src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.svg') format(\"svg\"), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.woff') format('woff'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.ttf') format('truetype'); font-style: italic; } }";
document.querySelector('head').appendChild(chromeQuery);
}
else {
fontload = document.createElement('style');
fontload.setAttribute('type','text/css');
fontload.setAttribute('id','fontload')
fontload.innerHTML = "@font-face{ font-family: \"SEGOEUIL\", \"Helvetica Neue\", Arial, sans-serif; src: local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.eot'); src: local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.eot?#iefix') format('embedded-opentype'), local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.woff') format('woff'), local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.ttf') format('truetype'), local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.svg') format('svg'); font-weight: normal; } @font-face{ font-family: \"SEGOEUIL\", \"Helvetica Neue\", Arial, sans-serif; src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.eot'); src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.eot?#iefix') format('embedded-opentype'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.woff') format('woff'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.ttf') format('truetype'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.svg') format('svg'); font-weight: bold; font-style: normal; } @font-face{ font-family: \"SEGOEUIL\", \"Helvetica Neue\", Arial, sans-serif; src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.eot'); src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.eot?#iefix') format('embedded-opentype'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.woff') format('woff'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.ttf') format('truetype'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.svg') format('svg'); font-style: italic; }";
document.querySelector('head').appendChild(fontload);
console.log('loaded')
}
</script>
<noscript><style id="fontload" type="text/css">
@font-face{
font-family: "SEGOEUIL", "Helvetica Neue", Arial, sans-serif;
src: local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.eot');
src: local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.eot?#iefix') format('embedded-opentype'),
local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.woff') format('woff'),
local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.ttf') format('truetype'),
local('Segoe UI Light'), url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/SEGOEUIL.svg') format('svg');
font-weight: normal;
}
@font-face{
font-family: "SEGOEUIL", "Helvetica Neue", Arial, sans-serif;
src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.eot');
src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.eot?#iefix') format('embedded-opentype'),
url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.woff') format('woff'),
url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.ttf') format('truetype'),
url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuisb.svg') format('svg');
font-weight: bold;
font-style: normal;
}
@font-face{
font-family: "SEGOEUIL", "Helvetica Neue", Arial, sans-serif;
src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.eot');
src: url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.eot?#iefix') format('embedded-opentype'),
url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.woff') format('woff'),
url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.ttf') format('truetype'),
url('https://raw.githubusercontent.com/lmmx/websiteresources/master/fonts/weblysleekuili.svg') format('svg');
font-style: italic;
}
</style></noscript>
编辑我在资源面板中看不到任何字体,所以我看不到成功的样子 - 我可以看到似乎是某种类型的opentype字体(延迟?)错误,这可能是相关的?
答案 0 :(得分:1)
有些事情看起来不对劲:
<noscript>
标记包围,因此只有在禁用JavaScript时才会加载您的字体@font-face
规则应将自定义字体映射到一个系列。所以font-family: "SEGOEUIL";
代替font-family: "SEGOEUIL", "Helvetica Neue", Arial, sans-serif;
font-weight
和font-style
。更改此选项会修复Chrome中的页面。