Author Topic: Strange lines on UILabel texts  (Read 2230 times)

Fbary

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Strange lines on UILabel texts
« on: July 28, 2014, 04:54:51 AM »
Hello,
I'm facing a problem with the UILabels. With some sizes the text drawn have some strange lines. Changing the size of the text sometimes makes them disappear but it's random and when the text is set to resize this strange behaviour appear randomly.
Look at the image I attached: the first one have a size of 77 and there are lines around the "C", "O" and "M" letters on the second word.
If I resize up to 93 I don't have these lines anymore.

Any clues of what it can be?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Strange lines on UILabel texts
« Reply #1 on: July 29, 2014, 02:55:07 AM »
Happens when you pack letters too closely. When you shrink the font, texture filtering causes nearby pixels to bleed through the edges.

Select the font prefab and add a transparent border.

Fbary

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Strange lines on UILabel texts
« Reply #2 on: July 29, 2014, 03:41:45 AM »
Thank you very much. It worked.

However I had to add the border three times to completely get rid of this problem.
Doing this way the last row of the font moved in a new line increasing the size of the font image from 1024x1024 to 1024x2048. It's not a great deal now but the font is getting much more space (which is wasted because it's empty, there is just this row and a lot of blank space). In the future this wasted space may cost me.

Is there any other way to prevent the problem? Like changing the texture filter somehow?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Strange lines on UILabel texts
« Reply #3 on: July 29, 2014, 03:43:54 AM »
Best way to avoid the problem is to ensure that you don't scale the font. Keep the font at its default size. If you need a smaller size font, don't shrink the labels -- create a smaller, separate font instead. I generally make 3 fonts per game -- title font, big font, and small font.