Large fonts and memory consumption

mariomario Posts: 3Unconfirmed Member
in GUI

I'm using an icon font to display a few icons in my project. I load the ttf as a DynamicFont and then display the icon for example in a label. In a few cases I want to display a fairly large icon which I do by setting the font size to for example 512pt. I now realized that this generates textures which are incredibly large. To display one icon in 512pt, Godot will generate a 4096x4096 texture which consumes 32MB video memory. Those textures aren't re-used in elements which display the same text using the same DynamicFont, meaning displaying 2 icons will consume 64MB.

Now I could go ahead and convert the icons I use into images and then load them like that. I would want to avoid this, if possible, as using the font makes handling the outcome very flexible (color, size, placement within normal text, etc.)

Hence my question -- is there any way to reduce the memory usage? I've tried exporting and using a ttf which only contains the exact icons I use but that doesn't influence the size of the generated textures.

Thanks a lot in advance!

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 2,635Admin

    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    If you need any help, please let us know! Thanks! :smile:

  • mariomario Posts: 3Unconfirmed Member

    @TwistedTwigleg said:
    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    If you need any help, please let us know! Thanks! :smile:

    Unfortunately I can't send you a direct message due to the fact that I'm still an unconfirmed member, so I'll need to reply here. I haven't received any emails from Vanilla Forums even upon resending it. It's not in the spam folder either and I double-checked the email address. Something going wrong with outgoing emails?


    As for the issue in my original post:

    It turned out that this not only happens for icon fonts but to any text/label in Godot 3.2.*. Once bigger text is displayed (e.g. 256-512pt) Godot generates ridiculously big textures. I couldn't find any fix for this so I resorted to:

    • Stopped using an icon font altogether and started to display actual images instead
    • Reduced the size of text-based fonts and upscaled them where needed (the loss is hardly noticeable and once font sizes are below 128pt the texture sizes are manageable)
    • Relying more on instantiation and freeing text-based elements where possible so I don't keep those textures in memory for too long

    That way I managed to mitigate the issue in my project. Still I think the big textures based on text/labels is problematic. I'm no expert on how vector-based text translates to textures and whether this could be optimized at all. Will most likely file a ticket on Github to bring this up.

  • MegalomaniakMegalomaniak Posts: 2,618Admin
    edited May 26

    Make sure your email is correct, and make sure you have checked your spam filter as well.

    edit: are you sure your email shouldn't end in magenta dot de?

  • TwistedTwiglegTwistedTwigleg Posts: 2,635Admin

    @mario said:

    @TwistedTwigleg said:
    This discussion was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    If you need any help, please let us know! Thanks! :smile:

    Unfortunately I can't send you a direct message due to the fact that I'm still an unconfirmed member, so I'll need to reply here. I haven't received any emails from Vanilla Forums even upon resending it. It's not in the spam folder either and I double-checked the email address. Something going wrong with outgoing emails?

    The outgoing emails are working, but they are bouncing. I would check your email address, as @Megalomaniak suggested, and make sure the email entered is correct.

    Good to know on the private messaging thing though! I did not know that unconfirmed users cannot private message, though it makes sense. If you need to contact me privately, please get in touch via my email listed on the contact page :smile:

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file