Skip to content

Might and Magic 6 7 8 and Heroes 3 FNT (font) File Generator for Multiple Languages (Python Script) 🔤👾

License

Notifications You must be signed in to change notification settings

might-and-magic/fnt-generator

Repository files navigation

FNT Generator

MIT License

Might and Magic 6 7 8 and Heroes 3 FNT (font) File Generator for Multiple Languages (Python Script). It uses another small library of mine: BDF Parser

Usage

Instantiation

FntObject = FntGen(<FONT_FILE_PATH>)

Example:

FntObject = FntGen('example_fonts/bdf/unifont-9.0.06.bdf')

setCharset

FntObject.setCharset(<CHARSET>)

Set charset. CHARSET is a string

  • All single-byte charsets are supported, typical example:
    • cp1252 (default value, for latin alphabet-based languages, e.g. en, fr, de, es, it)
    • cp1251 (for Cyrillic script-based languages, e.g. ru)
    • cp1250 (for Central European languages, e.g. cs, pl)
  • For double-byte charsets (DBCS), only gb2312 (zh_CN), gbk (zh_CN), big5 (zh_TW), euc_jp (ja), euc_kr (ko) are supported

Example:

FntObject.setCharset('cp1252')

setDecoration

FntObject.setDecoration(<DECORATION>)

Set decoration. DECORATION is a string, it can be: empty, shadow, black, or glow

Example:

FntObject.setDecoration('shadow')

output

FntObject.output(<FILE_NAME>, [PATH])

Output .fnt file(s). FILE_NAME is a required string parameter, PATH is an optional string parameter.

If there is any "<SIZE>" in FILE_NAME parameter, it will be replaced by the final font's actual size.

For single-byte charsets, a single .fnt file is generated.

For double-byte charsets (DBCS), it outputs multiple .fnt files. Each file name is followed by a hex representation of its corresponding high byte.

Examples:

FntObject.output('myfont', 'folder')
FntObject.output('myfont_<SIZE>_', 'folder2')

Combined examples

import fntgen as f
FntObject = f.FntGen('example_fonts/bdf/unifont-9.0.06.bdf')
FntObject.setCharset('cp1252').setDecoration('shadow').output('FONT', 'uni_cp1252')
FntObject.setCharset('gb2312').setDecoration('glow').output('DBCS_<SIZE>_', 'uni_gb2312')

(More combined examples: example.py)

Other tools

License

  • Python code is written by me (Tom CHEN) and is released under the MIT License.
  • otf2bdf: see its page.
  • FNT font file editors: fair use.
  • Example .bdf fonts:

About

Might and Magic 6 7 8 and Heroes 3 FNT (font) File Generator for Multiple Languages (Python Script) 🔤👾

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published