It is currently May 29th, 2024, 8:42 pm

Need help with auto text resize

Get help with creating, editing & fixing problems with skins
kloko
Posts: 4
Joined: November 30th, 2012, 9:27 am

Need help with auto text resize

Post by kloko »

Hello. I want that some text in my skin change fontsize automaticly, depending on the length of text. It's Weather Skin, and for example when it says "Snow" I'm okay with Fontsize=15, but when it's "Light Snow Shower and Fog" I don't have space for this and I want that it switching to Fontsize=12 automaticly. In some W= H= area or something. Thanks for your help, and sorry for my bad english.
You do not have the required permissions to view the files attached to this post.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Need help with auto text resize

Post by moshi »

one way would be a section variable for the font size:

Code: Select all

FontSize=[Calculation]
DynamicVariables=1
and here's the calculation:

Code: Select all

[Calculation]
Measure=Calc
Formula=1
DynamicVariables=1
RegExpSubstitute=1
Substitute="1":"[MeasureCondition]-lalala","^Light Snow Shower and Fog-lalala$":"12","^(.*)-lalala$":"15"
kloko
Posts: 4
Joined: November 30th, 2012, 9:27 am

Re: Need help with auto text resize

Post by kloko »

Thanks for help, it's nice, but in this way I'll need to create all the condition variations manualy, and I don't know all longest of them. So maybe I can create some "box" w=200 h=50, and formula will automatically resize text, so it will stack it to the border? Thanks.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Need help with auto text resize

Post by moshi »

you do not have to know to create everything manually. what you have to do is to learn about regular expressions.

this for example:

Code: Select all

Substitute="1":"[MeasureCondition]-lalala","^.{16}.*-lalala$":"12","^.{1,15}-lalala$":"15"
means everything up to 15 characters will have font size 15, everything with more characters will have font size 12.

what you have in mind would require an invisible meter that is not limited by W and H, so you can use the width of it as a section variable in a formula.

edit: change to the regexp
Last edited by moshi on February 4th, 2013, 11:03 am, edited 1 time in total.
kloko
Posts: 4
Joined: November 30th, 2012, 9:27 am

Re: Need help with auto text resize

Post by kloko »

Got it. I'll use your formula. Thanks for your help.