Author Topic: UILabel single character wrapping bug - includes patch  (Read 6470 times)

MigrantP

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 22
    • View Profile
UILabel single character wrapping bug - includes patch
« on: May 14, 2015, 12:42:31 PM »
We've had a mysterious single character line wrapping bug in our game for a while, and I dug into it today. We would sometimes see a UILabel set to resize freely wrap a single character to the next line - even if Max Lines was set to 1.

Upon investigation, NGUIText.WrapText() was working fine, and was not inserting newlines or anything. The problem was in NGUIText.Print(). It could decide that the last character doesn't fit, and move it down to a new line with no regard for the max lines setting. This seems most likely to be caused by a rounding issue.

An example image of the problem is attached, along with a patch against NGUI 3.8.2 that fixes the problem by enforcing Max Lines in NGUIText.Print(). There may be a better way to fix it, but that works for me =)