Author Topic: Dynamic font randomly don't show properly  (Read 66605 times)

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #75 on: August 27, 2013, 04:21:53 PM »
@kimsama: It works!! thanks a lot!

@Aren: Could you applied this patch to 2.6.5? now it's something similar but continues with the issue.

I'll use this patch for the coming projects, thanks!

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #76 on: August 28, 2013, 05:27:11 AM »
I have a fix for this problem in 2.6.5 version(PRO)

I've replaced the following lines in UIFont.Print function
  1. if (!mDynamicFont.GetCharacterInfo(c, out mChar, mDynamicFontSize, mDynamicFontStyle))
  2.         continue;
  3.  

with these lines

  1. if (!mDynamicFont.GetCharacterInfo(c, out mChar, mDynamicFontSize, mDynamicFontStyle))
  2. {
  3.         mDynamicFont.RequestCharactersInTexture(c.ToString(), mDynamicFontSize, mDynamicFontStyle);
  4.         if (!mDynamicFont.GetCharacterInfo(c, out mChar, mDynamicFontSize, mDynamicFontStyle))
  5.         {
  6.                 Debug.LogError(string.Format("Character {0} could not be found in font texture!", c));
  7.                         continue;
  8.         }
  9. }
  10.  

I don't think it is the right way to fix it, but it works for now

kimsama

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 9
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #77 on: August 28, 2013, 08:32:29 PM »
Bug is still present =(
Reproducible on IPad mini

@dkozlovtsev

Are you using NGUI 2.6.5 on iPad mini?

Randomly disappearing fonts bug is only being on several Android devices as I know.

I'm using Unity 4.1.5 with NGUI 2.6.3 and 2.6.4. (not tested with the latest version of Unity and NGUI 2.6.5)

Cheers,

-Kim

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #78 on: August 28, 2013, 09:08:25 PM »
@dkozlovtsev

Are you using NGUI 2.6.5 on iPad mini?

Randomly disappearing fonts bug is only being on several Android devices as I know.

I'm using Unity 4.1.5 with NGUI 2.6.3 and 2.6.4. (not tested with the latest version of Unity and NGUI 2.6.5)

Cheers,

-Kim
@kimsama
No, your fix doesn't work on 2.6.5 because Aren implemented something similar and have conflicts with it. But with 2.6.4 works like charm.

Thanks again.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #79 on: August 28, 2013, 11:42:26 PM »
I will have another look at it when I return from Unite.

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #80 on: August 29, 2013, 03:06:06 AM »
@dkozlovtsev

Are you using NGUI 2.6.5 on iPad mini?

Randomly disappearing fonts bug is only being on several Android devices as I know.

I'm using Unity 4.1.5 with NGUI 2.6.3 and 2.6.4. (not tested with the latest version of Unity and NGUI 2.6.5)

Cheers,

-Kim

Yep i'm using 2.6.5 but the problem was present even before 2.6.5, it was the reason i've updated NGUI.
Actually current NGUI from Pro repository is kinda unstable, i'm reverting it for now.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #81 on: August 29, 2013, 05:51:09 PM »
Unstable how?

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #82 on: August 30, 2013, 12:47:33 AM »
Unstable was not the right word my current issue is that dynamic fonts blinking on texture resize has resurfaced, possibly due to removing callbacks on texture change of dynamic fonts and removing line:
  1. if (mHasChanged) MarkAsDirty();
  2.  
from mFont.Request function

Also there are few lines in mFont like this
  1. #if DYNAMIC_FONT
  2.                 if (mDynamicFont != null) mDynamicFont.RequestCharactersInTexture(text);
  3. #endif
  4.  
It causes font generation with wrong character sizes, and the following condition fails
  1. if (mDynamicFont.GetCharacterInfo(c, out mChar, mDynamicFontSize, mDynamicFontStyle))
  2.  
In my opinion this.Request should be called instead or at least mDynamicFont.RequestCharactersInTexture with all 3 arguments specified.


Or i may be completely wrong, sorry if it is the case, i'm kinda new to NGUI codebase =)
Currently i've reverted to intitial 2.6.5 BETA it least text doesn't blink on this version =\
« Last Edit: August 30, 2013, 01:28:50 AM by dkozlovtsev »

brzozowsky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #83 on: September 15, 2013, 07:42:17 AM »
@kimsama:
How to apply this dynamic.fonts.fix.patch?

jjobby

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #84 on: September 18, 2013, 04:54:17 PM »
I really don't know what's wrong but I have this problem with dynamic font in every platform I've tested (Window, Mac, iOS). It even happens in Unity Editor. It looks like there is a problem with RequestCharactersInTexture(string) method. I changed these codes in UIFont.

  1. mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize)

To

  1. for (int i = 0; i < text.Length; ++i)
  2. {
  3.     mDynamicFont.RequestCharactersInTexture(text[i].ToString(), mDynamicFontSize, mDynamicFontStyle);
  4. }

I changed it to check one character at a time and this somehow fix the problem for me. May be this method cannot process an entire length of string correctly?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #85 on: September 19, 2013, 08:11:10 AM »
To fix it properly, change:
  1. mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize)
to:
  1. mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize, mDynamicFontStyle)
This change is already in NGUI 3.0.

hitorijanai

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #86 on: September 20, 2013, 01:25:23 AM »
I found that the problem is purely Unity's dynamic font bug (even sometimes TextMesh is missing some characters on some devices), and I made a patch to fix dynamic font problem for NGUI 2.7.0 and it seems to be working properly on Galaxy S3. The patch is based on Kimsama's test and patch for NGUI 2.6.4, but works in a quite different way and without altering UIPanel's LateUpdate steps into OnGUI (which makes Unity editor mode quite messy when working on NGUI components).

« Last Edit: September 20, 2013, 04:56:59 AM by hitorijanai »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #87 on: September 20, 2013, 03:32:37 AM »
Version 2.7.0 UILabel? Go for it.

3.0.0 has been reported to have this problem fixed already.

hitorijanai

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Dynamic font randomly don't show properly
« Reply #88 on: September 20, 2013, 05:16:39 AM »
I think the problem is still there, because I have tested it using TextMesh which is Unity's own component (Unity 4.2 and Galaxy S3), by brutally changing text of a label each frame. Both UILabel and Unity's TextMesh failed to render the label correctly without missing some characters. The problem seems to be solved when you change the text only in OnGUI method. Very strange indeed..

jsbanwjly

  • Guest
Re: Dynamic font randomly don't show properly
« Reply #89 on: September 24, 2013, 02:04:59 AM »
I have this problem too.(2.6.4)
We using Chinese, and we have a language table, which have all the words we need in game.
I fix this in awake function by steps:
1、Load language table. All words in "string languageString";
2、Reference UIFont we used in "UIFont  font";
3、call method like this: font.dynamicFont.RequestCharactersInTexture(languageString, font.dynamicFontSize, font.dynamicFontStyle);
then we have a font texture with size 1024*2048. then the problem is gone when game is playing.
don't know is it the right method, but it works.
(the texture is max enough for new words. so i think it won't be bigger anymore)
« Last Edit: September 24, 2013, 02:26:55 AM by jsbanwjly »