Author Topic: NGUI Label SpacingX bug v3.9.8 & v3.11.2  (Read 2912 times)

QiuLei

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
NGUI Label SpacingX bug v3.9.8 & v3.11.2
« on: April 09, 2017, 11:23:13 PM »
Hi, Tasharen.I recently upgrade my project from v3.9.8 to v3.11.2, and run into a Label SpacingX problem which I have fixed in v3.9.8. The problem in v3.9.8 is, when you input some Thai characters like "ยืนยัน" in a label, set Overflow to Resize Freely,and the label's SpacingX to 1,then it shows like:
ยืนยั
  น
I tried to modify v3.9.8 NGUIText.cs at line 1610:
Original:
               // Advance the position
               x += (subscriptMode == 0) ? finalSpacingX + glyph.advance :
              (finalSpacingX + glyph.advance) * sizeShrinkage;
Modified:
               //Modify NGUI by Qiulei [2017-3-9] : 解决泰语ยืนยัน在有spacingX时,显示错位的bug。原因:计算逻辑宽度时去掉了不占宽度的space,但绘制时没有去掉对应的space
                float charWidth = GetGlyphWidth(ch, prev);
                float realSpacingX = 0;
                if (charWidth != 0f)
                {
                    realSpacingX = finalSpacingX;
                    prev = ch;
                }

                // Advance the position
                x += (subscriptMode == 0) ? realSpacingX + glyph.advance :
                    (realSpacingX + glyph.advance) * sizeShrinkage;
But when I try to find out if v3.11.2 has soved this issue, I got a headache :(,the Label's SpacingX display is totally wrong:
If you want a Label show "abc" with Overflow Resize Freely,the  SpacingX 10,it shows like:" abc" but not "a b c", apparently its a new bug.
I try to solve this by modifying v3.9.8 NGUIText.cs line 1015 and 1644."if (finalSpacingX < 0f) w += finalSpacingX;" to "w += finalSpacingX;",but it show " a b c " but not "a b c".
I don't want try to modify anything any more, and I hope you can solve this problem in next version :'(.
And hope Thai characters like "ยืนยัน" shows normally too ::)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Label SpacingX bug v3.9.8 & v3.11.2
« Reply #1 on: April 14, 2017, 03:09:46 PM »
I tried it on my end and the label was shown correctly. Perhaps it's part of something I fixed since the last release? I'll put up a new NGUI version within a week.

QiuLei

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: NGUI Label SpacingX bug v3.9.8 & v3.11.2
« Reply #2 on: April 17, 2017, 08:30:54 AM »
 Thanks ;D

FoxQ

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: NGUI Label SpacingX bug v3.9.8 & v3.11.2
« Reply #3 on: June 29, 2017, 11:49:36 PM »
Similar problem in v3.11.4

If the text is longer than the size, it might display wrong like the attachment.
The input is "กฏขั้นพื้นฐานเกมส์" with spacing and shrink content.

I modify the code like QiuLei said, and it works.
(v3.11.4 NGUIText.cs at line 1015, line 1647)