It is currently March 28th, 2024, 9:06 am

Improved font rendering with Direct2D

Changes made during the Rainmeter 3.0 beta cycle.
Post Reply
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm
Contact:

Improved font rendering with Direct2D

Post by poiru »

The team is very excited to get working on a major change to Rainmeter. This change is why we have decided on a 3.0 version rather than 2.6.

During the 3.0 beta cycle, we are migrating from an older GDI+ graphics/text rendering system to the more powerful Direct2D system found in Windows 7 and later. The initial effort will be focused on vastly improved font rendering in String meters. The current font rendering method really results in poor quality display, particularly with smaller font sizes and anti-aliasing.

As you can see from the screenshots below, the new font rendering results in much higher quality text. However, there are still some issues (like issues with wrapping and a few missing features) that need additional development work. For this reason, we chose to keep it optional and "opt-in" by default for now.

Current font rendering:


Direct2D font rendering:



Enabling Direct2D rendering

The new font rendering requires Windows 7 or later. To enable it, set UseD2D=1 in the [Rainmeter] section of Rainmeter.ini. Rainmeter must be restarted for the changes to take effect. See the end of this post for a list of known issues.

In the Windows notification area, right-click the Rainmeter icon and select "Edit settings". Add the entry UseD2D=1 to the [Rainmeter] section. Exit and restart Rainmeter.

The new font rendering is powered by a combination of Direct2D and DirectWrite. The old font rendering is provided by GDI+, which is still used to render the majority of things (drawing lines, image scaling, etc.). As a result, only String meters will differ in quality at this point. In the future, we will likely make further use of Direct2D and the new capabilities it provides.

With UseD2D=1, your CPU usage and memory consumption may differ. If you notice substantial differences, please post before and after numbers for CPU usage and memory consumption.


Known issues

Below is a list of features that do not yet work with UseD2D=1.
  • Wrapping and relative positioning behavior is slightly different. We hope to minimize the differences between the new and old font rendering in upcoming beta releases. If you notice some oddities, don't hesitate to post.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Improved font rendering

Post by moshi »

Untitled-1.jpg
first impressions (left is GDI, right is Direct2D)

wether the font rendering is better is a matter of taste and probably also depends on the font.
at least with the font i use (look at the descriptions in the news feed) i think the GDI kerning is superior.

Direct2D does not recognize all fonts. i use FontFace=Source Sans Pro Semibold for some of the of the text. the default font is used with Direct2D.
http://sourceforge.net/projects/sourcesans.adobe/

on the Facebook part you can see 2 empty fields. these should not be there. the y position of the divider lines and the blue dots depend on section variables. (the heights of the Facebook messages. empty messages have a height of 0 with GDI)

Untitled-2.jpg
you guys sure this is only about fonts? it seems to break really simple calcualtion (for example for the white frame around the pictures.

Code: Select all

W=((([MeterThumbNail5:W])+8)*(#Image5On#))
H=((([MeterThumbNail5:H])+8)*(#Image5On#))
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Improved font rendering

Post by moshi »

(this is an answer to a post that no longer exists, please delete if obsolete)

not here and i have got it installed as well.

i have only the TTF installed though. can Rainmeter use OTF with Direct2D?

also, just to be sure. the lowercase g should look like this:
Untitled-1.jpg
User avatar
Brian
Developer
Posts: 2673
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Improved font rendering

Post by Brian »

moshi wrote:can Rainmeter use OTF with Direct2D?
Yes, but only if it is installed on your system. There is no support for LocalFont/@Resources/Fonts at this time, but we are working on it.

-Brian
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Improved font rendering

Post by jsmorley »

Yeah, I deleted my post as I found that although it does not seem to be using the "default" font (I assume that is still Arial), it isn't using the correct one either. That "g" you posted the image of is not what is used, nor is the "1" correct.

Not sure, we are going to have to poke around with it a bit.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Improved font rendering

Post by moshi »

jsmorley wrote:I assume that is still Arial
looks like the Segoe font family to me.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Improved font rendering

Post by jsmorley »

moshi wrote: looks like the Segoe font family to me.
You are right. It is Segoe UI
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Improved font rendering

Post by jsmorley »

I think the issue is with the "Semibold" on the font name. In Rainmeter, when a font file has a postfix to the font name like "verdanab.ttf", which has a "font name" of "Verdana Bold", the "family name" is still just "Verdana" and you get the effect with StringStyle=Bold.

FontFace in Rainmeter is the "family name", not the "font name".

So:

FileName: verdana.ttf
Font Name: Verdana
Family Name: Verdana

Rainmeter
FontFace=Verdana
StringStyle=Normal

FileName: verdanab.ttf
Font Name: Verdana Bold
Family Name: Verdana

Rainmeter
FontFace=Verdana
StringStyle=Bold

What Rainmeter is looking for with that font is:

FontFace=Source Sans Pro
StringStyle=SemiBold

Now, since there is no StringStyle=SemiBold, that obviously is not possible, and I think that is throwing it. Not sure why it ever worked in GDI+ and now doesn't in D2D, but we will explore that further.

That font family in general works fine with Rainmeter, as long as you use

FontFace=Source Sans Pro

Trouble is, although you can then use StringStyle=Bold and that works, that is not the end result you want I suspect.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Improved font rendering

Post by moshi »

no, i don't think so.

the file name is irrelevant. copy verdanab.ttf to the desktop, rename it to 558ds8s5d.ttf. try to install it.

what matters is the font name (not the file name) and the font weight (style).

this information is stored multiple times in a font (for different OSs, PostScript,etc.).
Untitled-1.jpg
what i encircled in blue is why it works in GDI.

now Direct2D is probably reading the needed information from somewhere else. i suspect at the bottom (preferred family, preferred style).
so maybe you are on the right track with StringStyle.

you might want to get FontForge to look deeper into this: http://sourceforge.net/projects/fontforge/
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Improved font rendering

Post by jsmorley »

Correct. I never meant to imply that the "file name" was of any importance at all. It is not. What matters is the "font name" which may be "MyFont Bold" and the "family name", which would be "MyFont". My point was that Rainmeter only cares about the "family name" and will insist on a StringStyle=Bold on the meter to use the font with the "font name" of "MyFont Bold".
Post Reply