Javascript RPG Maker MV font size question/problem

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
So, I'm making a somewhat custom menu for my game and I got a question/problem regarding font size.

Why is the this.contents.fontSize = 16; only affecting the drawText and not drawTextEx?
Am I doing something wrong? What do I need to change so font changes for all text inside the window?

For the record, I have no clue about javascript. I used to code a bit in ruby but that's it.

This is the code for menu status window I made
Code:
    myMenuStatusWindow.prototype.refresh = function() {
        var x = this.textPadding();
        this.contents.fontSize = 16;
        var width = this.contents.width - this.textPadding() * 2;
        this.contents.clear();
        this.drawText('Profile', 650, 100, 150, 'left');
        this.drawTextEx('\\c[1]Lewdness', 500, 150);
        this.resetFontSettings();
        if ($gameActors.actor(1).equips(1).contains($dataArmors[1]))
        {
            this.drawPicture('Maya', 0, 0);
        };
    };

This is how the menu currently looks
You don't have permission to view the spoiler content. Log in or register now.

EDIT:
I think I'll make a profile picture in GIMP and then just load the variables and position them where I want but still, I'd like to know how to solve this problem.
 

Magnus4fun

Newbie
Jun 28, 2017
18
13
I thought it would be more appropriate to answer it here.
The thing is that drawTextEx actually calls resetFontSettings() and therefore resets the font size. It does this most likely because it changes the font using the format you describe. In your case you specify the color.
A fun example since drawTextEx resets and edits the font then if you call drawTextEx first and then drawText, then drawText will actually use the font left after drawTextEx. So if you have:
this.drawTextEx('\\c[1]Lewd\\c[2]ness', 500, 150);
this.drawText('Profile', 650, 100, 150, 'left');
Then "Lewd" would be blue, "ness" would be orange, and "Profile" would also be orange.

The char '{' is usually used to make the formatted text larger and '}' smaller. This will make drawTextEx (or more precise processEscapeCharacter) call the functions "makeFontBigger" and "makeFontSmaller" which will change the font by 12.

However currently I do not think there is a way to specify the font size. However I use an old version of RPGMaker MV so that might have changed. EDIT I have now updated my RPGMaker MV and it still works

A simple fix would to add a char which specify that we will set the font size. This could be 'S'. Then change "Window_Base.prototype.processEscapeCharacter" accordingly:
Code:
Window_Base.prototype.processEscapeCharacter = function(code, textState) {
        switch (code) {
        case 'C':
            this.changeTextColor(this.textColor(this.obtainEscapeParam(textState)));
            break;
        case 'I':
            this.processDrawIcon(this.obtainEscapeParam(textState), textState);
            break;
        case '{':
            this.makeFontBigger();
            break;
        case '}':
            this.makeFontSmaller();
            break;
        case 'S':
            this.contents.fontSize = this.obtainEscapeParam(textState);
            break;
        }
    };
Using this you can write:
this.drawTextEx('\\s[16]\\c[1]Lewdness', 500, 150);​
This will now draw "Lewdness" with fontsize 16 and the color Blue.
 

kR1pt0n1t3

Active Member
Dec 31, 2017
863
1,021
Thanks again! :)

Preparing to watch Croatia - Nigeria now, gonna test this out later if I'm in a state to do it.