How To call DrawText with align center, but with a different font size than default?

Hello,

Currently calling DrawText with align center does work:

This works:
this.drawText(hp, 0, y, this.contents.width, 'center');

However, if I change the font size before calling that fn, it's not properly centered anymore. The 'center' works having in mind the default font size. Therefore if it's a smaller sized text, it's a little shifted to the left.

This doesn't work properly:
this.contents.fontSize = 22;
this.drawText(hp, 0, y, this.contents.width, 'center');

Isn't contents supposed to auto-update the width and alignment?
I just gave Bitmap.prototype.drawText a quick see and it seems to refer to this.fontSize as a property of the bitmap object and not this.contents.fontSize

I don't have any example to tinker with right now, but what if you try this.fontSize = 22 (bitmap.fontSize) as well as contents.fontSize?

This doesn't sound right to me because you already succeeded in increasing the font size though.
I just gave Bitmap.prototype.drawText a quick see and it seems to refer to this.fontSize as a property of the bitmap object and not this.contents.fontSize

I don't have any example to tinker with right now, but what if you try this.fontSize = 22 (bitmap.fontSize) as well as contents.fontSize?

This doesn't sound right to me because you already succeeded in increasing the font size though.

Well, even if it doesn't sound right... it did the trick lol.

Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-call-drawtext-with-align-center-but-with-a-different-font-size-than-default.74976/