It is currently April 18th, 2024, 7:08 pm

Align Text Vertically

Get help with creating, editing & fixing problems with skins
Grantp
Posts: 82
Joined: November 29th, 2010, 5:28 pm

Align Text Vertically

Post by Grantp »

Hi All,

Sorry if this has already been answered on the forum I have searched and not found an answer I understand.

I have a bar across my full screen and all I want to do is align test Horizontally & Vertically. Horizontal is straight forward but vertical is causing me problems seems to be trial and error.

For testing purposes I made it really big Bar Height 250 and FontSize 50, I had to make Y=88 to get Center of Character to be on Center line of the Bar.

Hope this makes sence and help would be appreciated.

Many thanks
Grant
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Align Text Vertically

Post by jsmorley »

It really is more or less "trial and error" to align meters vertically with each other. This is due to the fact that Rainmeter has no MeterAlignVert / MeterAlignHoriz capability, and probably can't. Aligning text horizontally within a single meter with StringAlign is pretty straightforward in code, but doing the same vertically with multiple meters would be... challenging. Really you would need both "align" and "distribute" like layers in Photoshop.

Then, even if you are looking to do it yourself with dynamic variables for the "Y" settings, it is still not easy to automate. Fonts are like snowflakes. They are very individual in how they are constructed, and there is no easy way to know how many "pixels" a font of any particular "point size" takes. A lot of fonts have varying white space around the actual characters, and in any case a font of FontSize=11 (points) is not always able to be translated into xxx pixels using any standard formula.
User avatar
karmat
Posts: 329
Joined: July 7th, 2009, 11:10 pm
Location: Canada

Re: Align Text Vertically

Post by karmat »

Not sure if this is what you mean, but if you are trying to get a line of text centered (left to right) in a bar (background), change the value of X to half the size of the bar's width (or whatever you want it centered in) and then under your Meters put in StringAlign=CENTER instead of LEFT or RIGHT.
Grantp
Posts: 82
Joined: November 29th, 2010, 5:28 pm

Re: Align Text Vertically

Post by Grantp »

Many thanks for your reply jsmorley, much appreciated your prompt and understandable reply

Cheers Grant
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Align Text Vertically

Post by jsmorley »

You are absolutely correct Karmat, but I think he means to align a text meter "vertically" on top of an image meter (bar) is his specific example:
1.jpg
You do not have the required permissions to view the files attached to this post.
Grantp
Posts: 82
Joined: November 29th, 2010, 5:28 pm

Re: Align Text Vertically

Post by Grantp »

Hi karmat,

Many thanks for your reply. I am actually trying to centeralise the Y co-ordinate.

jsmorley has told me why it is virtually impossible to do.

Thanks again
Grant
User avatar
Varelse
Posts: 61
Joined: April 22nd, 2009, 7:46 pm

Re: Align Text Vertically

Post by Varelse »

I've had limited success using this formula:

Y= (#HEIGHT#/2-(#FONTSIZE#*0.8))

This formula automatically centers the string based on HEIGHT. The multiplier on FONTSIZE may need to be changed depending on the font. I've had to use both 0.8 and 0.9 on different fonts. For more information go here.
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Align Text Vertically

Post by Chewtoy »

As long as it's a text string (or single characters of any type) you could use the built in #CRLF# variable.

So you got the text "I like fishes", then you can split it up and make a sort of vertical bar like this;
Text="I#CRLF##CRLF#l#CRLF#i#CRLF#k#CRLF#e#CRLF##CRLF#f#CRLF#i#CRLF#s#CRLF#h#CRLF#e#CRLF#s"
This will enter a new-line after each character. This will work if you have measures too, but you will have to fix their values so they are only 1 char each.

Example: You are measureing you CPU. You want the text vertically aligned.

Code: Select all


[MCPUU]
Measure=CPU
UpdateDivider=2

[CPU10]
Measure=Calc
Formula=TRUNC([MCPUU]/10)
DynamicVariables=1
Substitute=".0":""

[CPU1]
Measure=Calc
Formula=FRAC((TRUNC([MCPUU]))/10)
DynamicVariables=1
Substitute="0.":"

[CPU.]
Measure=Calc
Formula=FRAC([MCPUU])
DynamicVariables=1
Substitute="0.":""


[CPU]
Meter=String
MeasureName=CPU10
MeasureName2=CPU1
MeasureName3=CPU.
MeterStyle=Something
Text="%1#CRLF#%2#CRLF#%3"
The only problem you will have with that is when it shows 100% usage. Then the CPU10 will give the value of 10. But how often do you really use 100% CPU?
Anyhow, that's one way to do it.
I don't think, therefore I'm not.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Align Text Vertically

Post by CyberTheWorm »

I did find a way to do this using

Code: Select all

ClipString=1
and setting the width so it will only display 1 character. You have to use trial and error for this too.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page