MZ How to change the font of a particular window ?

Hello, everyone. I want to change the font of the Window_Command's items. I have changed in the code:
JavaScript:
Window_Command.prototype.drawItem = function(index) {
    const rect = this.itemLineRect(index);
    const align = this.itemTextAlign();
    this.resetTextColor();
    this.changePaintOpacity(this.isCommandEnabled(index));
    //Try to pass it to modify the
    this.contents.fontFace = "rmmz-mainfont, mplus-2p-bold-sub";
    this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align);
};
I saw the code execute, but it didn't work. Can anyone give me any advice?
Have you loaded "mplus-2p-bold-sub" with the FontManager?
You can see an example of this inside Scene_Boot.prototype.loadGameFonts
Format: FontManager.load(fontName, fontFile);

And by "not working" you mean it just turns to arial font?
What if you remove "mplus-2p-bold-sub"? Does it give you the regular font you've been using in-game?
Have you loaded "mplus-2p-bold-sub" with the FontManager?
You can see an example of this inside Scene_Boot.prototype.loadGameFonts
Format: FontManager.load(fontName, fontFile);

And by "not working" you mean it just turns to arial font?
What if you remove "mplus-2p-bold-sub"? Does it give you the regular font you've been using in-game?
Thanks for the reply, I found that removing "rmmz-mainfont" and then using the font name instead of the font file name solved the problem.
For clarification: it's because Bitmap#fontFace constitutes the font-family part of the font property (cf Bitmap#_makeFontNameText, rmmz_core.js).

Note that if you just want automatic bold or italic styling, MZ supports setting fontBold and/or fontItalic on the Bitmap, e.g. this.contents.fontBold = true;.

Also, rather than loading fonts on-demand, you'd generally want to name and preload the font file using FontManager.load(family, url). For example, see the loadGameFonts method of Scene_Boot.
For clarification: it's because Bitmap#fontFace constitutes the font-family part of the font property (cf Bitmap#_makeFontNameText, rmmz_core.js).

Note that if you just want automatic bold or italic styling, MZ supports setting fontBold and/or fontItalic on the Bitmap, e.g. this.contents.fontBold = true;.

Also, rather than loading fonts on-demand, you'd generally want to name and preload the font file using FontManager.load(family, url). For example, see the loadGameFonts method of Scene_Boot.
Thank you, I will check it out.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-change-the-font-of-a-particular-window.166814/