RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VX] In-Game Font Changer

0 Members and 1 Guest are viewing this topic.

****
I saw a squirrel...
Rep:
Level 82
...it got in my way.
In-Game Font Changer

This is something I discovered while working on my project, Bloodstained Hands. It's a useful little bit of code that allows you to change the font in-game of battle options, the menu, and if you aren't using too many complicated scripts that change the font, it can also change the font of the text boxes too.

In order for this to work, however, you do need to alter the code of one script. In "Main" below Begin and Graphics.freeze just put these two lines:

  Font.default_name = ["Font_Name"]
  Font.default_size = 20

The Font name can be changed to whatever you want, and so can the font size, but you may want to keep to fonts that are common to all computers (Arial, Arial Black, Verdana,  ect). You may also want to experiment with sizes to make sure there are no words cut off.

By the way, that code does not belong to me. I got it from a script by Woratana.

Now then, changing the font in-game!
You can do this anytime you want. Just create an event that looks like this:

@>Script: Font.default_name = ["Font_Name"]
@>Script: Font.default_size = Font_Size
(Where Font_Name is the name of the font you want to use and Font_Size is the size you want to use.)

Yes, the script is exactly the same as what was entered in Main. Yes, it can be used in-game. Yes, it is cool. You can use this for some pretty cool things, for example, an epic scene with the last boss of the game where the font for his voice is really big and creepy and the font for the main character is normal. Or you could create an item that calls a common event that sets game settings in which you could set the font (or if you have a special menu script, call it from there). The event system I use looks like this:

@>Show Choices: Verdana, Arial Black, Pristina
 :  When [Verdana]
    @>Script: Font.default_name = ["Verdana"]
    @>Script: Font.default_size = 20
    @>Set Variable [0001:Font] = 1
    @>
 :  When [Arial Black]
    @>Script: Font.default_name = ["Arial Black"]
    @>Script: Font.default_size = 23
    @>Set Variable [0001:Font] = 2
    @>
 :  When [Pristina]
    @>Script: Font.default_name = ["Pristina"]
    @>Script: Font.default_size = 30
    @>Set Variable [0001:Font] = 3
    @>
 :  Branch End
@>

Basically, what this does is show some choices as to what font you want to use, and sets the font to the one you selected. In addition, it sets the font size to fit in the window properly and it sets a variable to a number representing that font. The variable is used in a slightly different event that is necessary to make this event work properly. See, the problem with this system is that when the game is reset, so is the default font. So, once you reload your game, the font is back to normal. This can be fixed by using the following event:

@>Conditional Branch: Variable [0001:Font] == 1
    @>Script: Font.default_name = ["Verdana"]
    @>Script: Font.default_size = 20
 :  Else
    @>Conditional Branch: Variable [0001:Font] == 2
    @>Script: Font.default_name = ["Arial"]
    @>Script: Font.default_size = 23
     :  Else
        @>
     :  Branch End
    @>
 :  Branch End

What this does is reads what number the Font variable is set to, and then sets the font to whatever font that number represents. This can be done for as many fonts as you want. The trick with this, however, is that it has to be running at all times in all maps. The easiest way to do this is to set is to a common event with a parallel process activated by a switch.

So that is the in-game font changer. Credit goes to Woratana for the code, you don't need to credit me for the system. Although you can if you want to and feel nice. Feedback is appreciated.

Thought I might just mention this now, although it can also be seen in the comments below, you must have all custom fonts included in the DL of your game.
« Last Edit: February 23, 2014, 03:55:48 PM by modern algebra »

Gods ain't gonna help ya son...

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Not bad. Don't forget that any custom fonts would have to be included with the game and installed before gameplay.

****
I saw a squirrel...
Rep:
Level 82
...it got in my way.
I suppose that's true... well, that certainly makes it easier to make sure the computer has the font installed! :D
« Last Edit: November 05, 2010, 10:57:42 PM by Strak »

Gods ain't gonna help ya son...

****
I saw a squirrel...
Rep:
Level 82
...it got in my way.
Ah, I have discovered a minor error. Nothing serious, and it can probably be fixed easily, but I'll bring it to everyone's attention now. While this DOES change the font in-game, the font will revert back to the default font when you re-open the game again, until you change it again in-game. Another note is that if you change the font in one file, the font is changed for every file in the game. I will fix this ASAP.
« Last Edit: November 05, 2010, 10:58:06 PM by Strak »

Gods ain't gonna help ya son...

****
I saw a squirrel...
Rep:
Level 82
...it got in my way.
Alright, I found a mediocre way of fixing this problem, but it IS a bit tedious. It does work though, and it not only resets the font on one file, but it makes sure that each separate file can have its own font.

(1) Every time you change the font in-game, set a variable to a value that represents that font. Example:

@>Script: Font.default_name = ["Verdana"]
@>Script: Font.default_size = 20
@>Control Variables: [0001:Font] = 1

(2) Make an event that looks like this:

@>Conditional Branch: Variable [0001:Font] == 1
    @>Script: Font.default_name = ["Verdana"]
    @>Script: Font.default_size = 20
 :  Else
    @>Conditional Branch: Variable [0001:Font] == 2
    @>Script: Font.default_name = ["Arial"]
    @>Script: Font.default_size = 23
     :  Else
        @>
     :  Branch End
    @>
 :  Branch End

Basically, this event should set the default font to whatever font the variable representing it is set to. You can make as many Conditional Branches as need be, for as many fonts as you are using. The event should be a parallel process, and should constantly be running.

(3) This is the tedious part. Place this event on every map in the game. I know this isn't the BEST way to deal with this problem, but it gets the job done.
« Last Edit: November 05, 2010, 10:58:25 PM by Strak »

Gods ain't gonna help ya son...

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
Alright, I found a mediocre way of fixing this problem, but it IS a bit tedious. It does work though, and it not only resets the font on one file, but it makes sure that each separate file can have its own font.

(1) Every time you change the font in-game, set a variable to a value that represents that font. Example:

@>Script: Font.default_name = ["Verdana"]
@>Script: Font.default_size = 20
@>Control Variables: [0001:Font] = 1

(2) Make an event that looks like this:

@>Conditional Branch: Variable [0001:Font] == 1
    @>Script: Font.default_name = ["Verdana"]
    @>Script: Font.default_size = 20
 :  Else
    @>Conditional Branch: Variable [0001:Font] == 2
    @>Script: Font.default_name = ["Arial"]
    @>Script: Font.default_size = 23
     :  Else
        @>
     :  Branch End
    @>
 :  Branch End

Basically, this event should set the default font to whatever font the variable representing it is set to. You can make as many Conditional Branches as need be, for as many fonts as you are using. The event should be a parallel process, and should constantly be running.

(3) This is the tedious part. Place this event on every map in the game. I know this isn't the BEST way to deal with this problem, but it gets the job done.

You could just make it a common event, and set it to parallel process it with a switch.

****
I saw a squirrel...
Rep:
Level 82
...it got in my way.
That is a very good idea, I hadn't thought of that.

Gods ain't gonna help ya son...

**
Rep: +0/-0Level 67
RPGVX Advanced (I Do Not Script Tough)
If You Are Using A Costum Message System Like Modern Allegra's ATS,
You Could Do This In Order To Have Your Fonts In Messages.

I'm Using This In My Game Right Now And It Work Well.

Like In Your Exemple With The "Font" Variable Above, You Use A Conditionnal Branch In Order To Get Your Font Back After A Reset. What I Did Also Include That Variable. Create A New Event And Add As Many Pages As The Number Of Fonts Your Character Can Use In Your Game, As For Me It's 3. It Could Take Long Adding This To All Of My Events But At Least It Work. On Each Pages Put One Condition Of Activation At the Very Left Of Your Page:

@>Variable:Font
Equal To (The First Number Of The Font Your Character Can Choose)

And On This Page Add The Code \fn[thenameodyourfirstfont] at The Beginning Of Each Text Box. As For The Other Pages, Only Change The Variable And The text Code  :)

Hope It Helped !  :lol:


*
A-pow 2015
Rep:
Level 81
2014 Best RPG Maker User - GraphicsFor frequently finding and reporting spam and spam bots2013 Most Unsung MemberSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.How can I help you? :Da^2 + b^2 = c^2Secret Santa 2012 ParticipantSilver - GIAW 10Silver - GIAW 9Bronze - GIAW HalloweenGold - Game In A Week VII
I'm not sure I follow what you're trying to say, but

Modern Allegra

I lol'd :V



**
Rep: +0/-0Level 67
RPGVX Advanced (I Do Not Script Tough)
sorry for my bad english :-\