Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: ryan on January 11, 2013, 03:24:02 PM

Title: Font kerning not serialized?
Post by: ryan on January 11, 2013, 03:24:02 PM
Looking into a problem with some font spacing today, I noticed that my font prefabs don't have any of the kerning information serialized.  After a little digging, I found that the kerning is stored in a struct, and apparently Unity doesn't support serialization of user-defined structs.  I did this to get the kerning serialized:

  1. diff old/Assets/NGUI/Scripts/Internal/BMGlyph.cs new/Assets/NGUI/Scripts/Internal/BMGlyph.cs
  2. 16c16,17
  3. <       public struct Kerning
  4. ---
  5. >       [System.Serializable]
  6. >       public class Kerning
  7. 67,69c68
  8. <                               Kerning k = kerning[i];
  9. <                               k.amount = amount;
  10. <                               kerning[i] = k;
  11. ---
  12. >                               kerning[i].amount = amount;
Title: Re: Font kerning not serialized?
Post by: Ferazel on January 11, 2013, 06:02:11 PM
Ok, wow! How was this not discovered previously? The kerning information makes fonts look so much more readable. Please put this into the next update!
Title: Re: Font kerning not serialized?
Post by: ArenMook on January 11, 2013, 07:44:08 PM
o_O Interesting...

Any before / after pics of what effect this has?
Title: Re: Font kerning not serialized?
Post by: ArenMook on January 11, 2013, 07:59:15 PM
This is a better modification.
Title: Re: Font kerning not serialized?
Post by: ryan on January 11, 2013, 09:35:10 PM
The effects are mostly not noticeable, but with our font certain character combinations ended up a little more crowded than they should have been.  A lowercase "f" followed by an apostrophe is what caused me to investigate.  In the attached example, the spacing between the capital "W" and lowercase "i" is also slightly different, and a little extra space is inserted before the capital "T" without kerning.

Thanks for the modification.
Title: Re: Font kerning not serialized?
Post by: Ferazel on January 11, 2013, 10:32:19 PM
Yeah I guess I overreacted... it is not night/day difference but with some fonts in particular T + e is a really noticeable combination as well.