Author Topic: Dynamic font support for NGUI  (Read 105208 times)

wsycarlos

  • Guest
Dynamic font support for NGUI
« on: January 07, 2013, 10:54:01 PM »
We have change some code in UIFont to make the dynamic font work in NGUI
and also compatible with old NGUI version.
Now we are fixing some problems. and once we have done that, we will provide our new UIFont.cs and UIFontInspector.cs to everyone for free!
« Last Edit: January 08, 2013, 04:02:40 AM by wsycarlos »

wsycarlos

  • Guest
Re: Dynamic font support for NGUI
« Reply #1 on: January 07, 2013, 11:07:38 PM »
Here is the pic!















« Last Edit: January 07, 2013, 11:54:23 PM by wsycarlos »

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Dynamic font support for NGUI
« Reply #2 on: January 08, 2013, 01:55:43 AM »
I would have bought this feature for 1000$




 ;D
Graphicstream Dev.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Dynamic font support for NGUI
« Reply #3 on: January 08, 2013, 03:41:09 AM »
« Last Edit: January 08, 2013, 04:51:23 AM by Nicki »

jarjin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: Dynamic font support for NGUI
« Reply #4 on: January 08, 2013, 07:29:30 AM »
You're awesome!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!great work!!!!!!!!!!!!!!!!!

jarjin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: Dynamic font support for NGUI
« Reply #5 on: January 08, 2013, 07:31:10 AM »
I have some can't wait for.....

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font support for NGUI
« Reply #6 on: January 08, 2013, 09:23:06 AM »
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?

zh4ox

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Dynamic font support for NGUI
« Reply #7 on: January 08, 2013, 09:40:14 AM »
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?
yep, it uses the dynamic font texture, the amount of texture is decided by how many fonts we use
« Last Edit: January 08, 2013, 09:49:58 AM by zh4ox »

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Dynamic font support for NGUI
« Reply #8 on: January 08, 2013, 12:27:20 PM »
I'm really looking forward to testing this out. The only downside to dynamic fonts is the lack of concrete memory management of this font texture, but the nature of being able to put only the characters that we use in the texture at the specific time is really appealing.

Did you by chance get it to work with the UIPanel clipping as well?

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: Dynamic font support for NGUI
« Reply #9 on: January 08, 2013, 12:29:46 PM »
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?

For what it's worth, that doesn't bother me at all.  We have some atlases that are big enough already that trying to squeeze a font into it, even a dynamic one, would be tricky.  I split our font out into its own atlas long ago in anticipation of something like this feature for when we localize.  Limiting draw calls is all well and good, but getting hung up on the whole single draw call thing and passing over this feature because it doesn't achieve that would be a mistake.  (Not that you've said you're passing on it.)

wsycarlos

  • Guest
Re: Dynamic font support for NGUI
« Reply #10 on: January 08, 2013, 01:13:15 PM »
This is made by zh4ox above ::). And now he is dealing with different size of same font.
Let's wait for his final version.
And BTW, Aren,
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?
Unity create the font texture dynamically according to the list of chars u used with this font, so is that possible to add a texture dynamically into an atlas(as i remember, it's quite difficult), and then change it every time when u use a new char(like the chat window, who knows every players?)?

Unisip

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Dynamic font support for NGUI
« Reply #11 on: January 08, 2013, 01:19:14 PM »
Regarding memory management, the beauty of it is that the texture tends to use only the characters that are in use at a given moment. That is, suppose you have a font texture that holds a lot of 72px characters because you are showing a splashscreen GUI, for instance, next when you move on to another screen, like for instance an inventory menu, if you start using smaller characters of the same font, say 16px for titles and 12px for subtitles, whenever the texture is full it will be rebuilt, but without the 72px characters since they are nolonger in use on screen.

I've got my own integration mostly working and I am happy to share it too for free. At first I considered putting a price on it, but I'm happy to share it freely as every one seems excited about this. As long as I don't have to answer zillions of questions about it, I'm happy to share.

Eventually, ArenMook, I really think you should get down to integrating this in NGUI. It's not a lot of code, and what worries me about my own solution or any solution I could pick up on this forum is maintainance --> since I basically modified some of your source code, everytime you submit an update in assetstore, it's still going to be a bit clumsy to apply my patch on top of it.

Unisip

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Dynamic font support for NGUI
« Reply #12 on: January 08, 2013, 01:22:22 PM »
Btw, WSYCARLOS, since you guys are working on this too, if you are interested to take a look at my shot at it, feel free to ask. As far as I could test, I have everything working properly (some code cleaning would help, but featurewise it's functional). That is, multiple fonts, support for font styles, multiple font sizes, colors, font refresh when the font texture can't hold all the characters, etc...

BeShifty

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 7
  • Posts: 52
    • View Profile
Re: Dynamic font support for NGUI
« Reply #13 on: January 08, 2013, 01:43:31 PM »
If you can set the font size at runtime, could we add a size encoding 'tag' like the color one [FFFFFF]? Maybe [size=18]? Unfortunately the encoding would have to move towards an HTML style This is colored[size=18]This is colored and size 18[-color]This is size 18[-size]

Unisip

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Dynamic font support for NGUI
« Reply #14 on: January 08, 2013, 02:22:52 PM »
Mmm, that's more work, actually, if you want to mix font sizes in the same UILabel --> additional code changes to recompute all things related to text alignment, etc... Not trivial