Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Simurr on June 24, 2013, 10:53:43 AM

Title: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: Simurr on June 24, 2013, 10:53:43 AM
We are using NGUI 2.3.3h and Unity 4.2b5 (was also an issue with 4.2b3 and 4.2b4).  The dynamic font we are using is the DroidSansFallback TTF font from Android.  Everything works fine for standalone desktop builds but when I make a Windows App Store build none of the non-latin fonts show up (Japanese, Korean, Chinese etc.).

There are no error logs from the player.  DroidSansFallback is the only font we have setup and the latin fonts look like they are using droid sans.

Any ideas what could be the problem?
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on June 24, 2013, 10:57:45 AM
2.3.3 is back from February. How do you expect it to work with the latest beta of a platform that did not exist at that time?
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: Simurr on June 24, 2013, 11:19:03 AM
Sorry, wrong version.  NGUI is at least 2.6.1d.  I was going off a readme file left in the folder.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: Simurr on June 24, 2013, 01:35:12 PM
Just updated to 2.6.3.  Didn't fix the issue.  Actually added a compile issue for Windows App Store, but that's a separate problem.  Any ideas on this?
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on June 25, 2013, 01:23:13 AM
Try creating a GUIText or a 3D Text using that font and see if it shows up.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: Simurr on June 25, 2013, 04:48:21 PM
Made a simple test with 11 languages as 3d text and UILabels.  3D Text works fine, UILabels don't show non-latin characters.  I've attached example images of a standalone win build and a metro build.  Left side is 3D Text, right is UILabels. 
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on June 25, 2013, 05:44:37 PM
Interesting. So this issue is only presenting itself in the metro beta 4.2, and only with Win8 targeted... and only in the build, not in the editor? Sounds like something fishy is going on on the Unity's side again. I can't say I'm surprised. Dynamic font support has been finicky at best.

Just to clarify -- where is the label text coming from?  Is it set in inspector, or do you load it from some file?
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: Simurr on June 26, 2013, 09:11:32 AM
In our game we are setting text in the editor and from a language file.  The example project only uses in editor text.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: liu_yin_ on September 13, 2013, 06:16:09 PM
I ran into the same issue with Unity 4.2 and NGUI 2.6.4. Is this issue resolved in NGUI 2.7 or 3.0?
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on September 13, 2013, 10:24:03 PM
I honestly don't know. I don't have a win 8 device to try this on.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: liu_yin_ on September 14, 2013, 01:00:39 AM
Hi ArenMook,

Thanks a lot for the quick response.

I just verified NGUI 2.7.0 with Unity3D 4.2, only English characters can be displayed on Windows Phone 8 and Windows 8 Metro. Any non-latin character will disappear when using UILabel on both platform.

I also tried to verify last NGUI 3.0 with Unity3D (I just bought Pro license today). NGUI 3.0 doesn't compile with the following error on Windows 8 Metro due to changes in EventDelegate. I guess it's probably due to incompatibility between WinRT and Mono.

Assets\NGUI\Scripts\Internal\EventDelegate.cs(104,87): error CS1061: 'EventDelegate.Callback' does not contain a definition for 'Method' and no extension method 'Method' accepting a first argument of type 'EventDelegate.Callback' could be found (are you missing a using directive or an assembly reference?)
Assets\NGUI\Scripts\Internal\EventDelegate.cs(108,49): error CS0117: 'System.Delegate' does not contain a definition for 'CreateDelegate'

If you have a Windows 8 machine with Visual Studio installed, you don't need Windows 8 or Windows Phone 8 device to repro. You can directly load the generated Metro or WP8 project in Visual Studio and run it in emulator. And VS has excellent debug support for the Metro project generated by Unity3D, you can do line by line debugging of C# script with emulator.

I will really appreciate your help here since localization is very important for the project that I am currently working on. Actually we have more non English speaking players in our game. It's a really blocking issue to us if NGUI cannot display non-latin characters on Windows Phone 8 and Windows 8 Metro device. If you can give me some hint on where to set break point and what to look for, I will be happy to debug it on my side and report back my findings.

Thanks again!

Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on September 14, 2013, 11:50:20 AM
So Windows 8 doesn't support reflection either, not just WP8... ew. Well, I've added it to the list of "shitty platforms" alongside Flash and WP8, so if you grab the latest it will compile now.

And no, I don't have a Win8 machine. I hate that OS. Win7 I like. M$ seems to get it "right" every other release. XP was great, Vista sucked. Win7 was great, Win8 sucked...

You having pro does make trying things quite a bit easier though. In any case, I strongly advise you submitting a bug report about this to Unity. Any inconsistencies between editor and run-time should be reported -- especially if they work on all other platforms except Win8.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: liu_yin_ on September 14, 2013, 03:54:23 PM
Hi ArenMook,

Again, thanks for the quick response. But I think there may be some misunderstanding about this issue.

1) The non-latin character issue happens on both Win8 and WP8. If you happen to have WP8 device, you will also be able to repro this issue. But debugging will be pretty hard though.
2) I have tried to create 3D Text and GUI Text inside Unity with the font I use, and both of them are displayed properly in Win8 and WP8 device. Therefore, I think the issue is caused by some behavior inconsistency of dynamic font on Win8 & WP8, which NGUI's UIFont didn't expect and bail out when rendering non-latin character on both platforms.

I will for sure report this issue to Unity since it's platform inconsistency. However, giving them a project with NGUI UILabel containing non-latin character may not be that helpful. If you can shed some light and point me to the places where UILabel/UIFont expects to get data from dynamic font, and may likely to bail out, it will be very helpful since I will be able to debug it on my side and figure out where the behavior change is.

Thanks,
Yin
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on September 14, 2013, 04:09:38 PM
1. I understand, and I don't have either.

2. Dynamic font support is likely the cause here. Unity's dynamic font support is a recent addition, and the fact that it doesn't work on Win 8 / WP8 just shows that it's bugged. You need to report it to Unity. There is nothing I can do on the NGUI's side. All NGUI does is gets the dynamic font's characters -- which apparently doesn't work on WP8/Win8 devices. Don't worry, QA are quite used to people reporting issues shown by using NGUI in ways they did not test properly.
Title: Re: Unity 4.2 NGUI dynamic font not displaying non latin character in Win8 & WP8
Post by: liu_yin_ on September 14, 2013, 08:40:11 PM
I just did some further debugging on my side and found there is actually a bug inside Unity's implementation of Font.GetCharacterInfo for non-latin character on WP8 and Win8 platforms. It will return false although the requested character actually exists in the texture. Fortunately, with Font.characterInfo, it's fairly easy to re-implement the logic of Font.GetCharacterInfo and patch it up for WP8 and Win8 platform. I tested my fix on both platforms and verified Font.GetCharacterInfo is the only breaking part.

I will file a bug to Unity since now the repro and root-cause is fairly clear. Hopefully they can get it fixed soon.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: stephan7 on October 05, 2013, 06:49:44 AM
Hi everyone,

Regarding the error CS1061: 'EventDelegate.Callback' does not contain a definition for 'Method' mentioned above:

I solved it temporarily with a quick hack by writing a minimalistic plugin for WinRT.

The WinRT plugin has the following method:
public static string GetMethodName(Object callback)
{
    Delegate d = callback as Delegate;
    return d.GetMethodInfo().Name;
}


In the standard plugin for Non-WinRT builds this method looks like:
public static string GetMethodName(Object callback)
{
   Delegate d = callback as Delegate;
   return d.Method.Name;
}


Depending on whether you are making a build for WinRT or another platform Unity is automatically choosing the correct plugin.

BTW: one can't work with a conditional compile because GetMethodInfo() is not recognized by Unity's transformation from Mono to WinRT's .Net.

Perhaps that's useful for the one or other NGUI user.

Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: baptiste39100 on October 16, 2013, 10:51:17 AM
Hi,

stephan7 can you share your dll please, i can't compile a plugin there is no "blanck solution" available in my vs studio and i haven't fnd a solution yet....
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: stephan7 on October 18, 2013, 01:44:29 AM

stephan7 can you share your dll please, i can't compile a plugin there is no "blanck solution" available in my vs studio and i haven't fnd a solution yet....


There is an even simpler solution available that requires no plugin.

    private void ShowInfoAboutCurrentCallback()
    {
#if !UNITY_EDITOR && UNITY_METRO
        Debug.Log(callback.GetMethodInfo().Name);
#else
        Debug.Log (callback.Method.Name);
#endif
    }

On all other platforms it seems, that Unity supplies it's customized mono implementation. But not on WinRT.

Hope this helps,

Stephan
--
http://www.software7.com
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: blu3wings on November 01, 2013, 12:49:58 PM
Hi everyone,

Regarding the error CS1061: 'EventDelegate.Callback' does not contain a definition for 'Method' mentioned above:

I solved it temporarily with a quick hack by writing a minimalistic plugin for WinRT.

The WinRT plugin has the following method:
public static string GetMethodName(Object callback)
{
    Delegate d = callback as Delegate;
    return d.GetMethodInfo().Name;
}


In the standard plugin for Non-WinRT builds this method looks like:
public static string GetMethodName(Object callback)
{
   Delegate d = callback as Delegate;
   return d.Method.Name;
}


Depending on whether you are making a build for WinRT or another platform Unity is automatically choosing the correct plugin.

BTW: one can't work with a conditional compile because GetMethodInfo() is not recognized by Unity's transformation from Mono to WinRT's .Net.

Perhaps that's useful for the one or other NGUI user.



Nope. Not working for me. I tried Method an GetMethodInfo(). I can't compile for Metro. Am I missing anything here?
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: Filimindji on November 03, 2013, 07:55:25 AM
Hi there,

This is a solution that work for PC, Windows Store App and Windows Phone 8 - at least for me :

  1.  
  2. #if UNITY_EDITOR || (!UNITY_FLASH && !UNITY_WP8 && !UNITY_METRO)
  3. #define REFLECTION_SUPPORT
  4. #endif
  5.  
  6. // no #if before
  7. using System.Reflection;
  8.  
  9.  

...

  1.  
  2. #if !UNITY_EDITOR && UNITY_WP8
  3.     static string GetMethodName (Callback callback)
  4.     {
  5.         System.Delegate d = callback as System.Delegate;
  6.         return d.Method.Name;
  7.     }
  8.  
  9.     static bool IsValid (Callback callback)
  10.     {
  11.         System.Delegate d = callback as System.Delegate;
  12.         return d != null && d.Method != null;
  13.     }
  14. #elif !UNITY_EDITOR && UNITY_METRO
  15.     static string GetMethodName (Callback callback)
  16.     {
  17.         System.Delegate d = callback as System.Delegate;
  18.         return d.GetMethodInfo().Name;
  19.     }
  20.  
  21.     static bool IsValid (Callback callback)
  22.     {
  23.         System.Delegate d = callback as System.Delegate;
  24.         return d != null && d.GetMethodInfo() != null;
  25.     }
  26. #else
  27.  
  28.     // Perhaps it can be improved by merging this with the first #if
  29.     // I will let you try that ;)
  30.  
  31.     static string GetMethodName (Callback callback) { return callback.Method.Name; }
  32.     static bool IsValid (Callback callback) { return callback != null && callback.Method != null; }
  33. #endif
  34.  
  35.  

Well, I can't test for WP8 because I have no device, but it compile without error.

Let me know if it helps.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: ArenMook on November 03, 2013, 08:52:55 AM
So Win8 is different from Windows Phone 8. Makes sense. Not. Someone derped this one.
Title: Re: Unity 4.2 beta NGUI dynamic fonts not displaying non latin characters in metro
Post by: stephan7 on November 17, 2013, 07:36:30 AM
The WinRT and WP8 API have the same ancestor, but they have surprisingly significant differences.