Author Topic: Can I reset my ever-growing dynamic font atlas?  (Read 3863 times)

calbar

  • Guest
Can I reset my ever-growing dynamic font atlas?
« on: October 09, 2013, 05:20:09 PM »
I've noticed my dynamic font atlas continually grows as I type new characters or try different font sizes out. For example, I've got 3 versions of the character "A" in my atlas since trying a label out at size 18, 24 and 32.

Now that I'm happy with my wording and font size, is there a way to reset or regenerate my font atlas based on the characters currently being used? My atlas could be a lot smaller.

I've tried using "Replace" in the Font Maker as well as deleting my atlas and recreating it, but for some reason my old bloated atlas comes back! I'm guessing this happens because I'm using the same name, but it's still surprising. Is this a bug?

Thanks!

calbar

  • Guest
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #1 on: October 09, 2013, 05:29:46 PM »
Ah, ok, I just realized I was deleting the font object, not the texture that it references. That would be why the old layout comes back after deletion.

My problem still stands, though, because I can't seem to delete this texture.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #2 on: October 10, 2013, 07:36:19 AM »
Restart Unity and the font will be cleared. Or just select the TTF font and change its size. This also force-resets the texture.

Why do you care though? This is an edit-time thing. This texture is not getting packed into your project. Dynamic font is just that -- fully dynamic, and the texture gets generated and updated as necessary.

calbar

  • Guest
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #3 on: October 10, 2013, 11:41:55 AM »
Ah, thanks man! I'm just getting started and the concept is new to me. Is there a write-up on dynamic fonts somewhere? I'd hate taking your time if one exists, but I couldn't find one.

On that note, I had some questions about the benefits, caveats and use-cases for dynamic fonts.

I imagine you save on package size without having to including bitmap fonts, but is there a performance hit with generating them in real-time?
I'm also guessing in some cases you may save on runtime memory usage if you only use a few unique characters, but on the flip-side, you could unintentionally blow up the size of your texture if you're careless. For example, displaying characters at random font sizes. Are there any (non-obvious) ways to prevent or avoid this?
Are there common cases where you do and don't want to use dynamic fonts?
Are any of my assumptions wrong, or any other points I should know?

Sorry for all the questions, and feel free to just point me toward a link if one exists!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #4 on: October 11, 2013, 08:34:09 AM »
Using bitmap fonts will always be faster than using dynamic fonts, and you can do more with bitmap fonts. But the one advantage of dynamic fonts is that you are not tied to pre-baked data of a specific font size. So you can have 1 TTF file and 100 different font sizes, if you want. Plus it's a huge boon with eastern language fonts. Those tend to easily take up an entire 4096x4096 texture by themselves with the bitmap fonts.

calbar

  • Guest
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #5 on: October 15, 2013, 10:49:27 AM »
Ah, awesome - thanks for your help. :)

aidji

  • Guest
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #6 on: October 15, 2013, 07:49:23 PM »
Aren what is your advice for performance/quality about dynamic fonts:
- use differents sizes?
- use biggests sizes and scale down?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can I reset my ever-growing dynamic font atlas?
« Reply #7 on: October 16, 2013, 02:18:51 AM »
The latter. Next version of NGUI lets you specify a TTF font directly on your labels (as well as target font size and style). Scaling down labels via shrink content overflow method will also keep them crisp. So you'll be able to simply use one TTF everywhere if you only use one font.