Changing Font

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
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".
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,944
Reaction score
1,050
First Language
Dutch
Primarily Uses
RMMV
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.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
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.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,709
Reaction score
1,127
First Language
Portuguese - Br
Primarily Uses
RMMZ
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.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
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);
        }
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,709
Reaction score
1,127
First Language
Portuguese - Br
Primarily Uses
RMMZ
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?
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
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)
 

Attachments

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,709
Reaction score
1,127
First Language
Portuguese - Br
Primarily Uses
RMMZ
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.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
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
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,944
Reaction score
1,050
First Language
Dutch
Primarily Uses
RMMV
@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.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
533
Reaction score
235
First Language
English
Primarily Uses
RMMV
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.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,944
Reaction score
1,050
First Language
Dutch
Primarily Uses
RMMV
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 =)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top