Author Topic: 2.6.5 issue with label Shrink to fit.  (Read 4921 times)

boudboa

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
2.6.5 issue with label Shrink to fit.
« on: September 03, 2013, 08:14:33 AM »
After updating to 2.6.5 some of my labels were not correctly shrinked and sometimes were having the few last letters hidden outside of the label.

It fixed after reverting to 2.6.4

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #1 on: September 04, 2013, 04:43:32 AM »
"some of my labels" can't help me narrow down the issue. :P

I changed the way label's height gets specified. You can now specify it explicitly instead of relying on max number of lines. This affected shrinking somewhat.

ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #2 on: September 04, 2013, 05:35:09 AM »
I am experiencing the same problems, but I did a couple of tests.

I have the following fonts:

Ref_Calibri_Bold_42
Calibri_42_Bold_HD (42 Bold Bitmap Font, Pixel Size on Atlas = 1)
Calibri_42_Bold_SD (22 Bold Bitmap Font, Pixel Size on Atlas = 2)

Creating a new label with the following settings:

Fonts: Calibri_42_Ref
Text "New Label"
Max Width = 150 pixels
Max Height = 45 pixels (To make sure the SD font fits into a single line.)
Max Lines = 1 line
Shrink to Fit = True

First I tested loading "Calibri_42_Bold_HD" into the Reference font.
Adding extra text to this label (i.e. making it say "New Label New Label") will not shrink the font.

If I instead use "Calibri_42_Bold_SD", it will shrink the font to point 22 even though the max height is set at 45. (It does not seem to take the pixel size of the atlas it's on into account.) The green gizmo visibly extends beyond the text, however, adding extra text to the label will not shrink the font further, nor does it add the extra text even though there is still space for the label to grow.

I've tried a couple of combinations of max lines and max height, that doesn't seem to make Shrink to Fit.

I can take some screenshots if you want, Aren.

ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #3 on: September 04, 2013, 05:37:29 AM »
Just separating this question then: if I revert all scripts relating to UILabels to 2.6.4, can I still benefit from the following change made in 2.6.5: "- FIX: Widgets no longer store a reference to texture and material." ? Right now, this is the only functionality we need from 2.6.5.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #4 on: September 04, 2013, 05:45:47 AM »
The behaviour you described is intentional.

If you specify a "max lines" argument, it will trim the text when it's about to start a new line.

Change it to '0' and you will get the behaviour you're after.

Edit: However... I haven't tried this with a non-1 pixel size atlas. Hmm.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #5 on: September 04, 2013, 05:59:14 AM »
Ok, open up UILabel, and comment out line 548: //mSize *= mFont.pixelSize;

ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #6 on: September 04, 2013, 06:06:07 AM »
That works.  Thanks!

However, there is a specific usage scenario that people might run into. Now this might be an edge case; so you may not want to fix it.

If I want to create a title, often I don't want the label to run over one line. However, with the new system, I set a maximum line height. So in this case, it would be 42 for the bold font. However, if the title becomes sufficiently long (look, my designer is kind of wordy ;-) ) then the font will shrink so that it fits into that maximum line height twice.

I don't know if that would be easy to fix however.


ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #7 on: September 04, 2013, 06:16:42 AM »
Also, a second problem to the new style is that if you trying to create a single line of text, the resulting one line will automatically align to the top of the text box regardless of it's anchor point.

This is actually more of a "problem" for us right now than the previous bug I mentioned.

IndieJoe

  • Guest
Re: 2.6.5 issue with label Shrink to fit.
« Reply #8 on: September 09, 2013, 01:08:20 PM »
This seems like an unfortunate change, because all of the labels in our project used the old method of setting max lines to 1 to apply the auto-shrinking of the text, and now it's all broke  :-\

It also seems like there is a lot more overhead in getting this to work in general.  If you want a 3 line label at 64 point font, I think to achieve the shrink-to-fit you now have to set max lines to 3, and max height to 196 -- is that right?  But if you ever change font size, all of the label settings you made now no longer work.  Prior to this all you would have to do is set max lines to 3, right?

We are using this shrink-to-fit primarily for localization...if a word localizes to longer than the English version, the shrink-to-fit should shrink it down appropriately.  Also, as the person above mentions, it looks like the anchoring of the shrinking text in the new version is also not working like it was before.

Ok, open up UILabel, and comment out line 548: //mSize *= mFont.pixelSize;
Which problem should that solve?  I also could not find that line of code in UILabel...

Regards,
Joe

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #9 on: September 09, 2013, 08:25:33 PM »
3.0.0 that's currently in beta completely changed all of this and added additional methods of resizing / shrinking the label's content.

ChrisR

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: 2.6.5 issue with label Shrink to fit.
« Reply #10 on: September 10, 2013, 04:03:05 AM »
Which problem should that solve?  I also could not find that line of code in UILabel...

If you don't comment this line out, the UILabel seems to disregard the font atlas pixel size. This is a problem when you're swapping out HD/SD textures, as one or the other will be half (if SD) or double (if HD) the scale you intend them to be.

Just commenting because I think Aren won't be around for a while.