It is currently March 19th, 2024, 9:13 am

FontWeight Option

Changes made during the Rainmeter 4.1 beta cycle.
Post Reply
User avatar
jsmorley
Developer
Posts: 22632
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

FontWeight Option

Post by jsmorley »

Added new FontWeight option for the String meter.

This new option will give far better control over the weight of the font on String meters.
The weight of the font in the range 1-999.

The following are common values and their meanings. If the value is supported by the font family, it will be used. If not, the closest value that is supported by the font family will be used.

100 - Thin (Hairline)
200 - Extra Light (Ultra Light)
300 - Light
400 - Regular (Normal)
500 - Medium
600 - Semi Bold (Demi Bold)
700 - Bold
800 - Extra Bold (Ultra Bold)
900 - Black (Heavy)
950 - Extra Black (Ultra Black)

If the font does not support any additional weights, then 500 and below will use the font's normal weight, and 600 and above will simulate a bold effect. A value of "1" means "use the lightest weight the font family supports", and "999" means "use the heaviest weight the font family supports".
This should be used in place of the far less capable StringStyle option going forward.

Note that while this is pretty much the same as InlineSetting=Weight, that is kinda the point. While InlineSettings are powerful indeed, and are really useful for the "inline" part of the capabilities, the downside of using them all the time, even when you don't need anything "inline" is that they are a bit cumbersome to dynamically change with !SetOption and such. Since font "weight" is something you might use a lot, unlike more esoteric things like "underline" or "strikethrough", we wanted to get this capability front and center and as easy to use as possible.
rick-t-fiedrain
Posts: 26
Joined: February 15th, 2014, 9:53 am

Re: FontWeight Option

Post by rick-t-fiedrain »

In trying out the FontWeight= option this morning in comparison to the old StringStyle=BOLD option, I noticed that there is a significant change in positioning that also happens. Below I have a screen grab of the word "NOW:" as it looked using the old StringStyle and then after an update to FontWeight (I've included the code in the screen grabs so you can see what else is at work in the example.)
stringstyle.png
fontweight.png
The close screen grabs give a better look at the change in position.

This is the old StringStyle=BOLD output.
stringstylecloseup.png
This is the new FontWeight=800 output.
fontweightcloseup.png

Perhaps that is no biggie when writing a skin from scratch, but it sure means that updating older code will require that one invest a lot of time in re-positioning the text. Or, perhaps the usage of the inline style character spacing element is having an effect?

I'm guessing everything is operating as it should, but I was surprised to see the downward shift in positioning when only adjusting the look and feel of an element.

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

Re: FontWeight Option

Post by jsmorley »

Ok, here is the lowdown...

Rainmeter was originally written (long ago) using a graphical engine called GDI+. it's a standard Windows engine, and was, and to a large extent is, what Windows uses to display graphical output.

However, in the meantime, Microsoft has come out with Direct2D (referred to as D2D), which has a lot of advantages. The biggest of which is that it will use hardware acceleration. It also has some enhanced capabilities. This new D2D approach was made available as of Windows 7, and we started moving in that direction a few Rainmeter releases ago. While we are not done yet, it is our intention to make Rainmeter entirely D2D, and stop relying on GDI+ at all.

I need to stop at this point and make it clear that backwards compatibility, (we talk about BWC all the time) the ability to run "older" skins without issue in any "newer" version of Rainmeter, is really important to us. The gigantic library of existing skins on deviantART and other places, the hard work and creativity of the community, is our single biggest asset. We have no intention of destroying that, now or ever.

When D2D uses a font, and graphically renders text strings, it renders the position of the font within the required graphical "bounding box" slightly different than GDI+. While the D2D approach is much more accurate, and is really better, we found that changing to D2D for the String meter would cause BWC issues for older skins if we didn't do something.

So what we did was introduce some "fudging" of the font spacing to make D2D output as close as we could get to how GDI+ looks. It's very close indeed, and allows older skins running on recent versions of Rainmeter to look the same as they always did, while allowing us the advantages of D2D.

So we did that with all the existing options and behaviors of the String meter. They should look pretty much exactly as they always did as you move forward with newer versions of Rainmeter.

HOWEVER. With any "new" capabilities we add to the String meter, and D2D is going to offer several of them as we move forward, we are NOT doing any "fudging". There are no BWC issues with brand-new options and functionality. Obviously there are no "older" skins using them to be concerned about. New stuff is going to be full-out D2D in all respects.

So what that means is that while both InlineSettings=Weight and FontWeight are far, far better and more powerful than the older StringStyle option on a String meter, they are NOT a 1-for-1 replacement in older skins. If you do convert to using them, which I really recommend, some adjustments to position are very likely to be needed.
Post Reply