Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
5
Question by Dezky · Nov 28, 2013 at 01:04 PM · guitextfontbold

imported font(s) : bold style looks like compressed

Hello every one,

i've a problem when I import font in unity.

Every time i put the bold style to my guiText (by inspector or with ), it looks like compressed, with no space between letters.

No problem at all with default font (arial) alt text

Does anybody allready have this problem and find a solution ? since it's impossible to change Font in ONE GUIText, it cause me a lots of problem.

Thank you in advance.

font problem.png (54.0 kB)
Comment
Add comment · Show 1
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 Nananaaa · Apr 25, 2017 at 03:34 PM 0
Share

It seems like this is an issue with Unities Arial Font. Googles Droid Sans Font is working well in both, bold and regular, styles.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by gheeler · Nov 28, 2013 at 01:58 PM

a simple solution is to import the bold version of the font as an individual font. if you're on windows you can dig it out of C:\\Windows\\Fonts

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 karljj1 · Nov 28, 2013 at 02:00 PM

Try using a bold version of the font:

http://www.xfreefonts.com/free-fonts-download/se-optimist.html

EDIT:

Ok try this: link text

Its a script that will allow you to mix bold and normal fonts. Its something i just knocked up so feel free to optimise/improve. alt text

 using UnityEngine;
 using System.Collections.Generic;
 
 public class ScriptText : MonoBehaviour
 {
     public string label;
 
     public Font normal, bold;
 
     public void OnGUI()
     {        
         // Split the string into normal/bold The first item will be normal, then bold alternating
         string[] split = label.Split( new string[] { "<b>", "</b>" }, System.StringSplitOptions.None );
 
         GUI.skin.label.alignment = TextAnchor.LowerLeft;
 
         // Normalised coords
         Rect labelRect = new Rect( transform.position.x * Screen.width, transform.position.y * Screen.height, 0, 30 );        
 
         GUI.skin.font = normal;
         for( int i = 0; i < split.Length; ++i )
         {
             if( i > 0 && !split[i].StartsWith( " " ) )
             {
                 split[i] = " " + split[i];
             }
             
             GUIContent labelGC = new GUIContent( split[i] );
 
             // Calculate the size of this item
             Vector2 sz = GUI.skin.label.CalcSize( labelGC );
 
             // Size of draw rect
             labelRect.width = sz.x;
 
             // Draw
             GUI.Label( labelRect, labelGC );
 
             // Move our rect along
             labelRect.x += sz.x;
 
             // Toggle fonts
             GUI.skin.font = GUI.skin.font == normal ? bold : normal;
         }
     }
 }


text example.zip (110.3 kB)
screen.png (23.2 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
avatar image
0

Answer by Dezky · Nov 28, 2013 at 03:15 PM

thank you for your anwsers, but i want to use normal AND bold at the same time in ONE GUIText like this : alt text

all the TTF Style are imported, but since we can't change font on the same GUIText, i can't use the bold version...

What can i do ?

Thanks again for your help !


font problem2.png (47.9 kB)
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 gheeler · Nov 28, 2013 at 03:29 PM 0
Share

is this for desktop or handheld devices?

dynamic fonts dont work properly on android and ios im pretty sure. i had problems trying to use different sizes on handhelds and they were bunched together and ins$$anonymous$$d had to import a new copy of the same font for each size i needed

avatar image Dezky · Nov 28, 2013 at 03:33 PM 0
Share

For Both, but the problem is here on desktop & iOs... Did I need to do any report to unity ?

I really need to use THIS fonts, so i'm a little bit blocked...

avatar image gheeler · Nov 28, 2013 at 03:40 PM 0
Share

well i dont think youre going to be able to fix it for the handhelds. have you tested it with another font? you can see the problem i had with fonts here http://answers.unity3d.com/questions/403698/help-with-guistyles-between-platforms.html most of it is about textures but the font bit is there too

you may have to just do one section with one font then the next with the other but you should still be ablt to position them together if there is no padding in the guistyle

avatar image gheeler · Nov 28, 2013 at 03:42 PM 0
Share

heres an explanation of some of the problems with fonts http://wiki.etc.cmu.edu/unity3d/index.php/Unity_font_issue_on_iOS/Android

avatar image karljj1 · Nov 28, 2013 at 04:48 PM 0
Share

You could do it using a script. Use the OnGUI function and GUI.Label.

You can then use both fonts.

$$anonymous$$G a rought draft:

 public string ourLabel;
 
 public Font normal;
 public Font bold;
 
 void OnGUI()
 {
     // Split the string using the <b> tag
     for each item split
 
     GUI.skin.font = select font
     GUI.Label( item, GUILayout.Width( GUI.skin.label.CalcSize( item ).x ) );
 }

If your interested i will try and knock a script together for you later.

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

20 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

Related Questions

GuiText for Unity 4 dynamic scaling issue mobile 0 Answers

GUIText - how to set letter spacing? 2 Answers

GUI Text as a Button? 1 Answer

Cannot convert 'UnityEngine.Object' to 'UnityEngine.Font' 1 Answer

Changing the font size of GUIText (on Unity iPhone)? 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