Font Editor/Loader

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
Font Editor/Loader


By: Traverse (31/10/15)


Intro:

Spoiler



So I was messing around with the font options in RMMV. Wait, what font options, you say?


Indeed, there are no easily accessible font options. Most of the settings are split between the stuff in the Window_Base object and the Bitmap core object. So I decided to slap together a quick plugin to make changing the default fonts a bit more convenient. And then I started testing it.


And then, to my utter annoyance and near disbelief, I find out that custom fonts aren't recognized immediately when they're put into the fonts folder. You know, like how it WASN'T in Ace. Apparently, the go-to solution is either to install them on your machine (which, depending on what platforms you're going to export to, is not actually an option) or to edit the .css file that comes in the folder and change the default to your custom font there.


Which works until you suddenly want to use more than one custom font in your game. Yeah. So. Most of this plugin is just butt-basic options like changing font size and outline colors, but the important thing is that this plugin contains a custom font loader that allows the game to load, you know, custom fonts. Without installing them. Or changing the .css file. You can then use those loaded fonts in whatever other scripts/modifications/plugins you want.



Features:

  • Loads custom fonts placed in the fonts folder.
  • Quick access to font outline width/outline color/size/other language font settings used in Window_Base and inheriting windows.
  • Pixel offset option for text drawn by Bitmap (meant to be used with custom fonts cut-off when drawn). Negative X/Y values shift the text left/up.



Plugin:

Spoiler





//=============================================================================
// FontEditor.js
//=============================================================================

/*:
* This plugin overwrites the default behaviour of Window_Base.
* Use more than one font name separated by a comma to auto search for the
* next font if preceding cannot be found.
* Window_Base functions overwritten: standardFontFace
* standardFontSize
* resetFontSettings
* Bitmap functions redefined: drawText
*
* @plugindesc Alter the default font settings used by Window_Base and its inheritors... and load custom fonts.
* @author Traverse (31/10/2015)
*
* @param Load Custom Fonts
* @desc Add custom fonts to LOAD (not USE) here. Check Help for instructions.
* @default
*
* @param Font Name (English)
* @desc Change the default English font used by Window_Base.
* @default GameFont
*
* @param Font Size
* @desc Change the default font used by Window_Base. Default = 28.
* @default 28
*
* @param Outline Width
* @desc Change the width of the font outline. Default = 4.
* @default 4
*
* @param Outline Color
* @desc Change the color of the font outline. Default = rgba(0, 0, 0, 0.5).
* @default rgba(0, 0, 0, 0.5)
*
* @param Font Name (Japanese)
* @desc Change the default Japanese font used by Window_Base.
* @default GameFont
*
* @param Font Name (Chinese)
* @desc Change the default Chinese font used by Window_Base.
* @default SimHei, Heiti TC, sans-serif
*
* @param Font Name (Korean)
* @desc Change the default Korean font used by Window_Base.
* @default Dotum, AppleGothic, sans-serif
*
* @param Font Name (Russian)
* @desc Change the default Russian font used by Window_Base.
* @default GameFont
*
* @param Text X-Offset
* @desc Add a custom x-coordinate pixel offset to all drawn text. Use for fonts chopped off from the left. Default = 0.
* @default 0
*
* @param Text Y-Offset
* @desc Add a custom y-coordinate pixel offset to all drawn text. Use for fonts cut off from top or bottom. Default = 0.
* @default 0
*
* @help In order to use a custom font, it must first be placed in the fonts folder.
Then it must be LOADED by the game. After loading, it must be SET to be used,
either with this plugin, or another one, or by modifying the core code directly.
The format for LOADING (not SETTING) custom fonts with this plugin is:

refname,fontname/refname2,fontname2/refname3,fontname3/ect.
Example: Arial,Arial.ttf/Courier New,Courier New.ttf/ComSns,Comic Sans.ttf

Each 'refname' is a unique identifier. This is what you put in when SETTING
the font for use in the Font Name boxes of this plugin and what you will call
(as a string) if you want to set the font in a script/plugin/modification to
the core code.

Each fontname is the filename of the font you are using as it appears in the
fonts folder, and COMPLETE WITH FILE EXTENSION.

Due to how this plugin parses the strings, there must NOT be any spaces between
the commas and slashes that do not exist in the original filename.
E.g. Arial, Arial.ttf/... will NOT be loaded.
*/

(function() {
var substrBegin = document.currentScript.src.lastIndexOf('/');
var substrEnd = document.currentScript.src.indexOf('.js');
var scriptName = document.currentScript.src.substring(substrBegin+1, substrEnd);
var parameters = PluginManager.parameters(scriptName);

var eng_font_name = String(parameters['Font Name (English)'] || 'GameFont');
var jap_font_name = String(parameters['Font Name (Japanese)'] || 'GameFont');
var cn_font_name = String(parameters['Font Name (Chinese)'] || 'SimHei, Heiti TC, sans-serif');
var kr_font_name = String(parameters['Font Name (Korean)'] || 'Dotum, AppleGothic, sans-serif');
var rus_font_name = String(parameters['Font Name (Russian)'] || 'GameFont');
var font_size = Number(parameters['Font Size'] || 28);
var font_outline_width = Number(parameters['Outline Width'] || 4);
var font_outline_color = String(parameters['Outline Color'] || 'rgba(0, 0, 0, 0.5)');
var draw_text_XOffset = Number(parameters['Text X-Offset'] || 0);
var draw_text_YOffset = Number(parameters['Text Y-Offset'] || 0);

var directory = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var font_array_string = String(parameters['Load Custom Fonts']);
var split_strings = (font_array_string.split('/'));
var cust_font_hash = {};
split_strings.forEach(function(x) {
Object.defineProperty(cust_font_hash,
x.split(',')[0], {
value : x.split(',')[1],
enumerable : true})
});
Object.keys(cust_font_hash).forEach(function(refname) {
var fontname = cust_font_hash[refname];
var font_dir = directory + '/fonts/' + fontname;
console.log(refname);
console.log(font_dir);
Graphics.loadFont(refname, font_dir);
});

Window_Base.prototype.standardFontFace = function() {
if ($gameSystem.isJapanese()) {
return jap_font_name }
else if ($gameSystem.isChinese()) {
return cn_font_name }
else if ($gameSystem.isKorean()) {
return kr_font_name }
else if ($gameSystem.isRussian()) {
return rus_font_name }
else {
return eng_font_name }
};

Window_Base.prototype.standardFontSize = function() {
return font_size;
};

Window_Base.prototype.resetFontSettings = function() {
this.contents.fontFace = this.standardFontFace();
this.contents.fontSize = this.standardFontSize();
this.resetTextColor();
this.contents.outlineWidth = font_outline_width;
this.contents.outlineColor = font_outline_color;
};

var _bitmap_drawtext_trav_fontedit_271015 = Bitmap.prototype.drawText;
Bitmap.prototype.drawText = function(text, x_base, y_base, maxWidth, lineHeight, align) {
var x = Number(x_base + draw_text_XOffset);
var y = Number(y_base + draw_text_YOffset);
_bitmap_drawtext_trav_fontedit_271015.call(this, text, x, y, maxWidth, lineHeight, align);
};

}) ();



Instructions:


Contained in the plugin.


For anybody using the 27 October version of this plugin, be aware that the .js file needs to be named FontEditor.js (or else you must edit the line of code described in Post #7 of this thread to take a different filename). As of 29 October, this plugin has been updated to automatically detect whatever filename the .js file has been named to, so you can now name it anything you wish.


FAQ

Spoiler



Q. I filled out the Load Custom Fonts field but my font isn't showing up.


A. Properly filling out the field will load the font for potential use. It doesn't automatically make the game use it. That has to be set in the Font Name fields of this plugin or by another plugin or by modifying the default files.


Q. I don't know the format for filling out the Load Custom Fonts field.


A. The correct format and instructions are in the Help section of the plugin (or just read the comments in the plugin above).


Q. Why doesn't the title logo font change?


A. That font is set by Bitmap, not Window_Base. This plugin doesn't directly touch the font used by Bitmap, which remains whatever has been set as GameFont - it affects what is set afterwards by Window_Base, which changes the font initially set by Bitmap depending on language settings.


Window_Base settings affect text drawn by in-game windows, which the title logo is not drawn within; it is drawn separately and uses the font initially set by Bitmap. Which, as mentioned, doesn't differentiate between languages either; you'll notice that no matter what language settings you're using, the title will always be drawn with GameFont by default. You'll either have to change gamefont.css or use another plugin to alter that font.


Q. Do you plan to expand this plugin to allow fonts to be set for individual windows?


A. No. The reason behind this is because there are other, more fully-featured window-customizing plugins like Luna Engine or Yanfly Message that do not load custom fonts and may become incompatible with this plugin if I did this. Inserting a feature to set fonts for individual windows means altering the code for individual windows - the more this is done, the more likely this plugin will become incompatible with other window-changing plugins.


As it is, using other window-altering plugins is already likely to make everything except the fonts loader and pixel-offset options stop working anyway. The reason this shouldn't be much of a problem is that right now, the way things are set up, other plugins are likely to completely overwrite the clashing features in this one if there is a conflict. The more alterations made, the less I can guarantee an effect that clean.


Q. How do I install this plugin?


A. The same way as any other plugin. Save the code in a .js file and place in your game's plugins folder and then select from the Plugin Manager.



Credits:


- Traverse


Terms of Use:


Free to use and modify. Give credit if you use the whole thing, I spent time writing up that help segment
.


No credit necessary if only part of the plugin is used (i.e. you extract only the code for the font loader). Which means, I suppose, that you could cut out part of the comments or something and call it only using part of the plugin to avoid crediting me and I couldn't complain... although my laughter would suffice as payment in that case.


Extra Notes:

Spoiler



This plugin does overwrite three Window_Base functions, but it shouldn't really matter too much. You can even cut out just the loader too if that's all you need (if that's all you need to take, I'm won't even ask for credit). it probably wasn't the smartest or most efficient way to do it, but I don't think there's anything else that can load multiple custom fonts right now (not even Yanfly's Core, I tried). I haven't tested this on any other platform but Windows, so use at your own caution.


UPDATED 27/10/15: Added a feature to add a horizontal pixel offset for all text drawn. This is meant to be used with custom fonts that get chopped off from the left because of how they're drawn by default. This means a Bitmap function had to be redefined too.


UPDATED 29/10/15: Updated the plugin to automatically detect plugin parameters no matter what the .js file has been named as.


UPDATED 31/10/15: Added a Y-offset option for fonts cut off from the top/bottom.


UPDATED 9/11/16: Updated the formatting of the post, since it seems there were upgrades that broke the formatting.


The bulk of this post came from the topic I put up on rpgmakervxace.net. I was the one who posted that there, no plagiarism involved.
 
Last edited by a moderator:

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
YOU! I've been trying to fix font issues so much! Thank you for making this! I know it works (because the Outline is gone and Courier has been replaced by "gamefont") but i still can't get my custom font to work. This is the error i'm getting

 

Prescott

argggghhh
Veteran
Joined
Aug 28, 2014
Messages
506
Reaction score
421
First Language
English
Primarily Uses
RMMV
Have you checked and double checked that the file name and the name in the plugin are exactly the same? You may also want to try adding the extension, or removing the extension depending on which you have in there right now.

Either way, this is godsend. Thank you so much! There's been something like this for every engine, I'm not sure why it isn't a standard feature yet!
 

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
I don't know what i still haven't tried when it comes to fonts because i spent almost half an hour doing just that. Both with Yanfly and this editor
 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
I know it works (because the Outline is gone and Courier has been replaced by "gamefont") but i still can't get my custom font to work. This is the error i'm getting
Interesting... Could you show me the exact entry you put into the Load Custom Fonts field? No matter what I try, I can't seem to get an "undefined" for those strings (unless I leave the whole field blank and even then only the filename string turns up undefined).

In each refname,filename pair, the refname can be anything you want to use, but the filename has to be exactly same filename as that in the fonts folder. So if the font file is labelled "undefined", it has to be "undefined.ttf" or whatever the extension is.
 
Last edited by a moderator:

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
I did a test run with your plugin as the only active one and the result is the same. here are some screens to show what i'm doing

 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
Ahah, I think I know what your problem is! If I'm right, I should've been able to tell right from your first screenshot actually... makes me feel like I've screwed up an exam question or something :p  . My bad, really. I dunno how I overlooked this. I'm going to put this up in the instructions as soon as I can too.

 

So the filename of your plugin actually needs to be the same as the filename in this line of the code (which is the same as the first line of the comments in the plugin):

var parameters = PluginManager.parameters('FontEditor');The format you entered for all the settings was correct. It just wasn't reading anything you put in because the plugin was looking for settings for a file called FontEditor, not Traverse_FontEditor. The reason everything else was alright was because they had defaults to revert to if nothing was found in their settings. I'm guessing the outline disappeared because was what set as the default colour was unreadable, but I'll need to check that. I'm also going to see if I can replace that line of code with something that automatically reads the filename, but until that happens you should do one of two things.

 

Either rename the file from Traverse_FontEditor to FontEditor, or recode the line mentioned above to read: 

var parameters = PluginManager.parameters('Traverse_FontEditor');Many apologies!
 
Last edited by a moderator:

Joronjo

Veteran
Veteran
Joined
Sep 17, 2015
Messages
155
Reaction score
29
First Language
English Spanish
Primarily Uses
IT WORKED! THANK YOU SO MUCH! I changed the line in script to what you told me. I like to keep my scripts organized and to be able to know who to credit so that was a saver. Now i can make the games i want!
 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
You're very welcome.

I've updated the plugin so that it now automatically detects it own filename when looking for its own settings to use. Anybody using the current version can now name the .js file anything they want (as long as it doesn't contain a "/" or a ".js" in the non-extension part of the filename, anyway).
 
Last edited by a moderator:

Felix Trapper

old fogey
Veteran
Joined
Mar 14, 2012
Messages
163
Reaction score
118
First Language
English
Primarily Uses
First, excellent plugin and thank you for this!

Secondly, can you add a Y-offset to this script also? Some fonts I tried using are aligning themselves to the bottom of the message lines and as a result, menus and stuff are clipping the tails off the p's and q's...

 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
Fair point. I should've thought of that but I hadn't tested with a font that did that before.

Plugin's been updated with a y-offset option now! Use a negative value to shift up and a positive value to shift down just as how a negative X offset value shifts to the left instead of the right.
 

sbloom85

Veteran
Veteran
Joined
Nov 28, 2014
Messages
59
Reaction score
13
First Language
English
Primarily Uses
I love this plugin. Thanks for making it.
 

Coopziana

Veteran
Veteran
Joined
Jan 18, 2016
Messages
115
Reaction score
51
First Language
English
Hi, I was looking for something like this as Yanfly's Core Engine allows for the changing of fonts, however I've found that the font I want to use needs a bit of a nudge up as it sits too low and screws up the neatness of the game.


I found this plugin and figured I'd give it a shot (Copy/Paste/Save as... FontEditor.js) installed it, activate it... Some pretty strange results. In the plugin manager all the default values are Starred (e.g. Font Size: 28**), so i went through and took them all out... hmm doesn't seem to be doing anything. Maybe Yanfly scripts are causing the issue... deactivated all other plugin's, still nothing. Changed Font size to 400... no change.


I think it would be a lot easier for me to look at the script to find the potential issue if it was formatted correctly. Sadly, you're script is very messy and is a wall of text that is very difficult to read. I thought about throwing it into a java editor and fixing the formatting myself... but thought, that would be rather time consuming for something that may not work in the end anyway...


Could we perhaps have a formatted version of your script? 
 

Krimer

Veteran
Veteran
Joined
May 10, 2013
Messages
146
Reaction score
107
First Language
Ukrainian
Coopziana, its not an author fault. Last forum update broke all codes.


Here a formatted version.

Code:
//=============================================================================
// FontEditor.js
//=============================================================================
/*:
* This plugin overwrites the default behaviour of Window_Base.
* Use more than one font name separated by a comma to auto search for the
* next font if preceding cannot be found.
* Window_Base functions overwritten:     standardFontFace
*                                        standardFontSize
*                                        resetFontSettings
* Bitmap functions redefined:            drawText                           
*
* @plugindesc Alter the default font settings used by Window_Base and its inheritors... and load custom fonts.
* @author Traverse (31/10/2015)
*
* @param Load Custom Fonts
* @desc Add custom fonts to LOAD (not USE) here. Check Help for instructions.
* @default
*
* @param Font Name (English)
* @desc Change the default English font used by Window_Base.
* @default GameFont
*
* @param Font Size
* @desc Change the default font used by Window_Base. Default = 28.
* @default 28
*
* @param Outline Width* @desc Change the width of the font outline. Default = 4.
* @default 4
*
* @param Outline Color
* @desc Change the color of the font outline. Default = rgba(0, 0, 0, 0.5).
* @default rgba(0, 0, 0, 0.5)
*
* @param Font Name (Japanese)
* @desc Change the default Japanese font used by Window_Base.
* @default GameFont
*
* @param Font Name (Chinese)
* @desc Change the default Chinese font used by Window_Base.
* @default SimHei, Heiti TC, sans-serif
*
* @param Font Name (Korean)
* @desc Change the default Korean font used by Window_Base.
* @default Dotum, AppleGothic, sans-serif
*
* @param Font Name (Russian)
* @desc Change the default Russian font used by Window_Base.
* @default GameFont
*
* @param Text X-Offset
* @desc Add a custom x-coordinate pixel offset to all drawn text. Use for fonts chopped off from the left. Default = 0.
* @default 0
*
* @param Text Y-Offset
* @desc Add a custom y-coordinate pixel offset to all drawn text. Use for fonts cut off from top or bottom. Default = 0.
* @default 0
*
* @help In order to use a custom font, it must first be placed in the fonts folder.
Then it must be LOADED by the game. After loading, it must be SET to be used,
either with this plugin, or another one, or by modifying the core code directly.
The format for LOADING (not SETTING) custom fonts with this plugin is:

	refname,fontname/refname2,fontname2/refname3,fontname3/ect.
Example: Arial,Arial.ttf/Courier New,Courier New.ttf/ComSns,Comic Sans.ttf 

Each 'refname' is a unique identifier. This is what you put in when SETTING
the font for use in the Font Name boxes of this plugin and what you will call
(as a string) if you want to set the font in a script/plugin/modification to
the core code.

Each fontname is the filename of the font you are using as it appears in the
fonts folder, and COMPLETE WITH FILE EXTENSION.

Due to how this plugin parses the strings, there must NOT be any spaces between
the commas and slashes that do not exist in the original filename.
E.g. Arial, Arial.ttf/... will NOT be loaded.
*/

(function() {
    var substrBegin = document.currentScript.src.lastIndexOf('/');
    var substrEnd = document.currentScript.src.indexOf('.js');
    var scriptName = document.currentScript.src.substring(substrBegin + 1, substrEnd);
    var parameters = PluginManager.parameters(scriptName);
    var eng_font_name = String(parameters['Font Name (English)'] || 'GameFont');
    var jap_font_name = String(parameters['Font Name (Japanese)'] || 'GameFont');
    var cn_font_name = String(parameters['Font Name (Chinese)'] || 'SimHei, Heiti TC, sans-serif');
    var kr_font_name = String(parameters['Font Name (Korean)'] || 'Dotum, AppleGothic, sans-serif');
    var rus_font_name = String(parameters['Font Name (Russian)'] || 'GameFont');
    var font_size = Number(parameters['Font Size'] || 28);
    var font_outline_width = Number(parameters['Outline Width'] || 4);
    var font_outline_color = String(parameters['Outline Color'] || 'rgba(0, 0, 0, 0.5)');
    var draw_text_XOffset = Number(parameters['Text X-Offset'] || 0);
    var draw_text_YOffset = Number(parameters['Text Y-Offset'] || 0);
    var directory = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
    var font_array_string = String(parameters['Load Custom Fonts']);
    var split_strings = (font_array_string.split('/'));
    var cust_font_hash = {};
    split_strings.forEach(function(x) {
        Object.defineProperty(cust_font_hash, x.split(',')[0], {
            value: x.split(',')[1],
            enumerable: true
        })
    });
    Object.keys(cust_font_hash).forEach(function(refname) {
        var fontname = cust_font_hash[refname];
        var font_dir = directory + '/fonts/' + fontname;
        console.log(refname);
        console.log(font_dir);
        Graphics.loadFont(refname, font_dir);
    });
    Window_Base.prototype.standardFontFace = function() {
        if ($gameSystem.isJapanese()) {
            return jap_font_name
        } else if ($gameSystem.isChinese()) {
            return cn_font_name
        } else if ($gameSystem.isKorean()) {
            return kr_font_name
        } else if ($gameSystem.isRussian()) {
            return rus_font_name
        } else {
            return eng_font_name
        }
    };
    Window_Base.prototype.standardFontSize = function() {
        return font_size;
    };
    Window_Base.prototype.resetFontSettings = function() {
        this.contents.fontFace = this.standardFontFace();
        this.contents.fontSize = this.standardFontSize();
        this.resetTextColor();
        this.contents.outlineWidth = font_outline_width;
        this.contents.outlineColor = font_outline_color;
    };
    var _bitmap_drawtext_trav_fontedit_271015 = Bitmap.prototype.drawText;
    Bitmap.prototype.drawText = function(text, x_base, y_base, maxWidth, lineHeight, align) {
        var x = Number(x_base + draw_text_XOffset);
        var y = Number(y_base + draw_text_YOffset);
        _bitmap_drawtext_trav_fontedit_271015.call(this, text, x, y, maxWidth, lineHeight, align);
    };
})();
 

Coopziana

Veteran
Veteran
Joined
Jan 18, 2016
Messages
115
Reaction score
51
First Language
English
Coopziana, its not an author fault. Last forum update broke all codes.


Here a formatted version.

//=============================================================================
// FontEditor.js
//=============================================================================
/*:
* This plugin overwrites the default behaviour of Window_Base.
* Use more than one font name separated by a comma to auto search for the
* next font if preceding cannot be found.
* Window_Base functions overwritten: standardFontFace
* standardFontSize
* resetFontSettings
* Bitmap functions redefined: drawText
*
* @plugindesc Alter the default font settings used by Window_Base and its inheritors... and load custom fonts.
* @author Traverse (31/10/2015)
*
* @param Load Custom Fonts
* @desc Add custom fonts to LOAD (not USE) here. Check Help for instructions.
* @default
*
* @param Font Name (English)
* @desc Change the default English font used by Window_Base.
* @default GameFont
*
* @param Font Size
* @desc Change the default font used by Window_Base. Default = 28.
* @default 28
*
* @param Outline Width* @desc Change the width of the font outline. Default = 4.
* @default 4
*
* @param Outline Color
* @desc Change the color of the font outline. Default = rgba(0, 0, 0, 0.5).
* @default rgba(0, 0, 0, 0.5)
*
* @param Font Name (Japanese)
* @desc Change the default Japanese font used by Window_Base.
* @default GameFont
*
* @param Font Name (Chinese)
* @desc Change the default Chinese font used by Window_Base.
* @default SimHei, Heiti TC, sans-serif
*
* @param Font Name (Korean)
* @desc Change the default Korean font used by Window_Base.
* @default Dotum, AppleGothic, sans-serif
*
* @param Font Name (Russian)
* @desc Change the default Russian font used by Window_Base.
* @default GameFont
*
* @param Text X-Offset
* @desc Add a custom x-coordinate pixel offset to all drawn text. Use for fonts chopped off from the left. Default = 0.
* @default 0
*
* @param Text Y-Offset
* @desc Add a custom y-coordinate pixel offset to all drawn text. Use for fonts cut off from top or bottom. Default = 0.
* @default 0
*
* @help In order to use a custom font, it must first be placed in the fonts folder.
Then it must be LOADED by the game. After loading, it must be SET to be used,
either with this plugin, or another one, or by modifying the core code directly.
The format for LOADING (not SETTING) custom fonts with this plugin is:

refname,fontname/refname2,fontname2/refname3,fontname3/ect.
Example: Arial,Arial.ttf/Courier New,Courier New.ttf/ComSns,Comic Sans.ttf

Each 'refname' is a unique identifier. This is what you put in when SETTING
the font for use in the Font Name boxes of this plugin and what you will call
(as a string) if you want to set the font in a script/plugin/modification to
the core code.

Each fontname is the filename of the font you are using as it appears in the
fonts folder, and COMPLETE WITH FILE EXTENSION.

Due to how this plugin parses the strings, there must NOT be any spaces between
the commas and slashes that do not exist in the original filename.
E.g. Arial, Arial.ttf/... will NOT be loaded.
*/

(function() {
var substrBegin = document.currentScript.src.lastIndexOf('/');
var substrEnd = document.currentScript.src.indexOf('.js');
var scriptName = document.currentScript.src.substring(substrBegin + 1, substrEnd);
var parameters = PluginManager.parameters(scriptName);
var eng_font_name = String(parameters['Font Name (English)'] || 'GameFont');
var jap_font_name = String(parameters['Font Name (Japanese)'] || 'GameFont');
var cn_font_name = String(parameters['Font Name (Chinese)'] || 'SimHei, Heiti TC, sans-serif');
var kr_font_name = String(parameters['Font Name (Korean)'] || 'Dotum, AppleGothic, sans-serif');
var rus_font_name = String(parameters['Font Name (Russian)'] || 'GameFont');
var font_size = Number(parameters['Font Size'] || 28);
var font_outline_width = Number(parameters['Outline Width'] || 4);
var font_outline_color = String(parameters['Outline Color'] || 'rgba(0, 0, 0, 0.5)');
var draw_text_XOffset = Number(parameters['Text X-Offset'] || 0);
var draw_text_YOffset = Number(parameters['Text Y-Offset'] || 0);
var directory = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var font_array_string = String(parameters['Load Custom Fonts']);
var split_strings = (font_array_string.split('/'));
var cust_font_hash = {};
split_strings.forEach(function(x) {
Object.defineProperty(cust_font_hash, x.split(',')[0], {
value: x.split(',')[1],
enumerable: true
})
});
Object.keys(cust_font_hash).forEach(function(refname) {
var fontname = cust_font_hash[refname];
var font_dir = directory + '/fonts/' + fontname;
console.log(refname);
console.log(font_dir);
Graphics.loadFont(refname, font_dir);
});
Window_Base.prototype.standardFontFace = function() {
if ($gameSystem.isJapanese()) {
return jap_font_name
} else if ($gameSystem.isChinese()) {
return cn_font_name
} else if ($gameSystem.isKorean()) {
return kr_font_name
} else if ($gameSystem.isRussian()) {
return rus_font_name
} else {
return eng_font_name
}
};
Window_Base.prototype.standardFontSize = function() {
return font_size;
};
Window_Base.prototype.resetFontSettings = function() {
this.contents.fontFace = this.standardFontFace();
this.contents.fontSize = this.standardFontSize();
this.resetTextColor();
this.contents.outlineWidth = font_outline_width;
this.contents.outlineColor = font_outline_color;
};
var _bitmap_drawtext_trav_fontedit_271015 = Bitmap.prototype.drawText;
Bitmap.prototype.drawText = function(text, x_base, y_base, maxWidth, lineHeight, align) {
var x = Number(x_base + draw_text_XOffset);
var y = Number(y_base + draw_text_YOffset);
_bitmap_drawtext_trav_fontedit_271015.call(this, text, x, y, maxWidth, lineHeight, align);
};
})();


Fantastic. Thanks very much. Apologies Traverse I was unaware that the site messed up your formatting.
 
Joined
Apr 30, 2012
Messages
216
Reaction score
35
First Language
Spanish
Primarily Uses
It is not working for me,it could ve because im using the spanish languaje?
 

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

Latest Threads

Latest Posts

Latest Profile Posts

The Ace attorney series are so great games... But at the same time such a travesty.
Made a video showcasing a plugin (by Lanza) that adds 5 more weather effects to our MV games. :LZYsmile: Namely:
Ash-dust,
bloodrain,
Cherry Blossom Petals,
Hail,
and bubbles.

I just like this website:
lol

Forum statistics

Threads
103,238
Messages
998,294
Members
134,728
Latest member
ripleydx
Top