Author Topic: UILabel Line Break feature request & a minor scaling issue  (Read 3669 times)

atrainedmonkey

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UILabel Line Break feature request & a minor scaling issue
« on: June 08, 2015, 07:01:19 AM »
Hi,

We've got a couple of questions related to UILabel and Text wrapping:

1) If we add line breaks to text in a UILabel where:
 - maxLines is 2
 - overflow is Shrink Content
Then the text won't shrink to fit, and text will be cut-off. However, Reset maxLines to 0 and the text scales to fit as expected.

Is this a bug or a known limitation with NGUI 3.8.1?

2) The line breaking algorithm is currently "greedy" and our client would like more balanced lines, like what you'd get from a "Minimum Raggedness" algorithm
http://en.wikipedia.org/wiki/Line_wrap_and_word_wrap#Minimum_raggedness

It's highlighted best with 2 line UILabels we use in a store menu to display descriptions for the items. Because it is greedy, it will try to fill the first line, even if the second line only has one word (or in Eastern languages, it will often put punctuation on a new line by itself).

We tried a workaround of adding new lines into the text before putting it in the label, but because of the first issue I mentioned, we lose scaling, and so longer text would get cut-off.
So currently I have modified UILabel to use our custom text wrap function.

My question is:
Are there any plans to expand on the functionality here?
 - Adding a minimum raggedness algorithm would be great!
 - Implementing more rules line breaking with Asian Lanugages would be a cheeky bonus to stop punctuation spilling onto other lines - although this issue is much less prevalent when not using a greedy algorithm.
https://msdn.microsoft.com/en-us/goglobal/bb688158.aspx


And if not, (languages are a big complex monster) it would be great for us if text wrapping in NGUI was extensible, so we can modify it to work best for us without having to apply patches to NGUI. As we have many projects that would share this.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Line Break feature request & a minor scaling issue
« Reply #1 on: June 09, 2015, 01:17:51 AM »
While I have no immediate plans for this, you should be able to modify NGUIText to suit your needs, and submit your patch to be included in the main trunk, if you like.