Author Topic: Dynamic font to NGUI font  (Read 13981 times)

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Dynamic font to NGUI font
« on: August 28, 2014, 11:36:25 PM »
I've just started to transfer a number of dynamic font labels to NGUI ones, but I'm having trouble getting them to appear the same.

I have a number of prefabs with UIlabels on them that are created at runtime.

Dynamic font is set to size 80, Center, ShrinkContent, spacing -2, 6 and works as expected.

The NGUI version of the same font has the same settings, but doesn't shrink the content, is centered horizontally, but positioned at the very bottom of the label.

If I set the settings manually after the prefabs have been created the font starts to behave correctly.

This is my first time creating and working with NGUI fonts, so I've probably missed something simple. Any ideas?

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #1 on: August 28, 2014, 11:38:29 PM »
The other thing i've noticed is that my half size space character   doesn't seem to be working with the NGUI font.

I added Spacing Modifier Letters in Bitmap font generator, but that didn't help.

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #2 on: August 29, 2014, 02:27:39 AM »
Another thing that may be affecting it is that I set a default value for the label text, "Answer" and "Question", which I then replace with the actual answer and question. It seems to be getting the font size and position from the default value, but not updating those when the text is replaced.

But dynamic font does update when the text is replaced...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font to NGUI font
« Reply #3 on: August 30, 2014, 08:54:35 AM »
How did you create the bitmap font? Using the Font Maker, or some external tool?

There is no difference between NGUI and dynamic fonts in terms of positioning. Dynamic font set to shrink will behave a bit different though if you check "keep crisp". The dynamic font will keep requesting lower and lower sizes, while the bitmap font will just reduce the size of the existing glyphs, making them a bit blurry.

I'm not quite clear on the last part... the label gets the font size and position from the default text value and doesn't update when the font gets replaced? What size and position? If the label is set to Shrink to Fit, then it already has a size. The label's width and height will only change if it's set to Resize Freely or Resize Height.

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #4 on: August 31, 2014, 01:20:45 AM »
I created the font using Bitmap Font Generator, and imported with Font Maker.

I've attached the result of using:
Top: Unity Font
Middle: NGUI Font
Bottom: NGUI Font modified manually during runtime.

There are no other changes between these results. So Unity dynamic font works as expected. NGUI font doesn't work initially, but works when I manually set it (but don't actually change any values).

The Prefab has default label of "Question" instead of the actual question text you see in the image. I was wondering if the shrink to fit was working on the default label, but one set by code.

I didn't notice any problems switching from Unity to NGUI fonts before the latest update...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font to NGUI font
« Reply #5 on: August 31, 2014, 03:19:40 PM »
I see no reason for something like this, other than maybe attaching more than one widget to the same object. I would need steps to follow in order to reproduce the problem. Also, what's Bitmap Font Generator? NGUI has a built-in way of using FreeType to generate bitmap fonts, but you don't import them after. You just use them. It's the default option in the Font Maker.

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #6 on: August 31, 2014, 07:05:39 PM »
Thanks for your help,

Just the UILabel on the object.

Bitmap Font Generator:
http://www.moddb.com/members/carlk3d/blogs/unity-ngui-custom-font-maker-post-8

I then used Type: Imported Bitmap.

I will try creating the font entirely through font maker.


kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #7 on: August 31, 2014, 09:51:36 PM »
I created the font entirely through font maker which has solved the problem. Unfortunately I don't have as much control over the font as in Bitmap Font Generator.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font to NGUI font
« Reply #8 on: September 01, 2014, 12:19:04 PM »
I would suggest getting in touch with the author of that tool.

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #9 on: September 02, 2014, 05:14:11 AM »
Thanks ArenMook, I will.

In the mean time this page recommends using that tool:
http://www.tasharen.com/?page_id=133

"All fonts are created using the free BMFont program, or the more advanced Glyph Designer"

Perhaps if it's currently or temporarily incompatible with NGUI that could be mentioned.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font to NGUI font
« Reply #10 on: September 02, 2014, 12:17:05 PM »
That entire documentation has become obsolete 2 years ago. Nothing in NGUI points to any of those old pages. If you choose NGUI -> Help (or Help -> NGUI for that matter!), you are taken to a proper page.

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #11 on: September 05, 2014, 12:03:41 AM »
Ah ok. My bad.

IN the mean time I'm really missing my half space " ". Can you tell me how I can include that in the NGUI font?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font to NGUI font
« Reply #12 on: September 05, 2014, 01:17:06 PM »
NGUI will use whatever characters you choose when you create the font. If you want the half-space to be there, choose Custom for which character set gets included, and add it to the list of characters you see there.

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #13 on: September 07, 2014, 07:22:38 PM »
I've put in the unicode character   but it hasn't worked. Is there something special I need to do to add unicode characters?

kretin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: Dynamic font to NGUI font
« Reply #14 on: September 08, 2014, 03:50:23 AM »
I think I was getting lost between the html character ( ) and the unicode (U+2009).

When using dynamic fonts, the thin space was being read and displayed from an XML file where it was specified as  .

Now I've converted to NGUI font, but having trouble getting the thin space.

I've copied the thin space character (or space) from windows Character Map and put it in Font Maker - Custom, so I assume it's in the font prefab, but they are still not being displayed?

Since it's a space character I can't actually tell if it's in the NGUI font prefab or not...