检测 Javascript 中字体平滑设置的变化

发布于 2024-10-09 20:34:36 字数 307 浏览 0 评论 0原文

我有一个使用 @font-face 的页面,我正在使用 JavaScript 代码,根据是否启用字体平滑有条件地设置此字体中的文本。检测是沿着这些行完成的,但更复杂一些,可以区分 ClearType 和标准平滑。

在任何情况下,平滑检查都是在页面加载时完成的,我想了解是否有一种方法可以捕获页面加载后平滑首选项更改的事件。

谢谢

I have a page that uses @font-face and I am playing with the JavaScript code that conditionally sets the text in this typeface depending on whether the font smoothing is enabled. Detection is done along these lines, but a bit more elaborate to allow telling ClearType and Standard smoothing apart.

In any case the smoothing check is done on page load, and I want to understand if there is a way to capture the event of the smoothing preference changing once the page is loaded.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌生 2024-10-16 20:34:36

我没有找到一种方法可以在没有超时的情况下执行每 x 秒显示的检查 - 从资源的角度来看,这当然是次优的。

我认为没有任何 JavaScript 事件可以挂钩。如果平滑方法发生变化,包含文本的元素的大小可能会发生变化,但也可能不会发生变化。

I don't see a way to do this that works without a timeout to do the check you show every x seconds - which of course is sub-optimal from a resource point of view.

I don't think there is any JavaScript event to hook into. The size of an element that contains text might change if the smoothing method changes, but then it also might not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文