Author Topic: Font kerning not serialized?  (Read 6030 times)

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Font kerning not serialized?
« 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;

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Font kerning not serialized?
« Reply #1 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!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning not serialized?
« Reply #2 on: January 11, 2013, 07:44:08 PM »
o_O Interesting...

Any before / after pics of what effect this has?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Font kerning not serialized?
« Reply #3 on: January 11, 2013, 07:59:15 PM »
This is a better modification.

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
Re: Font kerning not serialized?
« Reply #4 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.

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: Font kerning not serialized?
« Reply #5 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.
« Last Edit: January 11, 2013, 10:40:22 PM by Ferazel »