Author Topic: Unify dynamic font size  (Read 3684 times)

Duke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Unify dynamic font size
« on: April 02, 2014, 05:04:54 AM »
Hi,

I'm currently having some UILabel in my app and it works pretty well thanks to this super good tool for unity  :)

But here is my problem :
I have some label with unified anchor set to fit the screen size, I have also configured font size to be 45 on all of those label.
But the texts I display in the different label don't have the same length.
So i some time have smaller text in some label (that's pretty normal).
But I would like to have the same font size on all my label so it look better !
But I can't find a good way to get the "real" font size of a label, in order to apply it to all the others =/
(I want to get the font size of the label where there is the longer text and apply this font size to the other labels)


I'm certainly missing something but i don't have find anything in the documentation or in the forum


Thanks for your help !

Duke

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unify dynamic font size
« Reply #1 on: April 02, 2014, 04:35:06 PM »
I don't get what you're trying to do. All labels have a size setting that you can adjust, regardless of the actual font's size. Labels also have an Overflow setting that controls what happens when the text's bounds exceed the bounds of the widget. Will it shrink? Will it cut off the rest of the text? Will it wrap the text? Will it resize the label? All of this is controllable via the Overflow setting. However if you have it anchored on all 4 sides, then overflow won't be able to resize it and it will switch to "shrink" as the default option.

Duke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Unify dynamic font size
« Reply #2 on: April 03, 2014, 02:07:06 AM »
Hi,

Thanks for your reply here is an image that is explaining the problem:



I just want to get the font size of the left side to apply the same size on the right side even if there is less text.
I can't only adjust the label size because in my case it will depend on the screen size ...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unify dynamic font size
« Reply #3 on: April 03, 2014, 09:53:39 PM »
You want the font size on the right to be based on the font size of the left, even when the left one shrinks the size to fit the content? There is no such functionality in NGUI. Labels are independent of each other.

Duke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Unify dynamic font size
« Reply #4 on: April 04, 2014, 03:46:22 AM »
Yeah that's exactly what I want to do.
I just need to get the font size of the left side after it have been shrinked and then apply this font size to the right side.
There is certainly a way to calculate it i'll try to find a way.

Thanks for the answers anyway  ;)

Duke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Unify dynamic font size
« Reply #5 on: April 04, 2014, 10:36:43 AM »
I have found an hacky workaround while reading the source of UILabel:

I just made mPrintedSize public in order to get "true" font size.
And I have made some modification in ProcessText also in order to have good line skrinking without having text to resize


Duke