Why InlineSetting=Weight is so cool
One of the things we have added in the Online Options stuff is the ability to set the "weight" of part or all of a string.
That in and of itself is pretty nice, being able to highlight one word in a string "bold" for instance. However, that isn't the best part of this functionality.
A whole new way of dealing with Fonts, Font Families and Font Weights
There are a couple of hidden secrets with D2D (specifically DirectWrite) when using fonts.
The first is that both .ttf (TrueType) and .otf (OpenType) fonts are fully supported.
The second, and what I think is a huge improvement, is that D2D will automatically create what is called a "font collection" of all the fonts that have the same "base family name" when you use the font in your skin. Let me lay out how it works now without D2D and InlineOptions, then I will show how much better it can be.
The problem
Say you have fonts like this. It is very common:
File: MyFont-Regular.ttf
Family Name: MyFont
SubFamily: Regular
File: MyFont-SemiBold.ttf
Family Name: MyFont
SubFamily: SemiBold
File: MyFont-Bold.ttf
Family Name: MyFont
SubFamily: Bold
With FontFace and StringStyle now, you can use FontFace=MyFont, and then either StringStyle=Normal or StringStyle=Bold. Rainmeter will always use the "Regular" SubFamily variant of the font if you specific StringStyle=Normal or don't use a StringStyle, and will use the "Bold" SubFamily variant if you specify StringStyle=Bold.
However, the only way you can use the "SemiBold" SubFamily is if that is the ONLY version of that font that is installed on your system or in the @Resources\Fonts folder of your skin. You can't specify StringStyle=SemiBold, it just doesn't support it. If you have both the "Regular" and "SemiBold" variants visible to Rainmeter, it will always use the "Regular" variant in this case.
So with our example fonts above, and using StringStyle, you will find it difficult to use any other weight but "Regular" and "Bold". With StringStyle, you can never specify StringStyle=SemiBold, and the only way to use it is to literally delete all other variants of the same font.
Another example of fonts might be like this. It is also very common:
File: MyFont-Regular.ttf
Family Name: MyFont
SubFamily: Regular
File: MyFont-SemiBold.ttf
Family Name: MyFont-SemiBold
SubFamily: Regular
File: MyFont-Bold.ttf
Family Name: MyFont-Bold
SubFamily: Regular
That case works a little bit better with the current approach, since you use the fonts by using the specific FontFace that you want. If you want to use "SemiBold" you specify FontFace=MyFont-SemiBold. Don't use any StringStyle at all, as it isn't needed or supported.
However, not only do you have to specify the weight you want on the FontFace option, you have to KNOW which of the two common methods described above the font you want to use is supporting. If the font is using "Family Name" to drive things, that is one approach and result, and if it is using "SubFamily Name", that is another.
The whole thing is just not acceptable.
For
3rd-party fonts, a lot of different weights has always been true. It has been a nightmare to use them in Rainmeter. There is a wild-wild-west mix of how Family and SubFamily are used in
3rd-party fonts, and your only alternative is a lot of trial-and-error.
With the fonts included in Windows, historically most of them (with a few exceptions like Segoe UI and Calibri) have only supported "Regular" and "Bold" anyway, due to Windows tending to live in a 1998 GDI+ world for backwards compatibility. That is changing, and Windows 10 will soon be adding a bunch of new font variants with multiple weights and styles. Those are going to be hard to use with StringStyle as well when they hit.
These are the common font weight "names" you may find in the font file name, Family, and / or SubFamily values:
Thin (Hairline)
Extra Light (Ultra Light)
Light
Regular (Normal)
Medium
Semi Bold (Demi Bold)
Bold
Extra Bold (Ultra Bold)
Black (Heavy)
Extra Black (Ultra Black)
With the old StringStyle approach, it has been very difficult indeed to use any of the variants other than Regular and Bold. A lot of trial-and-error, and making sure that only the variant(s) you want are visible to Rainmeter.
The solution
When Inline Options are used, be that "Weight", which we are talking about here, but also with Italic and Oblique and Expanded / Compressed, a different and far more powerful approach is used.
When a FontFace is used in Rainmeter, be it either:
File: MyFont-SemiBold.ttf
Family Name: MyFont
SubFamily: SemiBold
or
File: MyFont-SemiBold.ttf
Family Name: MyFont-SemiBold
SubFamily: Regular
D2D will automatically convert all the "Family Names" used to just "MyFont", and will create an internal "font collection" of all the variants supported by that font. It doesn't use SubFamily at all, that just isn't needed and is ignored.
Then using any of the supported
numeric weights in InlineSetting=Weight | ..
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)
The correct, or closest, variant of that font will be used. It doesn't matter what the file names are, it doesn't matter what the Family Names have appended on them, and it doesn't matter what the SubFamily Names are. If you use ANY form of FontFace=MyFont or FontFace=MyFont-SemiBold, it will choose the correct font to use
based on the numeric weight.
So no matter how a font supports the standard weights listed above, you can just put all the .ttf or .otf files you want to use in your skin in @Resources\Fonts, or even install them all in Windows, and just use FontFace=MyFont and InlineSetting=Weight | 600 to get the actual and correct "SemiBold" variant of the font if it exists. Not only that, but even if you use FontFace=MyFont-Thin and set InlineSetting=Weight | 600, it will still use the actual and correct "SemiBold" variant as long as it exists. If it doesn't, it will try to find the closest weight to 600 that does exist, and use that.
If you use Weight | 100 and there is no "Thin" font for that font collection, but there is a "Light" variant, it will automatically use 300 instead.
Weights from 500 or less will "round down" when looking for the closest match. Weights from 600 or more will "round up".
So that's why...
It's hard to even explain how much better this is than the old FontFace/StringStyle approach. It opens up a large number new options for using font weights (and other style effects) in your skins, and to be honest I doubt I will ever use StringStyle in a skin again. Even when I want "Bold", it is just as easy, and more reliable, to use:
InlineSetting=Weight | 700
InlinePattern=.*
on the String meter, even if I'm not actually doing weight changes "inline" in the string. Pretty often either 500 (Medium) or 600 (SemiBold) looks nicer anyway, as long as the font supports them.
That means my skins won't look right on XP, but I'll be honest. I don't care. Nobody should still be on XP. Period.