• ScreenScale Text
    6 replies, posted
[U][B]Hello Facepunch,[/B][/U] I've been trying to make my HUD scale on different resolutions but the text still seems to overlap other elements/text. I was wondering how I can use ScreenScale on text or if theres a better way to do this?
Set the position of text and size/position of all hud elements using ScrW() and ScrH(), the standard 1920/1080 resolution has a center of (960, 540).. If you hardcode in that position and someone plays on a lower resolution the point will still be at (960, 540). If you do ScrW()/2 and ScrH()/2 the position will always stay in the center of the screen no matter the resolution.
This is what I do in order to keep fonts at the same size across resolutions. Note that it will fuck up if they choose to change res after loading in. Simplely rejoining the server will fix that. [code]surface.CreateFont( 'fontname', { font = 'Roboto', size = ScreenScale( 6 ) } )[/code]
don't use screenscale it's bad it bases everything off width instead of height use this: [lua] function TextScale(x) return x / ScrH() end [/lua]
[QUOTE=Ilyaaa;52042799]This is what I do in order to keep fonts at the same size across resolutions. Note that it will fuck up if they choose to change res after loading in. Simplely rejoining the server will fix that. [code]surface.CreateFont( 'fontname', { font = 'Roboto', size = ScreenScale( 6 ) } )[/code][/QUOTE] Would it be unwise to use ScreenScale on a steam avatar? If possible?
[QUOTE=MeepDarknessM;52043713]don't use screenscale it's bad it bases everything off width instead of height use this: [lua] function TextScale(x) return x / ScrH() end [/lua][/QUOTE] I'd multiply the return value by some constant (e.g. 1080), as it is you'd have to TextScale(10800) to get 10 pixels tall on a 1080p screen. However, why is it better to scale by height and not by width?
[QUOTE=NeatNit;52047457]I'd multiply the return value by some constant (e.g. 1080), as it is you'd have to TextScale(10800) to get 10 pixels tall on a 1080p screen. However, why is it better to scale by height and not by width?[/QUOTE] Ultra wide exists, and some resolutions have different aspect ratios. Considering this and knowing ScreenScale is based on width and FontData's size parameter is based on height it can make users have fonts that are disproportionate to what you wanted them to be.
Sorry, you need to Log In to post a reply to this thread.