Iavra

Iavra Fonts

Feb 3rd, 2016 (edited)
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * @plugindesc v1.00 Allows you to add any number of additional fonts to the game, mapped by their file name.
  3.  * <Iavra Fonts>
  4.  * @author Iavra
  5.  *
  6.  * @param Fonts
  7.  * @desc Comma-separated list of all fonts to be loaded, relative to the project folder.
  8.  * @default
  9.  *
  10.  * @help
  11.  * The plugin parameter "Fonts" needs to contain a list of all fonts you want to use, relative to the project
  12.  * folder. They will be mapped according to their file name.
  13.  *
  14.  * So, assuming you want to use the files "fonts/test.ttf" and "fonts/subfolder/test2.otf", the plugin parameter
  15.  * would look like this:
  16.  *
  17.  * fonts/test.ttf, fonts/subfolder/test2.otf
  18.  *
  19.  * The fonts would be available as "test" and "test2" inside the game, ready to use.
  20.  */
  21.  
  22. (function($, undefined) {
  23.     "use strict";
  24.  
  25.     var _params = $plugins.filter(function(p) { return p.description.contains('<Iavra Fonts>'); })[0].parameters;
  26.     var _param_fonts = _params['Fonts'].trim().split(/\s*,\s*/).filter(function(f) { return !!f; });
  27.  
  28.     var alias_initialize = $.initialize;
  29.     $.initialize = function() {
  30.         alias_initialize.call(this);
  31.         for(var i = 0, font; font = _param_fonts[i++]; ) { Graphics.loadFont(/([^\/]+)\..*$/.exec(font)[1], font); }
  32.     };
  33.  
  34. })(SceneManager);
Add Comment
Please, Sign In to add comment