this post was submitted on 27 Sep 2025
6 points (87.5% liked)

Godot

7267 readers
33 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

Hi all, I'm making a map game set in the cold war and am wondering how to create labels for countries similar to the ones in HOI4:

My question is, how do I:

a) Find the largest possible text size/width of text that fits in a territory's area2D, taking into account the length of the name (e.g. "Canada" vs "German Democratic Republic")

b) Create a label that spans this width with the correct position, angle, margins/padding, etc.

c) Change the size of the label dynamically when countries gain or lose territory

Also note that, since some countries have empires (see UK, France...) or faraway territories (see U.S. with Alaska), and some are island nations (see Indonesia) there can also be multiple collision shapes rather than only one. Maybe a label could be created for each collision shape as long as it's not a tenny tiny island?

Also, a bit off-topic, but I got a pause screen working! Hooray!

you are viewing a single comment's thread
view the rest of the comments
[–] jlothamer@programming.dev 4 points 3 months ago

I was looking for something similar and found an asset in the godot asset library called Font Auto Size Labels. (https://godotengine.org/asset-library/asset/2866) It only worked well at design time and not runtime so I abandoned the idea and stuck with regular labels and using elipses. But I bet if you examine how the asset works, you might be able to get it function at runtime or learn how it works and roll your own. Good luck!