Author Topic: Broken Dynamic Font  (Read 15732 times)

hexaust

  • Newbie
  • *
  • Thank You
  • -Given: 14
  • -Receive: 1
  • Posts: 35
    • View Profile
Re: Broken Dynamic Font
« Reply #15 on: September 15, 2015, 06:11:25 AM »
I have reverted to 3.8.2 with unity 4.6.8f1 and everything works now. I'll wait for the next version of NGUI maybe all these issues with the fonts will disappear.

chaos3d

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Broken Dynamic Font
« Reply #16 on: September 17, 2015, 12:16:01 AM »
mActiveTTF is not safe in textureRebuildCallback. (UILabel.cs line 951 : UILabel.SetActiveFont() )
So I am using the following:
  1. Font font = mActiveTTF;
  2. if (!mFontUsage.TryGetValue(mActiveTTF, out usage))
  3.     mActiveTTF.textureRebuildCallback = delegate() { OnFontChanged(font); };
  4.  

UNITY 4.6.8p1
NGUI 3.9.2

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Broken Dynamic Font
« Reply #17 on: September 20, 2015, 02:30:14 AM »
A repro case would be fantastic. @chaos3d: I'd do it everywhere in UILabel.SetActiveFont for consistency:
  1.         protected void SetActiveFont (Font fnt)
  2.         {
  3.                 if (mActiveTTF != fnt)
  4.                 {
  5.                         Font font = mActiveTTF;
  6.  
  7.                         if (font != null)
  8.                         {
  9.                                 int usage;
  10.  
  11.                                 if (mFontUsage.TryGetValue(font, out usage))
  12.                                 {
  13.                                         usage = Mathf.Max(0, --usage);
  14.  
  15.                                         if (usage == 0)
  16.                                         {
  17. #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
  18.                                                 font.textureRebuildCallback = null;
  19. #endif
  20.                                                 mFontUsage.Remove(font);
  21.                                         }
  22.                                         else mFontUsage[font] = usage;
  23.                                 }
  24. #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
  25.                                 else font.textureRebuildCallback = null;
  26. #endif
  27.                         }
  28.  
  29.                         mActiveTTF = fnt;
  30.                         font = fnt;
  31.  
  32.                         if (font != null)
  33.                         {
  34.                                 int usage = 0;
  35.  
  36.                                 // Font hasn't been used yet? Register a change delegate callback
  37. #if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
  38.                                 if (!mFontUsage.TryGetValue(font, out usage))
  39.                                         font.textureRebuildCallback = delegate() { OnFontChanged(font); };
  40. #endif
  41. #if UNITY_FLASH
  42.                                 mFontUsage[font] = usage + 1;
  43. #else
  44.                                 mFontUsage[font] = ++usage;
  45. #endif
  46.                         }
  47.                 }
  48.         }

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Broken Dynamic Font
« Reply #18 on: September 21, 2015, 10:04:07 AM »
I think the repro case I submitted with a solution for the dynamic fonts should expose this problem too.

shaunpeoples

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Broken Dynamic Font
« Reply #19 on: September 22, 2015, 11:06:06 AM »
Also seeing an issue where  UILabel with dynamic fonts don't retain their position mentioned by poolts. Enabling the parent object with multiple UI elements may create some labels in the correct position, but not seem to consistently have one or two out of place. Didn't see this issue (definitely) before upgrading to Unity 5 and (probably) NGUI 3.9.2