Author Topic: UITextList not accounting for font spcaing  (Read 1714 times)

vallcrist

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 49
    • View Profile
UITextList not accounting for font spcaing
« on: December 18, 2013, 12:45:33 PM »
UITextList does not account for vertical spacing in the fonts, so if you have a 200 px height textbox with a 12px height font and 4 px of vertical spacing it will try to fit 16 lines ( 200/12 ) when it only fits 12 ( 200 / (12+4) )

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITextList not accounting for font spcaing
« Reply #1 on: December 18, 2013, 12:48:19 PM »
Thanks, you can resolve this by changing UITextList.lineHeight property to the following:
  1. protected float lineHeight { get { return (textLabel != null) ? textLabel.fontSize + textLabel.spacingY : 20f; } }

vallcrist

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 49
    • View Profile
Re: UITextList not accounting for font spcaing
« Reply #2 on: January 20, 2014, 04:44:48 PM »
Hey Michael, just stumbled on this error again today as i was redoing the chat in our game, seems like you forgot to add the in the updates, just bumping this up so you see it again. :)

You did update the lineHeight property, but you forgot to change it in the UpdateVisibleText method.

Line 299 of UITextList
  1. int maxLines = Mathf.FloorToInt((float)textLabel.height / textLabel.fontSize);
  2.  

should be

  1. int maxLines = Mathf.FloorToInt((float)textLabel.height / lineHeight);
  2.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITextList not accounting for font spcaing
« Reply #3 on: January 21, 2014, 01:23:39 AM »
You're right, thanks -- but you should also modify 'scrollHeight' too.
  1.         protected int scrollHeight
  2.         {
  3.                 get
  4.                 {
  5.                         if (!isValid) return 0;
  6.                         int maxLines = Mathf.FloorToInt((float)textLabel.height / lineHeight);
  7.                         return Mathf.Max(0, mTotalLines - maxLines);
  8.                 }
  9.         }