<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WPF Text Blog : ClearType</title><link>http://blogs.msdn.com/text/archive/tags/ClearType/default.aspx</link><description>Tags: ClearType</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>DirectWrite Questions and Answers</title><link>http://blogs.msdn.com/text/archive/2009/04/13/directwrite-questions-and-answers.aspx</link><pubDate>Tue, 14 Apr 2009 00:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9547344</guid><dc:creator>text</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/text/comments/9547344.aspx</comments><wfw:commentRss>http://blogs.msdn.com/text/commentrss.aspx?PostID=9547344</wfw:commentRss><description>&lt;P&gt;Hi, my name is Mikhail Leonov, and I’m a Senior Software Development Engineer on the DirectWrite team at Microsoft. I would like to address common user feedback on DirectWrite in a relatively informal ‘simple question – simple answer’ format. Feedback themes were gathered mostly from the user comments on various DirectWrite related blogs. Please feel free to post additional questions in the comments section right after this blog post. Throughout this post, I will assume the reader is familiar with DirectWrite basics. This link provides a good starting point: &lt;A href="http://channel9.msdn.com/pdc2008/PC18/" mce_href="http://channel9.msdn.com/pdc2008/PC18/"&gt;http://channel9.msdn.com/pdc2008/PC18/&lt;/A&gt;.&lt;/P&gt;
&lt;H5&gt;DirectWrite from the programmer’s point of view&lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;I want to experiment with DirectWrite in my application. How do I start using it?&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;DirectWrite can be used from native C++ code by including DWrite.h header file and linking to the DWrite.lib library. At the runtime, the application will automatically load DWrite.dll.&lt;/P&gt;
&lt;P&gt;To start with, the application needs to call &lt;CODE&gt;DWriteCreateFactory&lt;/CODE&gt;. The factory pointer returned by &lt;CODE&gt;DWriteCreateFactory&lt;/CODE&gt; implements &lt;CODE&gt;IDWriteFactory&lt;/CODE&gt; interface, which can be used to perform actions such as creating DirectWrite font and layout objects.&lt;/P&gt;
&lt;P&gt;For more information, please refer to the introductory DirectWrite materials linked in the beginning of this post.&lt;/P&gt;
&lt;H5&gt;DirectWrite on pre-Windows 7 operating systems&lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;My application needs to work on Vista and XP. Is using DirectWrite an option for me?&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;DirectWrite technology will ship first with Windows 7. After Windows 7 ships, DirectWrite will be made available for Windows Vista as well. There are no plans today to make DirectWrite available on Windows XP.&lt;/P&gt;
&lt;H5&gt;Microsoft platforms and applications using DirectWrite &lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;Does Microsoft use DirectWrite in its own products? I installed Windows 7, and I don’t see natural ClearType anywhere on the screen.&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;DirectWrite is used by the Windows 7 ClearType Text Tuner control panel applet and by the XPS Viewer application. It is worth noting that DirectWrite is a new technology, and it takes time for customers to evaluate their existing text functionality and determine how to take advantage of DirectWrite.&lt;/P&gt;
&lt;H5&gt;Supported font formats&lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;Does DirectWrite only support TrueType fonts? How about Type 1 fonts or bitmap fonts?&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;DirectWrite supports font files conformant to the OpenType specification version 1.5, which can be accessed here: &lt;A href="http://www.microsoft.com/typography/otspec/default.htm" mce_href="http://www.microsoft.com/typography/otspec/default.htm"&gt;http://www.microsoft.com/typography/otspec/default.htm&lt;/A&gt;. This support includes OpenType fonts with both TrueType and CFF outlines, and TrueType fonts with embedded bitmaps. Simply speaking, if your font has a TTF, OTF or TTC extension, DirectWrite should support it well.&lt;/P&gt;
&lt;P&gt;DirectWrite does not support bitmap or vector .FON font files, and DirectWrite does not support Adobe Type 1 .PFM/.PFB font files.&lt;/P&gt;
&lt;H5&gt;Installed fonts, local fonts, embedded fonts, per user fonts&lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;My application uses a custom font for certain user interface elements. Do I have to install it on the system in order for DirectWrite to be able to use it?&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, one doesn’t have to install a font in order for DirectWrite to be able to use it. DirectWrite provides full support for font files that are local to an application.&lt;/P&gt;
&lt;P&gt;The application that uses DirectWrite needs to register its own &lt;CODE&gt;IDWriteFontFileLoader&lt;/CODE&gt; interface implementation that manages the association between the font file location and contents. To support local font file enumeration functionality, the application needs to register its own &lt;CODE&gt;IDWriteFontCollectionLoader&lt;/CODE&gt; interface.&lt;/P&gt;
&lt;H5&gt;Rendering technologies to use DirectWrite with&lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;Can I use DirectWrite in my GDI+ application? How about using DirectWrite with Direct3D or GDI?&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;DirectWrite font stack is designed to be independent from any rendering technology, so clients have flexibility to use any existing rendering mechanism in their &lt;CODE&gt;IDWriteTextRenderer&lt;/CODE&gt; implementation. In addition, DirectWrite is designed to work well with Direct2D rendering components, and Direct2D provides convenient wrappers such as &lt;CODE&gt;ID2D1RenderTarget::DrawText()&lt;/CODE&gt; for drawing text on D2D surfaces.&lt;/P&gt;
&lt;P&gt;DirectWrite itself provides GDI interoperability helpers via &lt;CODE&gt;IDWriteGdiInterop&lt;/CODE&gt; interface. One can create a DirectWrite font face object that corresponds to a font selected in a GDI &lt;CODE&gt;HDC&lt;/CODE&gt; and easily replace &lt;CODE&gt;ExtTextOut(…, ETO_GLYPH_INDEX, …)&lt;/CODE&gt; calls with DirectWrite based glyph run drawing calls without requiring significant changes to the rest of the application code. One can also create a &lt;CODE&gt;LOGFONT&lt;/CODE&gt; description for a DirectWrite font face object to re-use existing GDI based controls from a DirectWrite based text processing component. On top of that, one can create GDI surfaces that satisfy DirectWrite rendering requirements through &lt;CODE&gt;IDWriteGdiInterop::CreateBitmapRenderTarget()&lt;/CODE&gt; method, and draw DirectWrite glyph runs on that surface using &lt;CODE&gt;IDWriteBitmapRenderTarget::DrawGlyphRun()&lt;/CODE&gt; method.&lt;/P&gt;
&lt;P&gt;Interoperability with GDI+ can be achieved via &lt;CODE&gt;GetHdc()&lt;/CODE&gt; and &lt;CODE&gt;FromHdc()&lt;/CODE&gt; methods provided by the GDI+ &lt;CODE&gt;Graphics&lt;/CODE&gt; object. The client has a choice of starting with a &lt;CODE&gt;Graphics&lt;/CODE&gt; object and only switching to &lt;CODE&gt;HDC&lt;/CODE&gt; methods for DirectWrite interoperability calls, or starting with an &lt;CODE&gt;HDC&lt;/CODE&gt; obtained from &lt;CODE&gt;IDWriteBitmapRenderTarget::GetMemoryDC()&lt;/CODE&gt; and switching to &lt;CODE&gt;Graphics&lt;/CODE&gt; object derived from it. Which of these two approached is the best depends on the application needs.&lt;/P&gt;
&lt;P&gt;Applications that render using Direct3D usually need to obtain text in either bitmap or outline form. To get the former, the client can ask DirectWrite to produce alpha textures containing text using &lt;CODE&gt;IDWriteGlyphRunAnalysis&lt;/CODE&gt; interface. To get the latter, the client can use &lt;CODE&gt;IDirectWriteFontFace::GetGlyphRunOutline()&lt;/CODE&gt; method to produce a geometry containing text.&lt;/P&gt;
&lt;H5&gt;Rendering quality&lt;/H5&gt;
&lt;BLOCKQUOTE&gt;&lt;EM&gt;How do I specify text rendering options in DirectWrite? I want to use the new natural ClearType for text paragraphs, while having text in my menus and buttons look like the rest of the operating system.&lt;/EM&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your case, two different measuring modes should be used—&lt;CODE&gt;DWRITE_MEASURING_MODE_NATURAL&lt;/CODE&gt; for text paragraphs, and &lt;CODE&gt;DWRITE_MEASURING_MODE_GDI_CLASSIC&lt;/CODE&gt; for menu and button text. The measuring mode then gets passed to drawing calls such as &lt;CODE&gt;ID2D1RenderTarget::DrawText()&lt;/CODE&gt; and &lt;CODE&gt;DrawGlyphRun()&lt;/CODE&gt; as an input parameter. For clients who create &lt;CODE&gt;IDWriteTextLayout&lt;/CODE&gt; themselves, &lt;CODE&gt;DWRITE_MEASURING_MODE_NATURAL&lt;/CODE&gt; corresponds to calling &lt;CODE&gt;IDWriteFactory::CreateTextLayout()&lt;/CODE&gt;, and &lt;CODE&gt;DWRITE_MEASURING_MODE_GDI_CLASSIC&lt;/CODE&gt; corresponds to calling &lt;CODE&gt;IDWriteFactory::CreateGdiCompatibleTextLayout()&lt;/CODE&gt; with &lt;CODE&gt;useGdiNatural&lt;/CODE&gt; set to &lt;CODE&gt;FALSE&lt;/CODE&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9547344" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/text/archive/tags/text+rendering/default.aspx">text rendering</category><category domain="http://blogs.msdn.com/text/archive/tags/ClearType/default.aspx">ClearType</category><category domain="http://blogs.msdn.com/text/archive/tags/vista/default.aspx">vista</category><category domain="http://blogs.msdn.com/text/archive/tags/DirectWrite/default.aspx">DirectWrite</category></item><item><title>Tips for improving your WPF text rendering experience</title><link>http://blogs.msdn.com/text/archive/2006/10/18/tips-for-improving-your-wpf-text-rendering-experience.aspx</link><pubDate>Thu, 19 Oct 2006 00:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:840267</guid><dc:creator>text</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/text/comments/840267.aspx</comments><wfw:commentRss>http://blogs.msdn.com/text/commentrss.aspx?PostID=840267</wfw:commentRss><description>&lt;SPAN style="FONT-SIZE: 14pt; FONT-FAMILY: Verdana"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;WPF uses the latest version of &lt;A href="http://www.microsoft.com/typography/WhatIsClearType.mspx" mce_href="http://www.microsoft.com/typography/WhatIsClearType.mspx"&gt;ClearType&lt;/A&gt; to render text. This version of ClearType has a few new features over the standard ClearType used in GDI and WinForms. You can read more about these features &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms749295.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms749295.aspx"&gt;here&lt;/A&gt;. &amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;STRONG&gt;We’ve found that a couple simple tips can improve your reading experience: &lt;o:p&gt;&lt;/o:p&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;-Make sure your monitor is set to its native resolution, typically the maximum resolution possible. This can be adjusted through Control Panel--&amp;gt;Display Properties on XP or Control Panel--&amp;gt; Adjust screen resolution on &lt;?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /&gt;&lt;st1:place w:st="on"&gt;Vista&lt;/st1:place&gt;.&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;-Use the ClearType tuner &lt;A href="http://www.microsoft.com/typography/ClearTypePowerToy.mspx" mce_href="http://www.microsoft.com/typography/ClearTypePowerToy.mspx"&gt;PowerToy&lt;/A&gt;. This adjusts the system's ClearType settings including pixel orientation and Gamma. Though WPF's ClearType engine is separate from GDI and WinForms, WPF still picks up these system wide settings. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;-For advanced users who are comfortable playing with regedit, there is one additional WPF ClearType setting that may help improve your experience: you can adjust the color level that WPF ClearType uses for sub-pixel anti-aliasing. At the moment this can only be tuned via registry keys, but we do have future plans to update the ClearType tuner to include this setting in a UI. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;To adjust this you will need to create this new reg key:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\&amp;lt;displayName&amp;gt;\&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;With &amp;lt;displayName&amp;gt; typically being 'DISPLAY1'. You can adjust things independently if you have multiple monitors. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Then create the following DWORD with any value between 0 and 100 (base 10):&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;I&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;ClearTypeLevel &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;The default value of 100 is the maximum amount of color and provides the greatest utilization of sub-pixels. On LCD panels this is the most optimal setting for the majority of users. If you perceive color fringes or halos around your text at a normal reading distance tune the value lower (You will need to restart any WPF application to see the effects of the change). The value of 0 uses only grayscale anti-aliasing and no color. Note if 'font smoothing' is turned off or set to ‘anti-alias’ on the system level, WPF will automatically render using grayscale anti-aliasing. Due to our pixel independent architecture we cannot render aliased text even if ‘font smoothing’ is turned off completely. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;-Chris Han&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=840267" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/text/archive/tags/text+rendering/default.aspx">text rendering</category><category domain="http://blogs.msdn.com/text/archive/tags/ClearType/default.aspx">ClearType</category></item></channel></rss>