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!
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!
Create a new scene for the country. Arrange the nodes so the area2d is the main node, and the label is a child of that node. Make sure that the label inherits traits from its parent node.
When you resize or move the Area2d it should now resize the label along with it.
Unfortunately this wouldn’t work as there’s a lot more than one country. I would have to make a label for every country, in which case I might as well just resize the labels myself…
You are only using one Area for the entire map?
No, each country is its own area.



