Monday, April 8, 2019

Mega Sg Utilities - Font Generator Tool (plus Font Pak!)

Now that the Analogue Mega Sg is shipping, retro gaming enthusiasts are finally able to get an all in one solution for playing Sega Genesis games (and legacy ones too) on modern displays via HDMI. One of the interesting new features introduced with the Mega Sg is the ability to import custom fonts to tailor the OSD look to ones liking. Analogue provides a description of the file format and usage in their Mega Sg Reference Guide:
The user loaded font allows you to select your own font in place of those which come with the Mega Sg. The load font option will bring you to the file browser. If you have a directory called FONT at the root of your SD card, it will default to that directory to load a font file. The font must use an 8x8 text box and must be represented in binary in a 1-bit per pixel format. Each character will take eight bytes to represent in this format. The file must be 768 bytes in size and use the extension .fnt. The characters in the file will have to start at ASCII 20 (space) and end at ASCII 7F (delete).
Binary representation of an 'A' character font 
I've created a PowerShell module (MegaSgUtils) containing a cmdlet named New-MegaSgFont that generates fnt files from prepared source image files (aka Font sheets). New-MegaSgFont takes two parameters - path to the source image file, and path of the output fnt file. Download here

Supported image file types include BMP, GIF, JPEG, PNG, & TIFF. Expected file contains 96 8x8 pixel characters (ASCII 20h to 7Fh) for a total of 6,144 pixels read left to right, top to bottom.

Example configurations:
  • 16 columns by 6 rows arrangement (128x48px)
  • 96 columns by 1 row (768x8px)
  • 1 column by 96 rows (8x768px)

Example source font image for converting to .fnt file

Steps to generate Mega Sg font (.fnt) files

  1. Download MegaSgUtils.zip (SHA1 08B03DE9AE737432717D12A675ED16AEF153E46F)
  2. Extract archive
  3. Open a PowerShell command window
  4. Navigate to extracted directory
  5. Run: Import-Module .\MegaSgUtils.dll -Force
  6. Run: New-MegaSgFont <FullPathToFontImage> <FullPathToOutputFNTFile>
Note: The MegaSgUtils PowerShell module requires PowerShell version 4.0 or later.

 

Mega Sg Font Pak

I've also created a Mega Sg Font sample pak. Download here. Extract the FONT folder to the root of your SD card for the optimum experience (loading fonts defaults to \FONT directory).

To load fonts:
  1. Enter the Mega Sg main menu
  2. Navigate Settings → System → Menu Options → Font
  3. Select Load Font From SD Card
  4. Select desired fnt file and enjoy!

4 comments:

  1. I tried running this in Windows 10 and receive the following error:

    PS C:\tmp> Import-Module .\MegaSgUtils.dll -Force
    Import-Module : Could not load file or assembly 'file:///C:\tmp\MegaSgUtils.dll' or one of its
    dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
    At line:1 char:1
    + Import-Module .\MegaSgUtils.dll -Force
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand

    ReplyDelete
    Replies

    1. Hi there! Looks like you’ll need to “Unblock” the dll. In Windows Explorer:
      1. Right click the dll, select properties
      2. On the General tab, check the “Unblock” checkbox, and click ok.
      3. Open a new PowerShell command window and proceed!

      I’ll likely be moving the module to PowerShell gallery to mitigate this issue. Thanks for reporting!

      Delete
  2. Could you make a Mega Man font from any of the first 6 games or from 9/10?

    Thank you.

    ReplyDelete