It is currently March 28th, 2024, 8:52 pm

Solved: Random FontFace from text file or @Resources folder

Get help with installing and using Rainmeter.
the_metal_lord
Posts: 27
Joined: April 3rd, 2018, 12:50 pm

Solved: Random FontFace from text file or @Resources folder

Post by the_metal_lord »

Hi!
I put couple of fonts into the @Resources folder, and I want random font each time the skin updates.

So I made a text file (FontFace.txt) and wrote the names of the fonts. Then used this-

Code: Select all

[MeasureFontFace]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=#CURRENTPATH#FontFace.txt
UpdateDivider=300
This is how the text file look-

Code: Select all

Caviar Dreams
Nexa Light
TT Chocolates Thin
Now, in the Meter I put this-

Code: Select all

FontFace=[MeasureFontFace]
But it's not properly working, it only shows the last font or the default Rainmeter font.

How to make it work properly? Or maybe any different way?
Last edited by the_metal_lord on April 4th, 2018, 4:07 am, edited 1 time in total.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Random FontFace from text file or @Resources folder

Post by ikarus1969 »

Hmmm.

If you want it to get a new font with every update then you should remove the UpdateDivider=300 from the "MeasureFontFace" measure (in case you have the default Update=100 in the rainmeter-section).

Additionaly, do you have a DynamicVariables=1 on the meter with FontFace=[MeasureFontFace]?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Random FontFace from text file or @Resources folder

Post by balala »

ikarus1969 wrote:(in case you have the default Update=100 in the rainmeter-section).
The default Update value is 1000, not 100 (probably this was a typo). But this doesn't matter too much, if there is an UpdateDivider=300 option, the [MeasureFontFace] measure will be updated on every 300th update cycle. No matter what the Update is set to.
The most important is to have set the DynamicVariables=1 option on the meter which uses the FontFace=[MeasureFontFace] option, as ikarus1969 said.
the_metal_lord
Posts: 27
Joined: April 3rd, 2018, 12:50 pm

Re: Random FontFace from text file or @Resources folder

Post by the_metal_lord »

Yeah, DynamicVariables=1 was already in the Meter. It just cycles through the last font and default Rainmeter font, other fonts are not showing up :( .
Is there way to use Random and lua script... I'm just totally confused.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Random FontFace from text file or @Resources folder

Post by jsmorley »

Fonts have to be loaded in Windows memory to use them. With Rainmeter, that means that the font must be installed in Windows, or it must reside in the @Resources\Fonts folder of the skin. If a font .ttf or .otf file is found in @Resources\Fonts when the skin is loaded, Rainmeter will load it into Windows memory and it can be used.

So getting the family name of the font is all well and good, but it won't use it if it isn't available.
the_metal_lord
Posts: 27
Joined: April 3rd, 2018, 12:50 pm

Re: Random FontFace from text file or @Resources folder

Post by the_metal_lord »

The fonts are already installed and all are in ttf or otf format.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1



[MeasureFile]
Measure=Plugin
Plugin=Plugins\QuotePlugin.dll
PathName=#CURRENTPATH#Quotes.txt
Subfolders=0
UpdateDivider=300
Substitute="---":"#CRLF#"


;-----------------------------

[MeterFile]
Meter=STRING
MeasureName=MeasureFile
StringAlign=Center
X=(#WORKAREAWIDTH# / 2)
Y=10
W=(#WORKAREAWIDTH# - 500)
H=600
FontFace=Nexa Light
FontSize=15
StringStyle=
FontColor=250,250,250,150
FontEffectColor=90,90,90,50
StringEffect=Shadow
Clipstring=2
DynamicVariables=1
AntiAlias=1
Last edited by the_metal_lord on April 3rd, 2018, 3:20 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Random FontFace from text file or @Resources folder

Post by balala »

the_metal_lord wrote:The fonts are already installed and all are in ttf or otf format.
Are installed in Windows?
However, could you please pack and upload the whole config (including the fonts, if they are in the @Resources\Fonts folder)? Just to check.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Random FontFace from text file or @Resources folder

Post by jsmorley »

Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureFontName]
Measure=Plugin
Plugin=QuotePlugin
PathName=#CURRENTPATH#FontFace.txt
UpdateDivider=2

[MeterTest]
Meter=String
FontSize=20
FontFace=[MeasureFontName]
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=[MeasureFontName]#CRLF##CRLF#Now is the time for all good men#CRLF#to come to the aid of their country#CRLF#12347890 !@#$%^&*(
FontFace.txt:

Code: Select all

Segoe UI
Trebuchet MS
Fira Sans
Calibri
Comic Sans MS
1.png
You do not have the required permissions to view the files attached to this post.
the_metal_lord
Posts: 27
Joined: April 3rd, 2018, 12:50 pm

Re: Random FontFace from text file or @Resources folder

Post by the_metal_lord »

jsmorley wrote:Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureFontName]
Measure=Plugin
Plugin=QuotePlugin
PathName=#CURRENTPATH#FontFace.txt
UpdateDivider=2

[MeterTest]
Meter=String
FontSize=20
FontFace=[MeasureFontName]
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=[MeasureFontName]#CRLF##CRLF#Now is the time for all good men#CRLF#to come to the aid of their country#CRLF#12347890 !@#$%^&*(
FontFace.txt:

Code: Select all

Segoe UI
Trebuchet MS
Fira Sans
Calibri
Comic Sans MS
1.png

- I tested this, still the same thing happening, only switching between the last font in the list (in this case Comic Sans) and default Rainmeter font. Other fonts are still not loading.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Random FontFace from text file or @Resources folder

Post by jsmorley »

Make sure that FontFace.txt is encoded as either ANSI or UTF-16 Little Endian. It won't work if it is encoded as UTF-8 w/BOM.