- Home /
How can I set the UI Text font size higher than 300px ? | Unity 5.4
The maximum UI Text font size can't be set higher than 300, but I want it to be like 500 or something. Is there a free way of doing this ?
Thanks in advance.
clarification: this is not a answer, just a fix to change the size. you can easy increase the scale of the RectTransform attached to the gameobject that contains the text, this will increase the text size in the canvas.
Answer by DiegoSLTS · Aug 15, 2016 at 03:05 AM
You can set a bigger size changing the fontSize field with a script. A simple example:
Add a Canvas with a Text child. Set the Canvas to scale with screen size and put something like 1920x1080. Set the Text's anchor to stretch vertical and horizontal and make sure top, bottom, left and right are 0. Add this script to the Text.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class TextSizeTest : MonoBehaviour {
[SerializeField]
int size = 300;
Text t;
void Awake() {
t = GetComponent<Text> ();
}
void Update () {
t.fontSize = size;
}
}
Press play and try different values in the inspector.
I just tested with the default Arial font and another .ttf that I imported. The max may be different for different fonts with more characters.
so, the clamp of the size is in the inspector, not in the text class, I learn something new, thanks.
Answer by Addyarb · Aug 14, 2016 at 08:38 PM
You don't need to increase the size of the font, you just need to scale the transform of the object that your Text component is on. There's almost no scenario where manually increasing the font size past 300 makes sense.
To get a font size equivalent to that of a 500 size, try scaling your font to 100 and then setting the scale to 5,5,5.
Scaling streches the image, it looks really bad if you scale a text by 5.
Also, "There's almost no scenario where manually increasing the font size past 300 makes sense" sounds too arbitrary.
True but I just set the font to 300 and scaled it by 1.2 or something. Works for now...
Your answer
Follow this Question
Related Questions
How to fix TextMeshPro breaking lines and escaping random characters? 0 Answers
IOS Unity 5 UI, Font/Text not displaying/Disappearing 3 Answers
Text blurred: uGUI 4.6 9 Answers
When game resolution is 4k, UI text font size stops scaling from 145 0 Answers
How to measure the width of a string? 0 Answers