It is currently January 20th, 2019, 12:13 pm

New Inline Options for String meter

Changes made during the Rainmeter 3.3 beta cycle.
User avatar
Posts: 18663
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New Inline Options for String meter

jsmorley » July 31st, 2015, 3:13 pm

We have added some new String meter features to Rainmeter, with new Inline Options functionality.

Important Note: The entire Inline Options functionality requires that Rainmeter have D2D (Direct2D) enabled. This in effect means that this functionality is not supported on Windows XP, and will be ignored on that platform, or if D2D is disabled in the Settings in Rainmeter.

Inline Options

This feature will allow you to specify some existing and new string formatting for the String meter. This formatting can be done to all OR PART of the string. Which in effect allows you to do "inline" formatting. (thus the name)

This has three primary purposes:
  • Changing the inline format of part of the string. What this means is that you might have two or more FontFace, FontSize or FontColor (or other) settings in a string, without needing to use multiple meters and relative positioning.
  • Adding some Direct2D character formatting features to the String meter. These include things like more robust control of the Weight of the font, new style features like Character Spacing, Oblique, Underline and Strikethrough, and control of Stretch and Typography features when used with supporting fonts.
  • Support for a color Gradient on part or all of the string.
The formatting features supported by the new InlineSetting / InlinePattern options are:
  • Face
  • Size
  • Color
  • Weight
  • CharacterSpacing
  • Italic
  • Oblique
  • Underline
  • Strikethrough
  • Stretch
  • Typography
  • GradientColor
Rather than going into each of these here, I will direct you to carefully examine the documentation at:

Inline Options Documentation

You will find that there is a LOT that this adds to the String meter. The following is a series of skins in a .rmskin that demonstrates most of the new features, and some screenshots of the example skins:


You do not have the required permissions to view the files attached to this post.
User avatar
Posts: 18663
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Why InlineSetting=Weight is so cool

jsmorley » August 4th, 2015, 4:04 am

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)
Regular (Normal)
Semi Bold (Demi 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


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

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.
User avatar
Active Colors
Posts: 499
Joined: February 16th, 2012, 3:32 am

Re: New Inline Options for String meter

Active Colors » August 17th, 2015, 3:10 pm

Speaking of D2D, is there a way to display information about D2D? Like whether it is installed or not installed.
User avatar
Posts: 760
Joined: November 20th, 2012, 11:58 pm

Re: New Inline Options for String meter

FreeRaider » August 17th, 2015, 3:24 pm

If i am right, there is a .dll file in your System32 folder (under C:/Windows/).
User avatar
Posts: 18663
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Inline Options for String meter

jsmorley » August 17th, 2015, 3:31 pm

Active Colors wrote:Speaking of D2D, is there a way to display information about D2D? Like whether it is installed or not installed.
It's not really about "installed", as D2D is just always installed on Win7 with the Platform Update applied, on Win8 and on Wn10. It will never be available on a system running XP.

It's about whether or not it is "enabled" in Rainmeter, and that is a setting that can be "global" or set for an individual skin. It is set in Rainmeter.ini as "UseD2D", but defaults to "1" on a supported OS, and so you can't reliably just look for that setting, either in the [Rainmeter] section or in individual skin [ConfigName] sections.

I'm not sure there is any reasonable way to test for this right now. If you are going to be distributing your skin to folks using XP, and goodness knows I strongly suggest you just throw those Luddites under the bus, then you just won't be able to use any of the newer, cool stuff we are adding to Rainmeter.

I'm not kidding. Supporting XP is just a dead-end going forward. We will be releasing a version of Rainmeter before much longer that just won't support it at all. We are rapidly approaching the point where trying to support XP is just holding us back and making for a ton of extra work we don't need.
User avatar
Posts: 285
Joined: August 14th, 2009, 8:04 am

Re: New Inline Options for String meter

killall-q » January 14th, 2016, 8:02 pm

Hey, just noticed we have underline and strikethrough now. Might we see those backported to StringStyle= for ease of use?
User avatar
Posts: 367
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: New Inline Options for String meter

~Faradey~ » February 16th, 2016, 8:18 am

Really nice addition gotta give it a try :thumbup:

i'm so new now with this long many new things to discover sweet :D