Author Topic: dynamic font corruption on Galaxy S3  (Read 2937 times)

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
dynamic font corruption on Galaxy S3
« on: August 17, 2013, 11:36:37 AM »
I am seeing this intermittent issue with dynamic fonts on Samsung Galaxy S3 (Attached screenshot).  I have noticed some other devices will look corrupted for a millisecond and then fix themselves, but on this device, it seems like often it can get stuck like this until something else eventually triggers a font rebuild.  Is there anything I can do about this or are we stuck waiting for Unity to fix stuff?  I am calling RequestChars as much as I can which did seem to help in some cases.

« Last Edit: August 17, 2013, 03:03:49 PM by FizzPow »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: dynamic font corruption on Galaxy S3
« Reply #1 on: August 18, 2013, 07:17:15 AM »
I hate the dynamic font implementation in Unity. TLDR version: I couldn't find a reliable repro case to pass to the person who wrote that feature, so the bug remains. If someone can create a step by step guide on how to get the issue to happen 100%, the bug will be fixed.
« Last Edit: August 18, 2013, 07:23:52 AM by ArenMook »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: dynamic font corruption on Galaxy S3
« Reply #2 on: August 18, 2013, 08:21:58 AM »
That said, I had an idea, and pushed 2.6.5 to Pro users that has a potential fix.

FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: dynamic font corruption on Galaxy S3
« Reply #3 on: August 18, 2013, 10:48:22 AM »
I look forward to trying that fix when it hits non-pro.  I did find something that seems to work.  Someone else posted a version of this function on another thread here, that I am calling immediately after I generate the screen in the screenshot and it does seem to fix the issue.  Strangely if even one frame passes though before I call this, it will not work.  Not sure if it gives any clues to something you could bake into NGUI though. 

  1.     public static void UILabelUpdateDynamicFonts()
  2.     {
  3.         Debug.Log("UpdateDynamicFonts");
  4.  
  5.         // find all dynamic fonts
  6.         var dynamicFonts = new Dictionary<UIFont, System.Text.StringBuilder>();
  7.  
  8.         // find all labels
  9.         UILabel[] labels = NGUITools.FindActive<UILabel>();
  10.  
  11.         for (int i = 0, imax = labels.Length; i < imax; ++i)
  12.         {
  13.             UILabel lbl = labels[i];
  14.             UIFont fnt = lbl.font;
  15.             if (!string.IsNullOrEmpty(lbl.text))
  16.             {
  17.                 if (fnt.isValid && fnt.isDynamic)
  18.                 {
  19.                     if (!dynamicFonts.ContainsKey(fnt))
  20.                     {
  21.                         //Debug.Log("Adding dynamicFonts: " + fnt.name);
  22.                         dynamicFonts.Add(fnt, new System.Text.StringBuilder());
  23.                     }
  24.                     dynamicFonts[fnt].Append(lbl.text);
  25.                     lbl.MarkAsChanged();
  26.                 }
  27.             }
  28.         }
  29.  
  30.         // request fonts
  31.         foreach (var pair in dynamicFonts)
  32.         {
  33.             UIFont fnt = pair.Key;
  34.             string text = pair.Value.ToString();
  35.             fnt.dynamicFont.RequestCharactersInTexture(text, fnt.dynamicFontSize, fnt.dynamicFontStyle);
  36.         }
  37.     }

pyamamoto

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: dynamic font corruption on Galaxy S3
« Reply #4 on: August 26, 2014, 02:03:17 PM »
Do you still have this issue and is your project quick to iterate on (load and see the issue)? Would you be willing to share the code with unity? We have the attention of Unity right now but are having trouble providing a quick enough to iterate on example with our codebase/issue.

Unity is onsite with us at this moment for this issue.


FizzPow

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
    • FizzPow Games
Re: dynamic font corruption on Galaxy S3
« Reply #5 on: August 26, 2014, 02:05:29 PM »
Sorry, this is from a project I haven't touched in almost a year now.  I gave up on using Dynamic fonts in new projects because I still kept having strange issues.  I might try again with uGUI.