- Oct 11, 2015
- Reaction score
- First Language
- Primarily Uses
Silv.EvText.MeasureBmp.fontSize = this.fontSize; Silv.EvText.MeasureBmp.outlineWidth = this.outlineWidth; Silv.EvText.MeasureBmp.fontItalic = this.italic; this.bitmap = new Bitmap(Silv.EvText.MeasureBmp.measureTextWidth(text) + this.outlineWidth * 2, this.fontSize + this.outlineWidth * 2);
this.bitmap.fontSize = this.fontSize; this.bitmap.outlineWidth = this.outlineWidth;this.bitmap.fontItalic = this.italic;this.bitmap.drawText(this.text, 0, 0, this.bitmap.width, this.bitmap.height, 'center');
I tested it with static values just to make sure!
Silv.EvText.MeasureBmp.outlineWidth = 16; alert(Silv.EvText.MeasureBmp.measureTextWidth(text)); // 108 Silv.EvText.MeasureBmp.outlineWidth = 1; alert(Silv.EvText.MeasureBmp.measureTextWidth(text)); // 108 THEY ARE EQUAL!What? They are equal???
So Bitmap.measureText does NOT INCLUDE the outline-width... That's.... fricking.... fantastic... And then I found another bug related to text-alignment... Gotta be kidding me. RPG Maker is lately really really really pissing me of big time.
Why would you NOT include the outline width in the text-measurement... The only reason this does not go wrong with the default outlineWidth is because RPG Maker adds some sort of extra width & height around the text after measuring it because I always end up with too much space without changing the default outlineWidth. Looks like another dirty RM-quick-fix from the RM-devs.
Note that just add + this.outlineWidth * 2 is not good enough because there are lots of other factors that determine the final width (italic, fonttype, etc).
Silv.EvText.MeasureBmp.fontSize = this.fontSize + this.outlineWidth; does also not work.
An outlineWidth value of 16 equals to 13 pixels on the left side and 12 pixels on the right side (non-italic for my text with default font). So calculating it isn't easily doable... You gotta know all of the internal workings...
Last edited by a moderator: