Author Topic: Font kerning problem  (Read 15269 times)

Seller

  • Guest
Font kerning problem
« on: September 25, 2013, 12:34:47 PM »
Hi,
I have a problem with kerning and dynamic fonts. I create dynamic font prefab and add it to a UILabel but ngui / unity ignore the font kerning. So is kerning supported by dynamic fonts?

Thanks Seller

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning problem
« Reply #1 on: September 25, 2013, 07:24:38 PM »
No, they don't. Unity limitation.

ilja_v

  • Guest
Re: Font kerning problem
« Reply #2 on: September 26, 2013, 07:06:01 AM »
Hi ArenMook,

so does that mean that you have to choose between support for Kerning vs. support for dynamic fonts, or are there any workarounds? So far all we could thinks of was importing text as texture from native components, but obviously if there is a way to avoid this, we'd rather go for a different option...

Regards,
Ilja

Darkmax

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 93
    • View Profile
Re: Font kerning problem
« Reply #3 on: September 26, 2013, 07:33:33 AM »
Like ArenMook said this is a Unity Limitation, and you need use an external tool to modify your font kerning, check this link:
http://forum.unity3d.com/threads/12723-Font-Line-spacing-amp-Kerning-in-GUI-system

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning problem
« Reply #4 on: September 26, 2013, 03:42:30 PM »
When the new GUI ships, it will ship with a revamped font system that doesn't suck hairy donkey nuts. That's when kerning will be possible.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Font kerning problem
« Reply #5 on: May 07, 2014, 04:45:44 AM »
Sorry to necro this post, but kerning still sucks. Has anyone been able to piece together some hacky solution until Unity gets around to exposing it properly?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning problem
« Reply #6 on: May 08, 2014, 03:08:53 AM »
The new GUI (uGUI) hasn't shipped yet. Nothing has changed.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Font kerning problem
« Reply #7 on: May 08, 2014, 05:18:56 AM »
We have actually identified an issue in NGUI that makes especially small size dynamic fonts behave weirdly. It has to do with rounding the letter sizes and advance sizes in NGUIText.

Particularly these two lines in NGUIText.cs:

NGUIText:165
  1. //return Mathf.Round(mTempChar.width * fontScale * pixelDensity);
  2. return mTempChar.width * fontScale * pixelDensity;
  3.  

NGUIText:239
  1. glyph.advance = Mathf.Round(glyph.advance); //remove this
  2.  


With those two removed roundings, the kerning follows the font properly.

Want me to make a pull request with this?
« Last Edit: May 08, 2014, 06:15:49 AM by Nicki »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning problem
« Reply #8 on: May 09, 2014, 04:58:31 AM »
That would make the letters not pixel-perfect, so they would be blurry, no?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Font kerning problem
« Reply #9 on: May 09, 2014, 06:14:19 AM »
That's not really our experience, since they're not "full pixel widths" anyway, losing the accuracy in kerning is worse than potentially fuzzy letters. A pixel here and there added to singular letters make things non-releasable. It makes designers go :(

You'll notice too, that for the bitmap fonts, you don't round the advance (line 206) or the glyphwidth (line 158), and they should have the same issues right?

It actually messes quite a lot with kerning at small sizes, since obviously 1 px is quite a lot on a 10pt font.

I think at least, it would be very helpful to be able to turn off "pixel perfect letters", or remove it entirely. I'm going to put together a little repro case, so you can see the problems I'm talking about.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning problem
« Reply #10 on: May 09, 2014, 06:20:35 AM »
Alright, I'll remove the rounding, but if something gets blurry, I'll blame you™ :D

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Font kerning problem
« Reply #11 on: July 28, 2015, 09:31:54 AM »
I'm necroing again .. :)

Has the Kerning in unity's font system come out with the new UGUI? It seems to still suck -_-

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning problem
« Reply #12 on: July 28, 2015, 06:47:48 PM »
No idea!