Changing Font

Hi, could someone help me with some code? I need to change the font for a drawText function. My game currently uses a different font than the default "GameFont" via YEP_CoreEngine.js but I actually want to use that GameFont for this specific instance. This is the part where I want the font changed:
JavaScript:
        if ($gameParty.numItems(item) == 0) {
          this.drawText('E', x, y, width, textAlign);
        } else {
          this.drawText($gameParty.numItems(item), x, y, width, textAlign);
        }

I imagine I'd only have to put it right before the 1st "drawText" since the else portion won't matter. I don't know the proper syntax for changing font though, specifically to "GameFont".
when drawing the font, you also need to revert it back to the default or previous
font you use.

so basicly, you need a couple of lines. but I dont know where to place it.
I'm pretty confident on the placement, I just need the actual code to do it lol. Your right though, I'd have to put it before and revert it right after the function.
Hi!
If this Yanfly plugin has a escape code for changing fonts in messages, can you try to use them in that?
Instead, you will have to use drawTextEx function.
I'm not in my computer right now to test it.
Hmm, but I thought the drawTextEx function doesn't support "width" which seems to be necessary for this situation. I'll try it though...if I can find the escape code for font change.

Edit: Damn, I only found these...
Font: Effect:
\fr - Resets all font changes.
\fs[x] - Changes font size to x.
\fn<x> - Changes font name to x.
\fb - Toggles font boldness.
\fi - Toggles font italic.

So I guess I'm back to the hard coding approach (which is totally fine by me).

Edit2: I think it might be this...
Window_Base.prototype.standardFontFace = function() {
return 'GameFont';
}

Edit3: Ah damn, "GameFont" just refers to the font the game is already using, sigh...
Edit4: Nope, "GameFont" is probably correct...something else must be amiss.
JavaScript:
        if ($gameParty.numItems(item) == 0) {
          Window_Base.prototype.standardFontFace = function() {
              return 'GameFont';
          }
          this.drawText('E', x + 2, y, width, textAlign);
          Window_Base.prototype.standardFontFace = function() {
              return Yanfly.Param.DefaultFont;
          }
        } else {
          this.drawText($gameParty.numItems(item), x, y, width, textAlign);
        }
Hi there!
On my pc right now. Let see if I can help you.
Where are do you want to apply these changes? Is it on the default scene item menu?
You can provide a demo project with the plugins you are using for me to try?
It is for Ossra's Grid Inventory. I want it to change the font of the quantity number on the corner of the icon. Hmm, I tried to make a demo project and pruned just about everything I can think of, but it was still too large to upload. But the only plugins involved are these: (default settings)
Try to change the line 697 to this:
if($gameParty.numItems(item) === 0){
this.drawTextEx(`\x1bfn<gameFont>${$gameParty.numItems(item)}\x1bfn<gameFont>`, x, y)
}else{
this.drawText($gameParty.numItems(item), x, y, width, textAlign);
}

Change the gameFont to the font name you want.
I believe that the \fn<n> is an escape code to change the font.
I didn't test it, and I'm really tired now(Maybe I'm doing something totally nonsense xD). So don't know if it will work.
Try to change the line 697 to this:
if($gameParty.numItems(item) === 0){
this.drawTextEx(`\x1bfn<gameFont>${$gameParty.numItems(item)}\x1bfn<gameFont>`, x, y)
}else{
this.drawText($gameParty.numItems(item), x, y, width, textAlign);
}

Change the gameFont to the font name you want.
I believe that the \fn<n> is an escape code to change the font.
I didn't test it, and I'm really tired now(Maybe I'm doing something totally nonsense xD). So don't know if it will work.
It works, but the location of the text is no longer where it should be (since it uses drawTextEx and thus doesn't have width and align).

Edit: Sigh, it's fine...I give up. I'll make do with it saying "equip" (using Kingthings Petrock Light) instead of "E" (using GameFont).
1595551726400.png
@Frostorm there might be a way to change font in each window scene if you like.
I dont know if you name the skin for each scene or just the font name, but you can
also ajust a window skin/image for each scene found here "ct_bolt_WindowEx"
it has an option to change each window a different font name, so see if it works.
Off the top of my head, I think this might be the way to do it, but I'm not quite sure:

JavaScript:
this.contents.font = "GameFont";
if ($gameParty.numItems(item) == 0) {
  this.drawText('E', x, y, width, textAlign);
} else {
  this.drawText($gameParty.numItems(item), x, y, width, textAlign);
}
this.contents.font = ???;

I'm not quite sure if it's "font" or something slightly different like "fontFace" or "textFont", and I don't know what you'd assign to change it back to the normal one.
mostly use is contents.fontFace to change it.
but if its only for 1 specific scene, you need to cache it first.

I have it dont on a plugin for a very specific reason =)

Original thread: https://forums.rpgmakerweb.com/threads/changing-font.124392/