Author Topic: NGUI appending extra space if the line contains double-space  (Read 1482 times)

cheyilin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Hi,

I found NGUI appending extra space if the line contains double-space after upgrading from 3.5.8 to 3.5.9.

NGUI 3.5.8


NGUI 3.5.9


Is this issue caused by "FIX: Text printing issue if the line begins with a double space." in 3.5.9 changelog ?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI appending extra space if the line contains double-space
« Reply #1 on: May 28, 2014, 05:51:28 AM »
Hmm yeah, something funky is going on there. I will look into this, thanks.

Edit: Replacing that entire section with this seems to do the trick:
  1.                         // If this marks the end of a word, add it to the final string.
  2.                         if (IsSpace(ch) && !eastern && start < offset)
  3.                         {
  4.                                 int end = offset - start + 1;
  5.  
  6.                                 // Last word on the last line should not include an invisible character
  7.                                 if (lineCount == maxLineCount && remainingWidth <= 0f && offset < textLength)
  8.                                 {
  9.                                         char cho = text[offset];
  10.                                         if (cho < ' ' || IsSpace(cho)) --end;
  11.                                 }
  12.  
  13.                                 sb.Append(text.Substring(start, end));
  14.                                 lineIsEmpty = false;
  15.                                 start = offset + 1;
  16.                                 prev = ch;
  17.                         }
(line 922 of NGUIText.cs)
« Last Edit: May 28, 2014, 06:04:20 AM by ArenMook »

cheyilin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: NGUI appending extra space if the line contains double-space
« Reply #2 on: May 29, 2014, 12:39:35 AM »
Hi ArenMook,

The patch works perfectly (NGUI 3.6.1c), thanks.