Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
2
Question by WillNode · Mar 03, 2016 at 02:51 PM · c#fontdynamics

Why Font.HasCharacter() always returns true on dynamic fonts?

Hi, basically i want to do a custom font management..

now, I have a font with limited-set of characters, take a look of this picture...

alt text

the left & right side of the picture is a set of ASCII Characters that available in a specific font, basically it work like this:

 for(int y = 0; y < 16; y++) {
    for(int x = 0; x < 8; x++) {
       if(font.HasCharacter((int)( (y << 3) | x) )))
        {
           // Character is Available,
           // Label with a Round Square Border
           // with specific character will appear
         } else {
          // Just load unbordered label 
          // with default font (Arial) displayed
         }
    }
 }

now this is the problem, you can see at the picture, both right & left is the same font, when this font in imported as unicode, only fonts that supported (in this case is caps character only) are displayed, which is work as expected.

now change it to dynamic fonts, as you can see the whole character is displayed (the rest unsupported is subtituted with arial, as the engine does when the font is dynamic), this not expected.

why this happen and how to fix it? so Font.HasCharacter will return true only when it available on specific font, even at dynamic font, or it is possible to turn off font fallbacks when using dynamic font?

any answer is appreciated.

screenshot-154.jpg (95.1 kB)
Comment
Add comment · Show 3
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 WillNode · Mar 06, 2016 at 12:05 AM 0
Share

anybody else?

avatar image WillNode · Mar 07, 2016 at 08:18 AM 0
Share

ok, the last bump,,,,

avatar image Swiftle · May 13, 2016 at 08:58 AM 0
Share

I'm also curious to know more about this issue. I want to resize the text based on the font used (since our fallback font is a bit bigger than the standard one) but there's no way to know if the character is being rendered using a fallback font.

1 Reply

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

Answer by WillNode · May 13, 2016 at 09:26 AM

Added my own temporary solution for this, i have already send this to bugfix and they confirms this, but I don't know when it got fixed. So here @Swiftle, my temporary solution:

         //Booleans to determine char at index if supported
         bool[] chars;
        //This function feeds data to chars, at asset font path (Very Slow! Works on Editor Only)
         public void PopulateCharacter(string path)
         {
             //A GLITCH: Unity's Font.HasCharacter doesn't work 
             //properly on dynamic mode, we need to change it to Unicode first
             TrueTypeFontImporter fontData = (TrueTypeFontImporter)AssetImporter.GetAtPath(path);
 
             fontData.fontTextureCase = FontTextureCase.Unicode;
             fontData.SaveAndReimport();
 
             chars = new bool[128];
             for (int i = 0; i < 128; i++)
             {
                 chars[i] =  font.HasCharacter((char)i);
             }
 
             // Change back
             fontData.fontTextureCase = FontTextureCase.Dynamic;
             fontData.SaveAndReimport();
         }
Comment
Add comment · Show 1 · 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 ilusja · Apr 01, 2020 at 08:55 AM 0
Share

Hey @WillNode, do you have any update on this case? Can't find this bug in Google and now I'm facing the same problem.

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.

Follow this Question

Answers Answers and Comments

114 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Text/font color 3 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

Changing a GUI Button's font in code 1 Answer


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