Jump to content
  • 0
Phodex Games

Changing fontsize of loaded font

Question

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

Share this post


Link to post

4 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
  • 0
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!

Share this post


Link to post
  • 0

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.

  • Like 1

Share this post


Link to post
  • 0

@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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...