• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Herman-Tulleken · Dec 15, 2010 at 01:42 PM · mobilefontlocalizationunicode

How do I display Chinese in Unity?

I can display C$$anonymous$$nese characters fine using the default skin. But as soon as I try to skin them, using my own fonts, I can't get them to display (in the editor).

The fonts are imported using the Unicode setting, but fonts that support C$$anonymous$$nese characters (as confirmed in tests in other programs) just does not work.

T$$anonymous$$s post suggests that it must be possible: http://forum.unity3d.com/threads/20358-C$$anonymous$$nese-IME-into-Unity

Unfortunately all the links are broken.

As if to further mock me, the text even displays correctly in the inspector!

Edit: It seems even the default font does not work completely (some characters are missing). These characters are definitely in the font; I have tested t$$anonymous$$s with another program.

Edit: T$$anonymous$$s is for Android iPhone, thus using Dynamic a font is not an option.

Just to test for interest sake, I tried dynamic fonts. They work (just on PC, of course), except that the same characters are missing (in the editor). Just to emphasize, the same fonts display all the characters in other programs.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Herman-Tulleken · Dec 19, 2010 at 07:17 PM

By using larger textures, I could get the characters to display, but they looked so awful that I ended up using images for text. Because we only have 20 strings in game (and no dynamic text except for numbers), the following simple scheme worked well.

I implemented an editor feature to render the text. Because it requires System.Drawing w$$anonymous$$ch is unaccessible from the Unity project, I had to compile the core function into a DLL. The basic function takes a string, and several parameters to control the color, font, etc.

Anti-aliasing does not work correctly on a transparent background, so I drew w$$anonymous$$te text on black, and then used t$$anonymous$$s for the alpha of the final image (in a single color - the color of the font).

 void RenderText(string text, ... /*lots of parameters.*/)
 {
    Bitmap image = new Bitmap(width, height);
    Grap$$anonymous$$cs g = Grap$$anonymous$$cs.FromImage(image);
    g.Smoot$$anonymous$$ngMode = Smoot$$anonymous$$ngMode.AntiAlias;
 
    //render w$$anonymous$$te text on black
    g.DrawString(text, /*lots of parameters*/);
 
    // Pseudocode follows!
 
    // t$$anonymous$$s happens at development time
    // there is no concern for efficiency
 
    foreach pixel in image
    {
       alpha = pixel.r; //r, g, and b are all the same - see note below
       pixel.rgb = fontColor;
       pixel.a = alpha;
    }
 
    image.Save(filename);  
 }

Note: On windows, the Quality smoothness type results in text that is rendered using cool type. In t$$anonymous$$s case, the channels are not the same; I assume an aggregate of the channels can be used, but it should probably be the same as plain AntiAliased text.

My editor plugin simply calls t$$anonymous$$s function for each string in the game.

The actual game then uses these images (loaded as Textures) for labels, instead of strings when the language is C$$anonymous$$nese.

The method is crude - here are the disadvantages:

  • Not suitable for massive amounts of texts or dynamic text.
  • Not suitable to support large number of languages.
  • It's a pain to keep the look-and-feel the same as the text for other languages, especially if many styles are used. (I store a style type each string, and then render it out accordingly).

On the upside, for a small number of strings and one or two languages, it is simple to implement (much simpler than to implement your own character-based font renderer), and it looks pretty.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Herman-Tulleken · Dec 19, 2010 at 07:44 PM 2
Share

I also added this feature request: http://feedback.unity3d.com/forums/15792-unity/suggestions/1308575-dynamic-font-rendering-on-mobile-devices-?ref=title

avatar image Jean-Fabre · Jan 19, 2011 at 01:51 PM 0
Share

Interesting that you compiled a function from the editor into a dll to be available.

avatar image
2

Answer by Statement · Dec 15, 2010 at 02:21 PM

See the documenation of Font. I paste some relevant parts for quick access.

Dynamic fonts

Unity 3.0 adds support for dynamic font rendering. When you set the Characters drop-down in the Import Settings to Dynamic, Unity will not pre-generate a texture with all font characters. Instead, it will use the OS built-in font rendering to create the texture on the fly. T$$anonymous$$s has the advantage that it can save in download size and texture memory, especially when you are using a font w$$anonymous$$ch is commonly included in user systems, so you don't have to include the font data, or when you need to support asian languages or large font sizes (w$$anonymous$$ch would make the font textures very large using normal font textures).

  • Dynamic fonts are currently only supported on Desktop platforms (Mac and Windows).

Unicode support

Unity has full unicode support. Unicode text allows you to display German, French, Danish or Japanese characters that are usually not supported in an ASCII character set. You can also enter a lot of different special purpose characters like arrow signs or the option key sign, if your font supports it.

To use unicode characters, choose either Unicode or Dynamic from the Characters drop-down in the Import Settings. You can now display unicode characters with t$$anonymous$$s font. If you are using a GUIText or Text Mesh, you can enter unicode characters into the Component's Text field in the Inspector. Note that the Inspector on Mac may not show the unicode characters correctly.


I don't know about other methods you can use since I haven't been working with asian fonts myself. Did you try setting it to dynamic?


  • It seems that unicode have problems on iPhone.

T$$anonymous$$s leads me to question what "full unicode support" means. Is it enabled for iPhone? Does it only apply for desktop application? Is it a typo in the help? Are people misinterpreting the manual are make errors? It's hard to tell.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Herman-Tulleken · Dec 15, 2010 at 02:38 PM 0
Share

Thanks for the link to the docs ;) I am using Unicode, not Dynamic, as the game is for Android / iPhone.

avatar image Statement · Dec 15, 2010 at 02:54 PM 0
Share

Sigh, beats me. I haven't done asian fonts or Andriod / iPhone development. I think you're better off waiting for someone else to give a better answer.

avatar image Herman-Tulleken · Dec 15, 2010 at 02:55 PM 0
Share

Just to test, I tried Dynamic. It works to the same extent as the default font... that is, some characters are missing. (And no, it is not the font).

avatar image Statement · Dec 15, 2010 at 02:56 PM 0
Share

You might want to update your question to make it clear this is on a mobile platform.

avatar image Herman-Tulleken · Dec 15, 2010 at 03:12 PM 0
Share

Good idea; i'll do it.

Show more comments
avatar image
0

Answer by jonas-echterhoff · Dec 15, 2010 at 02:33 PM

As Statement wrote, try the "Dynamic" option. "Unicode" will pre-generate a texture of all the characters contained in the font. However, many fonts don't have c$$anonymous$$nese characters. "Dynamic" will use the OS fallback mechanisms for font rendering, so c$$anonymous$$nese characters should work regardless of whether the font has them or not.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Statement · Dec 15, 2010 at 02:55 PM 0
Share

But this only is supported on Desktop platforms. The problem Herman has is that this is for a mobile product. It wasn't immediately clear, he just commented on my answer.

avatar image Herman-Tulleken · Dec 15, 2010 at 03:02 PM 0
Share

Thanks Jonas. I have updated my question to include the extra information - the game is for Android / iPhone, so Dynamic fonts is not and option. And I also made sure the fonts I tried have all the necessary characters :) Perhaps the support for Unicode is not as complete as claimed in the docs.

avatar image Avi · Jan 09, 2011 at 02:40 PM 1
Share

Hi Herman, I wrote a small tutorial for you : http://avi.my/2011/01/dynamic-font-in-unity3d-iphone-or-android/ I am not sure if it will solve your Chinese Character or not, but it solves Dynamic Character problem. I did not have a chinese character to try out. Could you follow this and see it works or not?

avatar image Herman-Tulleken · Jan 11, 2011 at 10:42 AM 0
Share

@Avi The tutorial looks very cool, and it is sure helpful for general fonts. However, because the Chinese character set is so large, it does not look good when saved to a texture :(

avatar image Avi · Jan 13, 2011 at 06:32 AM 0
Share

hmm... I understand. Ya you need a lot of fonts for that. Sorry cant help :(

avatar image
1

Answer by Avi · Jan 02, 2011 at 10:30 AM

I had the same problem and the only t$$anonymous$$ng I could use was 3d text. I know t$$anonymous$$s is not the best solution but it might help to know it works.

I basically had to put the 3d text under the camera as c$$anonymous$$ld so that it stays on the screen even when the camera moves. Then I had to resize to scale of 0.5 in XYZ.

EDIT: Oh and just to add on, to update the 3d text you got to add like

var $$anonymous$$tCount : TextMesh;
$$anonymous$$tCount.GetComponent(TextMesh).text = ballCount.ToString() + " ball";

As you can see, my ballcount was the data I was getting.

Quite messy I know, but I could not find a better way yet

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by bnmindstorm · Jun 29, 2012 at 01:07 PM

We did create a package that supports asiatic fonts by rendering them directly as text mesh and thus not using textures to store the font. If you t$$anonymous$$nk you may be interested by t$$anonymous$$s package, have a look at our website : http://ttftext.computerdreams.org/

alt text


ttftextasiatic.png (297.9 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Unicode Character Unity iPhone 4 Answers

Localization on mobile 0 Answers

Display TM symbol in enum on GUI 1 Answer

Unicode Characters in IOS 1 Answer

Streaming assets android 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges