/font-gen

A command-line tool to generate GameMaker compatible bitmap fonts

Primary LanguageJavaScriptMIT LicenseMIT

font-gen

A simple command-line tool to generate GameMaker 2.3+ compatible bitmap fonts

Setup

  1. Ensure that Node.js is installed by using the node -v command in any terminal, otherwise install Node.js
  2. Download BMFont and extract both bmfont64.com and bmfont64.exe to the depend/ folder
  3. (OPTIONAL) Open BMFont and modify the gm23.bmfc file to your liking, though this should already be setup for GameMaker compatibility
  4. Donate and download BMFont to GameMaker converter from YellowAfterlife and extract the following files to the depend/ folder:
    • neko.dll
    • gcmt-dll.dll
    • std.ndll
    • regexp.ndll
    • BmFontToYY23.n
    • BmFontToYY23.exe

Usage

  1. Create an input.json file in the root directory, see input_template.json contains a barebores layout of the file
  2. Modify input.json to your heart's content
  3. Open a terminal in the root and run node main.js -input input.json
  4. Watch the output, once the program has finished a "Exported X fonts in Xms" message will be displayed
  5. Check the export/ folder for export.yyp and respective folders inside of export/fonts/ for each of your fonts.
  6. Modify any .png files prior to importing into your project.
  7. Open export.yyp and select Tools > Create Local Package to create a local package containing the newly generated fonts
  8. Open your GameMaker project and select Tools > Import Local Package to import your fonts
  9. Voila! The font should be usable in your project now.

input.json

Below is a commented variation of the input.json file with every possible field

{
    // Optional
    "Configuration": {
        // The file to inherit settings from for BMFont, defaults to "depend/gm23.bmfc" if not provided
        "File": "depend/gm23.bmfc",

        // An optional prefix to prepend to exported font assets names, defaults to "fnt" if not provided
        "Prefix": "fnt",

        // An optional postfix to append to exported font asset names, blank/not used if not provided
        "Postfix": "_Exported",
        
        // The size of texture pages generated by BMFont, width and height must be equal and a power of two, defaults to 1024x1024 if not provided
        "Size": {
            "Width": 2048,
            "Height": 2048
        },

        // Amount to scale font sizes by, defaults to 1 if not provided.
        // 2 is selected here as it's most similar to Paint.net's font sizing
        "Scale": 2
    },
    // Required
    "Fonts": [
        // You can provide a list of fonts in this field
        {
            // The name of the exported asset, so for example with the above settings our fonts would export as
            // fntLarge_Exported
            "File": "Large",

            // The name of the font on your system, this can include spaces. If you're unsure about a font name, you can use BMFont to select the font
            // and then copy that into this field
            "Name": "Arial",

            // The size of the font you want to export, this is scaled by Configuration.Scale
            // Measured in pixels
            "Size": 96,

            // The character range to export from the font, defaults to 32-126 if not provided
            "Range": [32, 126],

            // The amount of padding to use for the font, defaults to {L: 2, R: 2, U: 0, D: 2} if not provided
            "Padding": {
                "Left": 4,
                "Right": 4,
                "Up": 2,
                "Down": 8
            },

            // The types of styling to apply to the font, can be "none", "bold", or "italic", defaults to "none" if not provided
            "Style": [
                "bold",
                "italic"
            ]
        },
        {
            "File": "Medium",
            "Name": "Arial",
            "Size": 48
        }
    ]
}

Special Thanks

BMFont by Andreas Jönsson

BMFont to GameMaker converter by YellowAfterlife