EasyMofCreator - Automated Font File Creation (Windows only)

9 posts / 0 new
Last post
Felix Kenton
fpkenton's picture
Offline
Mobile Conjurer
Joined: 5 Sep 2011
Posts:
EasyMofCreator - Automated Font File Creation (Windows only)

I have written a batch script to simply the creation of the .mof files needed by MoSync. It automates the process of creating .mof files for multiple font styles, sizes, and colours. No more tediously clicking through BMFont dialog windows and repeated calls to mof.exe!

HOW TO USE

1. Download the 'EasyMofCreator.zip' file attached to this post. Unzip the contents to get the 'EasyMofCreator.bat' file and place this script into the BMFont directory of the MoSync install. For me this is "C:\MoSync\bin\BMFont\".

2. Open BMFont (using either the start menu shortcut or the BMFont.exe file in the directory above). In "Font settings set 'Charset' to OEM:ANSI to make sure only the right characters are displayed in the main window. Now pick and choose which characters you wish to include in your .mof files, and then close the application (don't forget this - your configuration is only saved on exit!).

For the script to be successful the Texture Width and Height (in the Export Options dialog in BMFont, shown below) but be large enough. Don't worry though - the script will tell you when this is a problem!

BMFont export options

3. Double-click on the "EasyMofCreator.bat" file to run it. Voila! A "fonts\" directory is created filled with small selection of lovely .mof files!

CUSTOMISING THE SCRIPT

You can easily customise the fonts, sizes, and colours created but opening the script in a text editor and editing the first three variables (lines 6-8). Font names are written in plain text (comma separated) with two optional modifiers which can be added at the end of each name: ;b for bold and ;i for italic.
eg: Arial;b,Courier New;i,Impact;b;i
The size are colour variables are more straightforward, and are adequately explained within the file.

I must warn you that the "fonts\" folder is cleaned before each run, so remember to copy the fonts to your project folders rather than referencing them here.

LIMITATIONS

The script cannot resize the texture width and height automatically, as this depends on the font, font style, font size and character selection - too many variables!

Hope this comes in handy for somebody! :D

Felix Kenton

Update: This file will be deleted when you install a MoSync update over the top of your existing directory, so remember to keep a backup copy if your configuration is important.

AttachmentSize
EasyMofCreator.zip1.8 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Patrick Broman
patrick's picture
Offline
Mobile Wizard
Joined: 17 Feb 2009
Posts:

Hey, that's very cool! :)

rishimittal
rishimittal's picture
Offline
Mobile Conjurer
Joined: 8 Mar 2012
Posts:

Hey..

        http://www.mosync.com/documentation/manualpage/font-tools

I followed this procedure but at runtime it is showing cannot parse the font file..??What Error that could be..???

 

 

rishimittal
rishimittal's picture
Offline
Mobile Conjurer
Joined: 8 Mar 2012
Posts:

Are font Sizes hardcoded in the form of .mof file...??

On different platforms ,the size of the font is same ,as I made from the tool.so Different sizes mobile screen ..flexiblity to auto size the font is not there..???

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Yeah, there is a problem somewhere.  MoSync now distributes BMFont 1.12, which I think this script works with.  I did a similar one.  The problem is that the output from BMFont 1.12 is different from the old version - BMFont 0.9c, and the MAUI Font class hasn't been updated.  Apparently the Blitz Basic guys had similar problems.  To reliably create fonts for MoSync you need BMFont 0.9c

Font sizes and colours are hardcoded - they are bitmap fonts, not vectors.  You can use the MAUI-revamp library which uses native fonts (even on J2ME devices), but you can't change the font on those.  The alternative is to build a font server for scaling fonts, but that adds a lot of overhead to your project.  Mobile development is all about compromises like that.

Create fonts of varying sizes, and change the .lst file, or use the new resource packager to select the correct mof file for the target device.

rishimittal
rishimittal's picture
Offline
Mobile Conjurer
Joined: 8 Mar 2012
Posts:

Here when I am using the different size of fonts .mof file and list them in the .lst file...would they be taken as required on the run time or I have to  program it..?????????

 

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

If you are using .lstx files, then you can do that.  If you are using .lst files, then only include the .mof files you need for that screen resolution as they are quite big and you don't want to fill up the memory with fonts you don't use.

To do it programatically with .lstx then check this: http://www.mosync.com/documentation/manualpages/resource-compiler-reference and

http://www.mosync.com/documentation/manualpage/resource-compiler-tutorial

rishimittal
rishimittal's picture
Offline
Mobile Conjurer
Joined: 8 Mar 2012
Posts:

Thanks a ton..

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

rival wrote:

Yeah, there is a problem somewhere.  MoSync now distributes BMFont 1.12, which I think this script works with.  I did a similar one.  The problem is that the output from BMFont 1.12 is different from the old version - BMFont 0.9c, and the MAUI Font class hasn't been updated.  Apparently the Blitz Basic guys had similar problems.  To reliably create fonts for MoSync you need BMFont 0.9c

I've just been inside the Font source code to fix a different bug.  It looks like the Font code *has* been updated for BMFont 1.12.  I don't know which version this changed in - it wasn't in 2.4 but it is in 3.0

Which version of MoSync are you running?