It is currently March 29th, 2024, 9:17 am

Text resizing

Get help with creating, editing & fixing problems with skins
Ziettol
Posts: 4
Joined: May 14th, 2018, 7:45 pm

Text resizing

Post by Ziettol »

Hey,
i try to work it out by myself but i'm getting frustrated -_- I need to make something to simply change FontSize according to the text Width and Height for the Weather Reader. That's what i got. Any help?

Code: Select all

[Rainmeter]
MouseOverAction=[!ShowMeterGroup MusicHover][!Redraw]
MouseLeaveAction=[!HideMeterGroup MusicHover][!Redraw]
MiddleMouseUpAction=[!CommandMeasure "MeasureSong" "PlayPause"]
ContextTitle=Open Config Menu
ContextAction=[!ActivateConfig #RootConfig#\Config]

[MetaData]
Name=Amnio: Current's Weather
Author=JosephB2000
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 4.0

[Variables]
Size1=50
Size2=100
Width=([CurrentDesc:H])
@includeStyles=#@#Styles.inc

@includeVariables=#@#Variables.inc

;-------------------------------------------
; MEASURES
;-------------------------------------------

@includeMeasures=#@#Measures\WeatherMeasures.inc

;-------------------------------------------
; MAIN APPEARANCE
;-------------------------------------------

[InvisibleBackground]
Meter=String
W=163
H=350
SolidColor=0,0,0,1

;-------------------------------------------
; CURRENT

[CurrentIcon]
Meter=Image
MeasureName=MeasureWeatherIcon
ImagePath=#@#Images\Weather
W=75
H=75
Y=125
X=55
ImageTint=255,255,255,150

[CurrentTemp]
Meter=String
MeasureName=MeasureWeatherTemp
MeterStyle=FontStyleVegurLight
X=125
Y=130
Text=%1°
FontSize=35
FontColor=#MainColour#,230


[CurrentDesc]
Meter=String
MeasureName=MeasureWeatherDesc
MeterStyle=FontStyleVegurRegular
X=120
Y=0
Padding=15,5,15,5
FontColor=255,255,255,230
SolidColor=0,0,0,0
FontFace=la Compagnie des Ombres
AntiAlias=1
ClipString=1
StringAlign=Center
AntiAlias=1
Text=%1
IfCondition=#Width#<120
IfTrueAction=[!SetOption CurrentDesc FontSize #Size2#]
FontSize=#Size1#
DynamicVariables=1
DynamicWindowSize=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Text resizing

Post by balala »

Ziettol wrote:I need to make something to simply change FontSize according to the text Width and Height for the Weather Reader. That's what i got. Any help?
We can't test the provided code, because it uses a few files which we don't have (like Styles.inc, Variables.inc or WeatherMeasures.inc - all of them are included through some @Include options).
However, take care that the IfCondition option can't be used on meters, just on measures. Move the IfCondition / IfTrueAction options pair from the [CurrentDesc] meter, to a measure, eg to a measure included into the WeatherMeasures.inc file (the provided code doesn't have measures, probably all of them are included into the mentioned .inc file). Just take care to also add a DynamicVariables=1 to the same measure, if it doesn't have it yet.
Ziettol
Posts: 4
Joined: May 14th, 2018, 7:45 pm

Re: Text resizing

Post by Ziettol »

So, i tried to move everything to one code, so you will be able to test it now :) I added the conditions to MeaserWeatherTemp but still no effect :(

Code: Select all

;-------------------------------------------
; MEASURES
;-------------------------------------------

[MeasureCurrent]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=http://xml.weather.com/weather/local/#WeatherCode#?cc=*&unit=#Unit#&dayf=0
RegExp="(?siU).*<tmp>(.*)</tmp>.*<t>(.*)</t>.*<icon>(.*)</icon>"

[MeasureWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=1
IfCondition=[CurrentDesc:W]>120
IfTrueAction=[!SetOption CurrentDesc FontSize #Size2#]
IfCondition=[CurrentDesc:W]<120
IfTrueAction=[!SetOption CurrentDesc FontSize #Size1#]
DynamicVariables=1

[MeasureWeatherDesc]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=2
Substitute=" And ":" and ","Snow/":"Snow and ","Lgt.":"Light ","T-Storm":"Thunder Storm","":"Unknown"

[MeasureWeatherIcon]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=3
Substitute="":"na"

[Variables]
Size1=50
Size2=100
#on#=1
#off#=0
FrameW=250
FrameH=150
Width=#CurrentDesc:H#

MainColour=255,255,255
SecondaryColour=0,0,0
TertiaryColour=255,255,255
QuaternaryColour=0,0,0
QuinaryColour=0,0,0

Analogue=ue
Colour=u

Unit=m
    ;f
WeatherCode=PLMZ4628

;-------------------------------------------
; STYLES
;-------------------------------------------

[FontStyleVegurLight]
FontFace=steelfish rg
FontColor=#MainColour#,255
AntiAlias=1

[FontStyleVegurRegular]
FontFace=la Compagnie des Ombres
FontColor=#MainColour#,150
AntiAlias=1

;-------------------------------------------
; MAIN APPEARANCE
;-------------------------------------------

[InvisibleBackground]
Meter=String
W=300
H=350
SolidColor=0,0,0,1

;-------------------------------------------
; CURRENT

[CurrentIcon]
Meter=Image
MeasureName=MeasureWeatherIcon
ImagePath=#@#Images\Weather
W=75
H=75
Y=125
X=55
ImageTint=255,255,255,150

[CurrentTemp]
Meter=String
MeasureName=MeasureWeatherTemp
MeterStyle=FontStyleVegurLight
X=125
Y=130
Text=%1°
FontSize=35
FontColor=#MainColour#,230


[CurrentDesc]
Meter=String
MeasureName=MeasureWeatherDesc
MeterStyle=FontStyleVegurRegular
X=120
Y=0
W=#FrameW#
H=#FrameH#
FontColor=255,255,255,230
AntiAlias=1
ClipString=1
StringAlign=Center
Text=Light Rain Shower
FontSize=#Size2#
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Text resizing

Post by balala »

Ziettol wrote:I added the conditions to MeaserWeatherTemp but still no effect :(
As usually, you can't use twice (or more times) the same option into one single section. You have two IfCondition and two IfTrueAction options in the [MeasureWeatherTemp] measure. Number them:

Code: Select all

[MeasureWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=1
IfCondition=[CurrentDesc:W]>120
IfTrueAction=[!SetOption CurrentDesc FontSize #Size2#]
IfCondition2=[CurrentDesc:W]<120
IfTrueAction2=[!SetOption CurrentDesc FontSize #Size1#]
DynamicVariables=1
A few other comments:
  • Add an UpdateDivider=-1 option to the [InvisibleBackground] meter, because doesn't worth to update this meter continuously.
  • This question was discussed many times here on the forum: the Unit variable should have to be either m (metric, eg for temperatures in Celsius), or i (imperial - temperatures in Fahrenheit). The f value works only because if there is added any other value then m, Weather.com returns the results in the imperial units (you have commented out the f value, but I suppose you used it, at least for tryouts).
  • Although this definitely isn't a mistake and the code works same way, newly WebParser became measure. It's not any more a plugin. That's why I suggest to replace the

    Code: Select all

    Measure=Plugin
    Plugin=Plugins\WebParser.dll
    options with a single Measure=WebParser (but as I said, even if you leave them as you had, the code will keep working).
Ziettol
Posts: 4
Joined: May 14th, 2018, 7:45 pm

Re: Text resizing

Post by Ziettol »

So i tried everything you said in the post but still can't get it to work. I want to make the longer descriptions as "Light Shower Rain" smaller as they wrap and take more space and short descriptions of weather as "Fair" larger so they look nice on the desktop. Here is the code that i tried to use after yours advices.

Code: Select all

;-------------------------------------------
; MEASURES
;-------------------------------------------

[MeasureCurrent]
Measure=WebParser
UpdateRate=1800
Url=http://xml.weather.com/weather/local/#WeatherCode#?cc=*&unit=#Unit#&dayf=0
RegExp="(?siU).*<tmp>(.*)</tmp>.*<t>(.*)</t>.*<icon>(.*)</icon>"

[MeasureWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=1
IfCondition=[CurrentDesc:W]>100
IfTrueAction=[!SetOption MeasureWeatherDesc FontSize #Size1#]
IfCondition2=[CurrentDesc:W]<100
IfTrueAction2=[!SetOption MeasureWeatherDesc FontSize #Size2#]
DynamicVariables=1

[MeasureWeatherDesc]
Measure=WebParser
Url=[MeasureCurrent]
StringIndex=2
Substitute=" And ":" and ","Snow/":"Snow and ","Lgt.":"Light ","T-Storm":"Thunder Storm","":"Unknown"

[MeasureWeatherIcon]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=3
Substitute="":"na"

[Variables]
Size1=45
Size2=83
FrameW=270
FrameH=140
Width=#CurrentDesc:H#

MainColour=255,255,255
SecondaryColour=0,0,0
TertiaryColour=255,255,255
QuaternaryColour=0,0,0
QuinaryColour=0,0,0

Analogue=ue
Colour=u

Unit=m
WeatherCode=PLMZ4628

;-------------------------------------------
; STYLES
;-------------------------------------------

[FontStyleVegurLight]
FontFace=steelfish rg
FontColor=#MainColour#,255
AntiAlias=1

[FontStyleVegurRegular]
FontFace=la Compagnie des Ombres
FontColor=#MainColour#,150
AntiAlias=1

;-------------------------------------------
; MAIN APPEARANCE
;-------------------------------------------

[InvisibleBackground]
Meter=String
W=300
H=355
SolidColor=0,0,0,1
UpdateDivider=-1

;-------------------------------------------
; CURRENT

[CurrentIcon]
Meter=Image
MeasureName=MeasureWeatherIcon
ImagePath=#@#Images\Weather
W=55
H=55
Y=115
X=190
ImageTint=255,255,255,230

[CurrentTemp]
Meter=String
MeasureName=MeasureWeatherTemp
MeterStyle=FontStyleVegurLight
X=250
Y=110
Text=%1°C
FontSize=35
FontColor=#MainColour#,230

[CurrentDesc]
Meter=String
MeasureName=MeasureWeatherDesc
MeterStyle=FontStyleVegurRegular
X=250
Y=-5
W=#FrameW#
H=#FrameH#
FontColor=255,255,255,230
AntiAlias=1
ClipString=1
StringAlign=Center
Text=Fire
FontSize=#Size1#
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Text resizing

Post by balala »

Ziettol wrote:So i tried everything you said in the post but still can't get it to work. I want to make the longer descriptions as "Light Shower Rain" smaller as they wrap and take more space and short descriptions of weather as "Fair" larger so they look nice on the desktop. Here is the code that i tried to use after yours advices.
A few more problems:
  • The measures (doesn't matter what type) don't have a FontSize option, you can't set their font size. [MeasureWeatherDesc] is a measure, so you can't apply a FontSize option to it, through the !SetOption bangs of the IfTrueAction and IfTrueAction2 options (of the [MeasureWeatherTemp] measure). You should have to apply this option to a String meter (however I'm not sure to which one you would like).
  • The IfCondition options of the [MeasureWeatherTemp] measure don't include the case when the width of the [CurrentDesc] meter would be exactly 100 (100 is nor less, nor higher then 100). I probably would modify those options, creating a single IfCondition, one single IfTrueAction and one IfFalseAction. This way every possible value of the variable would be included somewhere (but also see below another problem).
  • Even if the IfConditions would be applied correctly and would work, the [CurrentDesc] meter has a fixed width (through its W=#FrameW# option). This makes always true the IfCondition and false the IfCondition2 (the value of the FrameW variable is set to 270 in the [Variables] section). See below a solution.
    One solution would be to add a second String meter, with exactly the same settings as the first one, excepting its size and color. It should have to be(almost) transparent (to not disturb). After this you can rewrite the IfConditions, to compare the width of this new meter with 100.
If you don't succeed rewriting all this, please first decide what String meter you would like to apply the new font size to. If this will be clarified, I'll try to rewrite the code.
Ziettol
Posts: 4
Joined: May 14th, 2018, 7:45 pm

Re: Text resizing

Post by Ziettol »

Thanks! Managed to make it work! :)

Code: Select all

;-------------------------------------------
; MEASURES
;-------------------------------------------

[MeasureCurrent]
Measure=WebParser
UpdateRate=1800
Url=http://xml.weather.com/weather/local/#WeatherCode#?cc=*&unit=#Unit#&dayf=0
RegExp="(?siU).*<tmp>(.*)</tmp>.*<t>(.*)</t>.*<icon>(.*)</icon>"

[MeasureWeatherTemp]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=1
IfCondition=[CurrentDesc2:W]>200
IfTrueAction=[!SetOption CurrentDesc FontSize #Size1#]
IfCondition2=[CurrentDesc2:W]<=200
IfTrueAction2=[!SetOption CurrentDesc FontSize #Size2#]
IfCondition2=[CurrentDesc2:W]<=120
IfTrueAction2=[!SetOption CurrentDesc FontSize #Size3#]
DynamicVariables=1

[MeasureWeatherDesc]
Measure=WebParser
Url=[MeasureCurrent]
StringIndex=2
Substitute=" And ":" and ","Snow/":"Snow and ","Lgt.":"Light ","T-Storm":"Thunder Storm","":"Unknown"

[MeasureWeatherIcon]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureCurrent]
StringIndex=3
Substitute="":"na"

[Variables]
Size1=45
Size2=60
Size3=80
FrameW=250
FrameH=160
Width=#CurrentDesc:H#

MainColour=255,255,255
SecondaryColour=0,0,0
TertiaryColour=255,255,255
QuaternaryColour=0,0,0
QuinaryColour=0,0,0

Analogue=ue
Colour=u

Unit=m
WeatherCode=PLMZ4628

;-------------------------------------------
; STYLES
;-------------------------------------------

[FontStyleVegurLight]
FontFace=steelfish rg
FontColor=#MainColour#,255
AntiAlias=1

[FontStyleVegurRegular]
FontFace=la Compagnie des Ombres
FontColor=#MainColour#,150
AntiAlias=1

;-------------------------------------------
; MAIN APPEARANCE
;-------------------------------------------

[InvisibleBackground]
Meter=String
W=300
H=355
SolidColor=0,0,0,1
UpdateDivider=-1

;-------------------------------------------
; CURRENT

[CurrentIcon]
Meter=Image
MeasureName=MeasureWeatherIcon
ImagePath=#@#Images\Weather
W=55
H=55
Y=115
X=190
ImageTint=255,255,255,230

[CurrentTemp]
Meter=String
MeasureName=MeasureWeatherTemp
MeterStyle=FontStyleVegurLight
X=250
Y=110
Text=%1°C
FontSize=35
FontColor=#MainColour#,230

[CurrentDesc]
Meter=String
MeasureName=MeasureWeatherDesc
MeterStyle=FontStyleVegurRegular
X=250
Y=3
W=#FrameW#
H=#FrameH#
FontColor=255,255,255,230
AntiAlias=1
ClipString=1
StringAlign=Center
Text=%1
FontSize=#Size1#
DynamicVariables=1

[CurrentDesc2]
Meter=String
MeasureName=MeasureWeatherDesc
MeterStyle=FontStyleVegurRegular
X=250
Y=3
FontColor=255,255,255,001
AntiAlias=1
ClipString=1
StringAlign=Center
Text=%1
FontSize=#Size1#
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Text resizing

Post by balala »

But I see two more mistakes: in the [MeasureWeatherTemp] measure you have two IfCondition2 and two IfTrueAction2 options. The second ones should have to be IfCondition3 and IfTrueAction3.
Also, although the conditions are working, instead of the posted IfTrueAction2, I'd use the following one: IfCondition2=(([CurrentDesc2:W]<=200)&&([CurrentDesc2:W]>120)). The posted IfConditions, as you had them, wasn't completely clear, because if for example the width of the [CurrentDesc2] meter is 100, it can be included into both conditions (IfCondition2 and IfCondition3).

Code: Select all

[MeasureWeatherTemp]
Measure=WebParser
Url=[MeasureCurrent]
StringIndex=1
IfCondition=[CurrentDesc2:W]>200
IfTrueAction=[!SetOption CurrentDesc FontSize "#Size1#"]
IfCondition2=(([CurrentDesc2:W]<=200)&&([CurrentDesc2:W]>120))
IfTrueAction2=[!SetOption CurrentDesc FontSize "#Size2#"]
IfCondition3=[CurrentDesc2:W]<=120
IfTrueAction3=[!SetOption CurrentDesc FontSize "#Size3#"]
DynamicVariables=1
(Just as a side note, here I also replaced the Measure=Plugin and Plugin=Plugins\WebParser.dll options with Measure=WebParser. As I said before, WebParser became a measure, it's not any more a plugin, so this would be the correct form of the option(s). However the plugin form, due backward compatibility, still works).