Command line interface

mcfonts also offers a CLI front-end.

To use it, use the python -m command.

python -m mcfonts

For help on possible options, run it with the argument --help or -h.

It contains these functions:

  • coverage

  • render

  • save

  • show

  • supported

  • test

coverage

Display the result of some Coverage report.

$ python -m mcfonts font.json coverage block
✓ Basic Latin                                      (U+0000-U+007F) [128/128, 100.00%]
✓ Latin-1 Supplement                               (U+0080-U+00FF) [128/128, 100.00%]
~ General Punctuation                              (U+2000-U+206F) [1/112, 0.89%]
$ python -m mcfonts font.json coverage character
        ▼ Basic Latin (U+0000-U+007F) ▼
       0 1 2 3 4 5 6 7 8 9 A B C D E F
U+000X ␀ ␁ ␂ ␃ ␄ ␅ ␆ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␎ ␏
U+001X ␐ ␑ ␒ ␓ ␔ ␕ ␖ ␗ ␘ ␙ ␚ ␛ ␜ ␝ ␞ ␟
U+002X   ! " \# $ % & ' ( ) * + , - . /
U+003X 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
U+004X @ A B C D E F G H I J K L M N O
U+005X P Q R S T U V W X Y Z [ \ ] ^ _
U+006X ` a b c d e f g h i j k l m n o
U+007X p q r s t u v w x y z { | } ~ ⑿

        ▼ Latin-1 Supplement (U+0080-U+00FF) ▼
       0 1 2 3 4 5 6 7 8 9 A B C D E F
U+008X ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏
U+009X ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ⒜ ⒝ ⒞ ⒟
U+00AX   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
U+00BX ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
U+00CX À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
U+00DX Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
U+00EX à á â ã ä å æ ç è é ê ë ì í î ï
U+00FX ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

        ▼ General Punctuation (U+2000-U+206F) ▼
       0 1 2 3 4 5 6 7 8 9 A B C D E F
U+200X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ‌ ▯ ▯ ▯
U+201X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯
U+202X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯
U+203X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯
U+204X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯
U+205X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯
U+206X ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯ ▯
$ python -m mcfonts font.json coverage character --unknown-character X
        ▼ Basic Latin (U+0000-U+007F) ▼
       0 1 2 3 4 5 6 7 8 9 A B C D E F
U+000X ␀ ␁ ␂ ␃ ␄ ␅ ␆ ␇ ␈ ␉ ␊ ␋ ␌ ␍ ␎ ␏
U+001X ␐ ␑ ␒ ␓ ␔ ␕ ␖ ␗ ␘ ␙ ␚ ␛ ␜ ␝ ␞ ␟
U+002X   ! " # $ % & ' ( ) * + , - . /
U+003X 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
U+004X @ A B C D E F G H I J K L M N O
U+005X P Q R S T U V W X Y Z [ \ ] ^ _
U+006X ` a b c d e f g h i j k l m n o
U+007X p q r s t u v w x y z { | } ~ ⑿

        ▼ Latin-1 Supplement (U+0080-U+00FF) ▼
       0 1 2 3 4 5 6 7 8 9 A B C D E F
U+008X ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ ⒊ ⒋ ⒌ ⒍ ⒎ ⒏
U+009X ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ⒜ ⒝ ⒞ ⒟
U+00AX   ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯
U+00BX ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
U+00CX À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
U+00DX Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
U+00EX à á â ã ä å æ ç è é ê ë ì í î ï
U+00FX ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ

        ▼ General Punctuation (U+2000-U+206F) ▼
       0 1 2 3 4 5 6 7 8 9 A B C D E F
U+200X X X X X X X X X X X X X ‌ X X X
U+201X X X X X X X X X X X X X X X X X
U+202X X X X X X X X X X X X X X X X X
U+203X X X X X X X X X X X X X X X X X
U+204X X X X X X X X X X X X X X X X X
U+205X X X X X X X X X X X X X X X X X
U+206X X X X X X X X X X X X X X X X
$ python -m mcfonts font.json coverage comparison --path2 font2.json
Comparing MinecraftFont(3 providers => 352 characters) and MinecraftFont(2 providers => 100 characters)
A | B (delta)
characters 3 | 3 (0)
blocks 3 | 3 (0)
        Basic Latin             127/127 | 127/127 (0)
        Latin-1 Supplement      128/255 | 128/255 (0)
        General Punctuation     1/8,303 | 1/8,303 (0)

show

Display the glyphs of characters in font.

$ python -m mcfonts test.json show ⚠a
CHARACTER a:
BITMAP GLYPH: WIDTH 5, HEIGHT 5
□□□□□□□□
□□□□□□□□
□███□□□□
█□□□█□□□
█□□□█□□□
█□□██□□□
□██□█□□□
□□□□□□□□

character of U+26A0: WARNING SIGN ⚠ does not exist in font

render

Render text with font to image.

$ python -m mcfonts font.json render hello hello.png
$ python -m mcfonts font.json render hello hello.png --kerning 2
$ python -m mcfonts font.json render hello hello.png --scale 4
$ python -m mcfonts font.json render hello hello.png --kerning 3 --scale 4

save

Save font to format. Formats are currently hard-coded and third-party libraries cannot extend the CLI if they add their own save formats.

$ python -m mcfonts font.json save minecraft default.json
$ python -m mcfonts font.json save opentype font.otf
$ python -m mcfonts font.json save yaff font.yaff
$ python -m mcfonts font.json save unihex font.hex

supported

Test if characters are present ("supported") in font.

$ python -m mcfonts font.json supported
Font supports:
    a b c
$ python -m mcfonts font.json supported 4⚠
Font supports:
    4
Unsupported:
    ⚠
$ python -m mcfonts font.json supported ab⚠ --show-providers
BitmapProvider(94 characters, height 8, ascent 7, file minecraft:font/ascii.png) supports:
        a b
Unsupported:
        ⚠

test

Load font and do nothing if successful. If failed, exit code is 1.

$ python -m mcfonts font.json test
success
$ python -m mcfonts bad.json test
failure
$ echo $?
1