Center Text regarding to String lenght

Hi, is there a way to center the text, considering the string length?

In my project, I use a script call to show a message. In this message a players name is displayed. The lenght of the name can vary. But i want the text to always center in the box.

$game_message.background = 1

$game_message.position = 1

$game_message.add("\n"+$name[$turn_number] + "'s turn begins!")

How can i achieve this without modyfying the built in scripts? Can i add a centering command to this script call?
I would count the number of letters on the character's name then add spaces before it.
Ok thank you I will try it out.
It's not that optimal in some cases though as some characters tend to take more space than others but it's workable.
Better than nothing. 😀

Original thread: https://forums.rpgmakerweb.com/threads/center-text-regarding-to-string-lenght.41423/