Author Topic: Label issue.  (Read 1835 times)

iwishash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Label issue.
« on: January 27, 2014, 06:15:57 AM »
Hi,
After upgrade version 3.0.9 f6 (from 3.0.7), there's problem on the label.
I used dynamic font which has x-side negative spacing to obtain more less spacing between characters.
After upgrade, the label shows like below. (made one more vertical line)


My UILabel setting has -2 x-side spacing.


When I change the spacing to 0, it shows correctly. (only one line)
Is there other setting to solve this?

davidoakley

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Label issue.
« Reply #1 on: January 27, 2014, 06:46:26 AM »
I think that's related to what I've just seen having upgraded from 3.0.6 to 3.0.9... When using "retina" sized graphics (pixel size 0.5), I'm getting that last-letter wrapping happening too.

My guess is that the width that is being calculated is fractional and is being rounded down, and then when the text is wrapped into that width it pushes the last letter onto the next line.

For me, changing the Mathf.RoundToInt to Mathf.CeilToInt in UILabel.ProcessText seems to have fixed it. Not sure whether that's the correct diagnosis or fix of course!

David

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Label issue.
« Reply #2 on: January 27, 2014, 08:25:52 AM »
Thanks, quick and dirty fix is to change line 1060 in NGUIText.cs from:
  1. if (x + glyph.advance > rectWidth)
to:
  1. if (x + glyph.advance + finalSpacingX > rectWidth)

iwishash

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Label issue.
« Reply #3 on: January 28, 2014, 06:08:48 AM »
Oh, that works!
Thank you for the solutions.