Author Topic: Bug when adding font to atlas  (Read 9487 times)

arkon3

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 71
    • View Profile
Bug when adding font to atlas
« on: March 01, 2014, 11:25:30 PM »
I have a small font with 12 characters in it. I've used GlyphDesigner to create the texture and .txt data file. If I use the NGUI fontmaker to make a NGUI bitmap font and don't add it to an atlas it works fine. BUT if I try and add it to an atlas the font does not render. Inside the atlas the font is there correctly but any label's that use it are all garbled. I'm using the latest NGUI.

I've attached the files so you can see what happens.

I've just noticed a way bigger bug. Now the atlas that the font was in on the first attempt has been corrupted and all sprites that used it are not working. When I try and re add the sprites to the atlas it overwrites the font bitmap with the atlas contents! It's totally busted. I'm going to have to delete the atlas and font and try again.
« Last Edit: March 01, 2014, 11:36:38 PM by arkon3 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug when adding font to atlas
« Reply #1 on: March 02, 2014, 06:43:25 PM »
I just tried the following:

1. Opened the Font Maker.
2. Type: Imported Bitmap. Font Data: Trajan60. Texture: Trajan60. Output: Wooden Atlas.
3. Clicked Create the Font.
4. ALT+SHIFT+L to make a label. By default nothing shows up because your font only has digits.
5. Changed the label's text to "1234". Text shows up.

arkon3

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 71
    • View Profile
Re: Bug when adding font to atlas
« Reply #2 on: March 02, 2014, 08:12:45 PM »
I've just deleted the atlas and font and done it again and this time it worked. There seems to be a problem where it can get its references wrong. Also I had a 2048x2048 atlas, i deleted a load of sprites from it and it did not shrink the atlas to suit. The remaining sprites would have fit in a 512x512 but it stayed 2048 x 2048. Looks like sometimes deleting sprites doesn't recalculate the atlas.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug when adding font to atlas
« Reply #3 on: March 02, 2014, 09:56:47 PM »
Long and narrow sprites are notoriously bad for Unity's packing algorithm. Avoid them like the plague. Also be sure to save after every modification to the atlas, or the changes may not be written to disk.