是否可以在JavaScript中通过浏览器检测硬件加速?
我注意到,由于字体渲染发生变化,使用硬件加速的浏览器的字体大小并不相同 - 使字符显得更小。在具有水平导航的网站上,这实际上正在成为一个问题。
是否可以使用 JavaScript 或 JS 库来检测浏览器中是否启用(或禁用)硬件加速?
Modernizr 似乎没有提供这种选择。
I've noticed that font sizes are not the same across browsers which use hardware acceleration due to the font rendering changes - making characters appear smaller. On sites with horizontal navigation, this is actually becoming an issue.
Is it possible to use JavaScript or a JS library to detect hardware acceleration as being enabled (or disabled) in the browser?
Modernizr doesn't seem to offer this choice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
字体呈现因浏览器、操作系统和用户设置而异。因此,您的网站应该优雅地处理此类差异,而不是依赖于像素精确的字体渲染。硬件加速只是造成这种差异的又一个原因。
由于您实际上并不是想知道它是否是硬件加速的,而是在字体渲染方面存在差异,那么如何测量某些渲染文本的大小,并据此调整您的页面呢?
The font rendering differs depending on browser, OS and user settings. So your website should deal with such differences gracefully instead of relying on pixel exact font rendering. Hardware acceleration is just one more source of such differences.
Since you're not actually interested in finding out if it is hardware accelerated, but in differences in font rendering how about measuring the size some rendered text has, and adapt your page based on that?
由于您只对跨浏览器和平台的字体大小差异感兴趣,因此可能值得研究字体大小标准化技术。
我个人唯一熟悉的是 YUI Fonts CSS。我在所有项目中都使用它,并且使用了 HTML5Boilerplate 项目。
还有 CSS 排版框架,例如 Baseline、Typogridphy,Blueprint(我已经研究过这个,如果你去的话推荐它沿着这条路)最后是atatonic
Since you're only interested in the difference of font size across browsers and platforms, it might be worth looking into font size normalizing techniques.
The only one I'm personally familiar with is YUI Fonts CSS. I use it in all my projects and it's used the HTML5Boilerplate project.
There are also css typography frameworks such as the Baseline, Typogridphy, Blueprint (I've looked into this a recommend it if you go down this path) and finally atatonic
与其寻找缓慢渲染的解决方法,为什么不使用 underscore 的节流或反跳来减少刷新呢?
Rather than have workarounds for slow rendering, why not use underscore's throttle or debounce to reduce refreshes?
您无法获得处理器速度或内存大小
但你可以通过函数来了解硬件强度
you can't get processor speed or ram size
but you can make function to know the hardewre strength