Support => NGUI 3 Support => Topic started by: Gillissie on August 12, 2013, 07:27:38 AM
Title: Bug with UILabel "adjust scale to fit"
Post by: Gillissie on August 12, 2013, 07:27:38 AM
I am setting up my game so that there are two different sizes of each font, and using a reference font that gets set to one of the sizes, depending on what resolution the game is being run in (on a mobile device).
This works great, except that the "adjust scale to fit" feature seems to ignore the pixel size value of the current font. It seems to scale the label based on a pixel size of 1, no matter what it is set to.
Title: Re: Bug with UILabel "adjust scale to fit"
Post by: Gillissie on August 12, 2013, 07:41:10 AM
Changing lines of UILabel seems to have fixed it:
line 494 old: float maxY = mFont.size * mMaxLineCount;
Add this line right after "if (mShrinkToFit)": mSize.x /= mFont.pixelSize;
Also, this helps in the font setter, after everything else. Most other property setters have this call, so I'm not sure why the font setter doesn't: if (shrinkToFit) MakePixelPerfect();
Title: Re: Bug with UILabel "adjust scale to fit"
Post by: Gillissie on August 12, 2013, 07:46:07 AM
On a related note, I have also changed line 652 of UILabel to take the font's pixel size into account when doing the effects...
It would be great to see these changes in future versions out of the box. Thanks.
Title: Re: Bug with UILabel "adjust scale to fit"
Post by: ArenMook on August 12, 2013, 03:57:58 PM
Your suggestions make sense, however I am not quite clear where that is supposed to go:
Quote
Add this line right after "if (mShrinkToFit)": mSize.x /= mFont.pixelSize;
Title: Re: Bug with UILabel "adjust scale to fit"
Post by: Gillissie on August 12, 2013, 05:54:38 PM
It's where the code with this comment is:
if(mShrinkToFit)
{
// We want to shrink the label (when it doesn't fit)
mSize.x/= mFont.pixelSize;// Gillissie added
Title: Re: Bug with UILabel "adjust scale to fit"
Post by: ArenMook on August 13, 2013, 08:28:07 PM
Ok, I'll have a look at it again -- and I got your email too, thanks.
Title: Re: Bug with UILabel "adjust scale to fit"
Post by: ArenMook on August 13, 2013, 09:18:24 PM
Alright, so I looked into it... first of all it makes sense to have that operation happen on the entire vector2, not just the X component. Second, seems to be that it should be a multiplication, not a division.