Phodex Games Posted February 13, 2018 Share Posted February 13, 2018 Hi I am heavily working on my own user interface system at them moment and I wonder if there is a easy way to resize a loaded font. Example pseudo code for the functionality I am searching for: --Pseudo Code self.font = Font:Load("Arial", 6, Font.Smooth) --Load Font self.font:SetSize(10) --Change size during runtime I have a solution for this by preloading the font in all sizes and then change the rendered font. But this isn't memory efficient, or are Fonts so small that it makes no diffrence, either way it does create a lot of code Thanks for ideas in advance Markus from Phodex Quote Link to comment Share on other sites More sharing options...
Rick Posted February 13, 2018 Share Posted February 13, 2018 I do the same thing in my UI system. I don't give a real font number in my UI. Instead I just do ex_small, small, medium, large, ex_large, and fill. Each "label" is a ui widget that is basically a rectangle area and I load the font for all various sizes and then I use the text functions to figure out which size is best given the ui widget area which scales by screen resolution. This way the font always "scales" as well. Yes, it's a pain, and yes you have to load various sizes (I go by 2's) but I couldn't find any way around it to get scaling fonts that don't look all stretched if you wrote to a texture and scaled the texture. Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted February 13, 2018 Author Share Posted February 13, 2018 3 minutes ago, Rick said: I do the same thing in my UI system. I don't give a real font number in my UI. Instead I just do ex_small, small, medium, large, ex_large, and fill. Each "label" is a ui widget that is basically a rectangle area and I load the font for all various sizes and then I use the text functions to figure out which size is best given the ui widget area which scales by screen resolution. This way the font always "scales" as well. Yes, it's a pain, and yes you have to load various sizes (I go by 2's) but I couldn't find any way around it to get scaling fonts that don't look all stretched if you wrote to a texture and scaled the texture. Hi Rick thanks for your answer, you got me an idea. I do it very similar within my system, but I could implement something so my UI system calculates all needed font sizes and then I only load those font sizes, instead of loading all fontsizes at once. But then, if you ever resize during runtime, you may need to load a new font, which I would like to prevent if happening during runtime, but that is not such a big deal, I guess I am just a little bit too perfectionist :D. Either way thanks for your input. Have a nice day! 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted February 15, 2018 Share Posted February 15, 2018 When a font is loaded, the vector image is rasterized into a texture and the vector data is dumped. So it can't really be resized without reloading the file. I would like to create similar functionality for loading SVG vector images. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Phodex Games Posted February 17, 2018 Author Share Posted February 17, 2018 @Josh Would be very great to have vector image support :), because rasterizing all those images (if in vector format) and finding the perfect resolution, especially if you want to provide resolution independent results, can be annoying and slows down the workflow. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.