- Home /
Change fontsize with resolution
How to change font dynamically with the screen resolution.
Answer by Fornoreason1000 · Mar 18, 2014 at 08:47 AM
well its simple, suppose your naive resolution is 1080x1920 and your font size is 32pt, you bump it down to 720x1280.
720p is 2/3 of 1080p. so 0.666*32 = 22. just convert that logic to code and your done. so its basically the formula is (currentResoltuion/nativeResolution) * Nativefont = NewFontSize
update your font size only after the resolution is been changed.something like this
void ChangeRes(int width,int height)
{
//Change Resolution here
//Update Font sizes and other GUI element sizes here
}
that way you wont be constantly recalculating your fonts. it will do so whenever you call that function.
Hop it helps
Can we get the Screen resolution height from the code?
Your answer
Follow this Question
Related Questions
EncodeToPng() with custom ppi 1 Answer
How to get the current "best fit" size of a Text component? 3 Answers
Simple way to change GUIText font size 4 Answers
Re-sizing UI text font relative to screen size 3 Answers
Scaling problem for mobile 0 Answers