wpf 在 IE9 中禁用 Cleartype(文本抗锯齿)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5427315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:42:05  来源:igfitidea点击:

Disable Cleartype (text anti-aliasing) in IE9

wpfinternet-explorer-9antialiasingcleartypedirectwrite

提问by Justin Grant

It's well documented (e.g. here) that IE9 ignores the OS-wide settings for font smoothing (aka anti-aliasing). Even if font-smoothing and ClearType are disabled in Windows, IE still shows anti-aliased fonts, which some users struggle to read, especially at small font sizes.

IE9 忽略了操作系统范围的字体平滑设置(又名抗锯齿),这是有据可查的(例如这里)。即使在 Windows 中禁用字体平滑和 ClearType,IE 仍然显示抗锯齿字体,有些用户难以阅读,尤其是在小字体时。

How can I disable all font anti-aliasing (ClearType or otherwise) in IE9?

如何在 IE9 中禁用所有字体抗锯齿(ClearType 或其他)?

More details:

更多细节:

Our company builds a web application which uses a lot of small fonts. With the release of IE9, some of our users have complained that IE9's default anti-aliasing makes our small fonts fuzzy or blurry. So we need to help our users who've installed IE9 and who want to turn off anti-aliasing.

我们公司构建了一个使用大量小字体的 Web 应用程序。随着 IE9 的发布,我们的一些用户抱怨 IE9 的默认抗锯齿使我们的小字体模糊或模糊。所以我们需要帮助已经安装了 IE9 并且想要关闭抗锯齿功能的用户。

Also, personally, I have trouble reading small, anti-aliased fonts, so I'd like a solution for my own use, even for sites I don't control.

另外,就我个人而言,我在阅读小的、抗锯齿的字体时遇到问题,所以我想要一个供我自己使用的解决方案,即使是我无法控制的网站。

In IE8 I could uncheck the "Always use ClearType for HTML" and then disable ClearType in the OS and IE8 would show all fonts aliased. But in IE9, this option is missing.

在 IE8 中,我可以取消选中“Always use ClearType for HTML”,然后在操作系统中禁用 ClearType,IE8 将显示所有字体别名。但是在 IE9 中,这个选项是缺失的。

After some research about the problem, here's what I've learned: the core issue is that IE relies on DirectWrite for text rendering and does not support any of the newer rendering options which would draw text without anti-aliasing and respect the user's OS-wide default choices.

在对该问题进行了一些研究之后,我了解到:核心问题是 IE 依赖 DirectWrite 进行文本渲染,并且不支持任何较新的渲染选项,这些选项会在没有抗锯齿的情况下绘制文本并尊重用户的操作系统-广泛的默认选择。

Making things worse, if you disable ClearType in the OS, in some cases IE will fall back to DirectWrite's default non-cleartype anti-aliasing which is even fuzzier than ClearType.

更糟糕的是,如果您在操作系统中禁用 ClearType,在某些情况下 IE 将回退到 DirectWrite 的默认非 cleartype 抗锯齿,这甚至比 ClearType 更模糊。

采纳答案by Justin Grant

After a few days of searching, I found an MSDN Forums threadwhich pointed me to a solution here: http://www.softwareninjas.ca/dwrite-dll-wrapper

经过几天的搜索,我找到了一个MSDN 论坛线程,它指向我这里的解决方案:http: //www.softwareninjas.ca/dwrite-dll-wrapper

Follow the instructions on that page and you'll remove anti-aliasing from IE9 (at least the 32-bit version of IE which is the default IE, even on 64-bit Windows 7). I've tested it so far on a Win7 x64 laptop and it worked flawlessly.

按照该页面上的说明操作,您将从 IE9(至少 32 位版本的 IE,即默认 IE,即使在 64 位 Windows 7 上)中删除抗锯齿。到目前为止,我已经在 Win7 x64 笔记本电脑上对其进行了测试,并且运行完美。

Big thanks to Olivier Dagenais who built this. Here's a technical summary of how his solution works.

非常感谢 Olivier Dagenais 建造了这个。这是他的解决方案如何工作的技术摘要。

It's a two-step process. First, you need to disable ClearType in IE via a registry key. This is the same setting which was available in previous versions of IE, but it was removed from the IE UI because it stopped working in IE9.

这是一个两步过程。首先,您需要通过注册表项在 IE 中禁用 ClearType。这与以前版本的 IE 中可用的设置相同,但它已从 IE UI 中删除,因为它在 IE9 中停止工作。

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
"UseClearType"="no"

Second, now that ClearType is disabled, Windows will fall back to a non-cleartype anti-aliasing solution. Now that fallback anti-alising also needs to be disabled. Quoting from the thread above:

其次,既然 ClearType 被禁用,Windows 将回退到非 cleartype 抗锯齿解决方案。现在还需要禁用回退抗锯齿。引用上面的线程:

What is left is the font smoothing (aka sub-pixel rendering), and that is the "blurring effect" you still see after turning cleartype off.

In case you were wondering, there is a way to turn that off too.

The method i used to turn off the sub-pixel wonder is to build a simple wrapper for dwrite.dll which intercepts and forwards calls to the real dwrite.dll, disabling font smoothing in the process.

You can download it from: http://www.softwareninjas.ca/dwrite-dll-wrapper

You can find the code at https://softwareninjas.kilnhg.com/Repo/Open-Source/Group/DWrite-dll-Wrapper

剩下的是字体平滑(又名子像素渲染),这就是关闭 cleartype 后您仍然看到的“模糊效果”。

如果您想知道,也有一种方法可以将其关闭。

我用来关闭子像素奇迹的方法是为 dwrite.dll 构建一个简单的包装器,它拦截并将调用转发到真正的 dwrite.dll,在此过程中禁用字体平滑。

您可以从以下位置下载:http: //www.softwareninjas.ca/dwrite-dll-wrapper

您可以在https://softwareninjas.kilnhg.com/Repo/Open-Source/Group/DWrite-dll-Wrapper找到代码

This was a pretty cool hack. Probably somewhat brittle across windows and DirectX releases, but will do the trick for now until Microsoft gets their act together to fix the underlying "can't disable anti-aliasing" problem in IE itself.

这是一个非常酷的黑客。在 Windows 和 DirectX 版本中可能有点脆弱,但在微软联合起来解决 IE 本身中潜在的“无法禁用抗锯齿”问题之前,它们现在会起作用。

It also works for apps which use the IE WebBrowser control (aka MSHTML), so you can control anti-aliasing on an app-by-app basis. It also works for the HTML Help viewer.

它也适用于使用 IE WebBrowser 控件(又名 MSHTML)的应用程序,因此您可以逐个应用程序控制抗锯齿。它也适用于 HTML 帮助查看器。

Note that the text quality in IE9 standards mode isn't ideal. Specifically, small fonts sometimes have letters sometimes run together without the usual one-pixel space between them. If you render the same page in compatibility mode (or your site uses a non-strict DTD or other non-standards-enforcing DTD), then it looks fine. So there's an additional step for some sites if they want the best aliased text rendering: just view a site in compatibility mode by pressing the compatibility button in IE's toolbar.

请注意,IE9 标准模式下的文本质量并不理想。具体来说,小字体有时会将字母组合在一起,而它们之间通常没有一个像素的空间。如果您在兼容模式下呈现相同的页面(或者您的站点使用非严格 DTD 或其他非标准执行 DTD),那么它看起来不错。因此,如果某些站点想要最佳的别名文本呈现,则需要额外的步骤:只需按 IE 工具栏中的兼容性按钮以兼容模式查看站点。

回答by David d C e Freitas

To answer your question directly:

要直接回答您的问题:

ClearType font rendering is used in all IE9 document modes; sub-pixel positioning is used only in IE9's default standards mode. IE9's compatibility modes—Quirks, 7, and 8—use whole-pixel text metrics.

ClearType 字体渲染用于所有 IE9 文档模式;子像素定位仅用于 IE9 的默认标准模式。IE9 的兼容模式——Quirks、7 和 8——使用全像素文本度量。

So try switching your doctype to use Quirks mode:

因此,尝试切换您的文档类型以使用Quirks 模式

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

The other thing to consider is to try avoid point based font sizes.

要考虑的另一件事是尽量避免基于点的字体大小



Important information regarding fonts, blurriness and rendering in IE9

有关 IE9 中字体、模糊度和渲染的重要信息

MSDN sources:

MSDN 来源:

回答by user214553

The info here solves two problems: 1. Getting rid of cleartype and font smoothing in IE9 2. Getting rid of cleartype and font smoothing when IE10 is installed or installs itself automatically

这里的信息解决了两个问题: 1. 去掉 IE9 中的 cleartype 和字体平滑 2. 去掉 IE10 安装或自动安装时的 cleartype 和字体平滑

I had done a registery hack to turn off cleartype in IE9: [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main] "UseClearType"="no" and used a little piece of freeware to get rid of font smoothing in IE9: https://softwareninjas.kilnhg.com/Repo/Open-Source/Group/DWrite-dll-Wrapper

我做了一个注册黑客来关闭 IE9 中的 cleartype:[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main] "UseClearType"="no" 并使用了一小块免费软件来摆脱 IE9 中的字体平滑: https: //softwareninjas.kilnhg.com/Repo/Open-Source/Group/DWrite-dll-Wrapper

Then IE10 automatically installed itself and the blurry type was back. I tried uninstalling IE 10, which wasn't through the add/remove programs interface but rather through the installed updates interface--removing the IE10 update. That ostensibly took me back to IE9, but the blurry type remained in spite of the fact that "no" was still the answer for cleartype in the registry and the two .dll files were still in my IE program folder.

然后IE10自动安装,模糊类型又回来了。我尝试卸载 IE 10,这不是通过添加/删除程序界面,而是通过安装的更新界面——删除 IE10 更新。这表面上让我回到了 IE9,但模糊类型仍然存在,尽管“否”仍然是注册表中 cleartype 的答案,并且两个 .dll 文件仍在我的 IE 程序文件夹中。

So, I decided to uninstall IE9 and reinstall it. That also involved going through the installed updates interface and removing the IE9 update.

所以,我决定卸载IE9并重新安装它。这还涉及浏览已安装的更新界面并删除 IE9 更新。

I rebooted and expected to have to reinstall the program, but my IE icon was still there. When I clicked it, IE9 opened with nice, sharp type.

我重新启动并预计必须重新安装程序,但我的 IE 图标仍然存在。当我点击它时,IE9 以漂亮、清晰的字体打开。