It is currently April 27th, 2024, 6:48 pm

[BUG | SUGGESTION] InlineSetting inherits Weight and Italic status from FontFace

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[BUG | SUGGESTION] InlineSetting inherits Weight and Italic status from FontFace

Post by Yincognito »

Introduction:
I'm building an "utility skin" for myself in order to find the Unicode character whose W and H are the same for all fonts (by the way, if anyone knows which is that character, if it exists, feel free to save me of the trouble to find out and let me know), by trying to iterate through all system fonts (done) and every Unicode character (to be done) to find it, and I've discovered something...

Skin:
Not sure if it's a bug or the intended behavior, but it still feels wrong in this case and obviously it affects the visual outcome of the skin:

Code: Select all

[Variables]
FontIdx=0

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,128

---Measures---

[FontList]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
OutputType=ValueList
UpdateDivider=-1

[FontItem]
Measure=String
String=[FontList]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*\R){0,#FontIdx#}?(.*) [(].*[)]\R.*$":"\1"
UpdateDivider=-1
DynamicVariables=1

---Meters---

[FontText]
Meter=String
W=500
FontEffectColor=0,0,0,255
FontColor=255,255,255,255
StringEffect=Shadow

; - Variable FontFace, Fixed Setting (issue: pattern inherits FontFace's weight and italic status) -
FontFace=[FontItem]
InlinePattern=^(.*?: ).*$
InlineSetting=Face | Tahoma
; - Have to manually reset pattern's weight to its Face default because of the above (possible: Y) -
InlinePattern2=^(.*?: ).*$
InlineSetting2=Weight | 400
; - Have to manually reset pattern's italic to its Face default because of the above (possible: N) -
;InlinePattern3=^(.*?: ).*$
;InlineSetting3=Italic | Yes or No

FontSize=16
AntiAlias=1
ClipString=2
UpdateDivider=-1
MeasureName=FontItem
Text=Font Item: %1
MouseScrollUpAction=[!SetVariable FontIdx (#FontIdx#-1)][!UpdateMeasure FontItem][!UpdateMeter FontText][!Redraw]
MouseScrollDownAction=[!SetVariable FontIdx (#FontIdx#+1)][!UpdateMeasure FontItem][!UpdateMeter FontText][!Redraw]
DynamicVariables=1
InlineSetting.jpg
Expectation:
- the 1st part of the string (i.e. Font Item: ) to stay Tahoma in its regular and non-italic default form
- the 2nd part of the string (i.e. [FontItem] aka %1) to be displayed according to the iterated font with its own weight and italic status

The "BUG":
If I only let the 1st InlineSetting above (like it should be normal and enough, at least in this case), the 1st part of the string inherits the weight and italic status from the 2nd part of the string aka the iterated font. Now, this might be the desired behavior in some cases when you'd want that status preserved, but it's not in this particular case, since it's about an entirely different font face... with its own weight and italic style. Hence, not sure it's a bug.

The "SUGGESTION":
To get to the desired form, I added the 2nd InlineSetting, which sets (back) the Weight of the 1st part of the string to its default (and font specific) value. However, I can't do that for the Italic status with the 3nd InlineSetting, since apparently, both the Italic and the Oblique inline settings assume the user only wants to turn the Italic/Oblique on and not off. Hence, the suggestion to add the possibility of setting those states OFF if desired, which would probably offer a solution to the "bug" as well.

Note:
The above behavior is also true if I'm doing things the other way, by setting the FontFace to Tahoma and the iniline Setting to the iterated font. Of course, the current code is more suited since when doing things the other way I'd have to check the iterated font face name for parts like "Bold", "Regular", "Italic" and so on.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
SilverAzide
Rainmeter Sage
Posts: 2613
Joined: March 23rd, 2015, 5:26 pm

Re: [BUG | SUGGESTION] InlineSetting inherits Weight and Italic status from FontFace

Post by SilverAzide »

Yincognito wrote: August 2nd, 2023, 12:45 am I'm building an "utility skin" for myself in order to find the Unicode character whose W and H are the same for all fonts (by the way, if anyone knows which is that character, if it exists, feel free to save me of the trouble to find out and let me know)...
U+200B ZERO WIDTH SPACE
U+200C ZERO WIDTH NON-JOINER

/jk :lol:
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG | SUGGESTION] InlineSetting inherits Weight and Italic status from FontFace

Post by Yincognito »

SilverAzide wrote: August 2nd, 2023, 2:34 am U+200B ZERO WIDTH SPACE

/jk :lol:
Good one... except it's freaking 0! :rofl: Very useful character otherwise, but even this can't do everything... :(
I need some char that can dynamically set the size of a square icon image, irrespective of font properties. :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Brian
Developer
Posts: 2687
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [BUG | SUGGESTION] InlineSetting inherits Weight and Italic status from FontFace

Post by Brian »

So, I don't think I would classify this as a bug because of the way the String meter and InlineSetting's were originally designed.

What happens is when the String meter options are read, it builds a "format" based on the fonts properties and any non-InlineSetting's options (mainly StringStyle and FontSize). The format's properties get applied to the entire meter.

When the meter is drawn, an object called a "text layout" is created based on the format. The layout allows each InlineSetting to be applied one at a time...but only the specific defined property. The Face property doesn't change any of the other properties from the format (like Italic). Each property would have to be defined separately as you found out.



What wasn't accounted for (maybe a oversight in the design?), is an InlineSetting option that can get the default setting from the the font located at the given location in the text (defined by InlinePattern).

What might be needed is several new options. Something like InlineSetting=Font that would not only change the font face, but get the default properties from the font (different from InlineSetting=Face which only changes the font face). And maybe other options for the other affected properties like Italic, Weight, Oblique, and Stretch. Something like InlineSetting=Italic | Default or something. Those 4 will be a bit more complicated since the font face could be different for each character that has been changed by other InlineSetting=Face options.



You probably already thought of this, but you could solve your issue with another String meter.
Something like this (didn't test it much):

Code: Select all

[Variables]
FontIdx=0

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,128

---Measures---

[FontList]
Measure=Registry
RegHKey=HKEY_LOCAL_MACHINE
RegKey=SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
OutputType=ValueList
UpdateDivider=-1

[FontItem]
Measure=String
String=[FontList]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*\R){0,#FontIdx#}?(.*) [(].*[)]\R.*$":"\1"
UpdateDivider=-1
DynamicVariables=1

---Meters---

[FontText_Label]
Meter=String
FontEffectColor=0,0,0,255
FontColor=255,255,255,255
StringEffect=Shadow

FontFace=Tahoma

FontSize=16
AntiAlias=1
ClipString=2
UpdateDivider=-1
MeasureName=FontItem
Text=Font Item:
MouseScrollUpAction=[!SetVariable FontIdx (#FontIdx#-1)][!UpdateMeasure FontItem][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FontIdx (#FontIdx#+1)][!UpdateMeasure FontItem][!UpdateMeter *][!Redraw]
DynamicVariables=1

[FontText]
Meter=String
MeterStyle=FontText_Label
X=R
Y=r
W=400

FontFace=[FontItem]

ClipString=2
Text=" %1"
MeasureName=FontItem
-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG | SUGGESTION] InlineSetting inherits Weight and Italic status from FontFace

Post by Yincognito »

Well, this certainly looks more complicated to solve, now that you explained it. My point here was that while the rest of the inline options allow free change in a direction or another (since most of them are just numbers), Italic and probably Oblique as well only allow "enabling" these, but not "disabling" them, for the pattern text. In other words, I don't think there would be 4 settings to deal with, but only the 2 I mentioned, and you wouldn't have to bother to set those 2 to a specific font's default, just "off", as this isn't possible ATM with inline settings.

I've already applied the breaking up into 2 meters immediately after posting the initial report (which is why I didn't answer SilverAzide's funny pun right away), I just thought this should have been possible via inline settings as well, that's all. Giving control to the user and all that. ;-)

Anyway, it's your call, whatever you think it's easier and more feasible.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth