LPX Posted May 3, 2023 Share Posted May 3, 2023 the dxDrawText function has a parameter for the font size as a scale, but I only have the pixel size, how can I convert the pixel to scale. ex: 12px -> ? Link to comment
Shady1 Posted May 3, 2023 Share Posted May 3, 2023 (edited) 17 hours ago, LPX said: the dxDrawText function has a parameter for the font size as a scale, but I only have the pixel size, how can I convert the pixel to scale. ex: 12px -> ? To convert pixel size to scale, you can use the following formula: scale = pixel size / 12 In this formula, "pixel size" represents the font size in pixels that you want to convert, and "12" represents 12 pixels which correspond to the default dpi/ppi value. For example, a font size of 12 pixels would have a scale value of 1: scale = 12 / 12 = 1 A font size of 15 pixels would have a scale value calculated as follows: scale = 15 / 12 = 1.25 The actual conversion can vary depending on the dpi/ppi value used, but a default value of 96 is typically assumed. -- define the default dpi/ppi value local dpi = 96 -- enter the pixel size you want to convert local pixelSize = 12 -- use the formula to convert pixel size to scale value local scale = pixelSize / (dpi / 12) -- print the scale value print("Scale value: ", scale) Edited May 3, 2023 by Shady1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now