Hello, sorry if it wasn't clear.
I modified your code with the code I posted earlier. It works correctly now, I simply added the width calculation from the source code of RPG MZ.
Before posting the message, I checked whether the bug still occurred on a “clean” project, and it did. My apologies if the bug does not appear for you.