SuperHouse / esp-open-rtos

Open source FreeRTOS-based ESP8266 software framework
BSD 3-Clause "New" or "Revised" License
1.52k stars 491 forks source link

Create custom fonts #754

Closed colesnicov closed 4 years ago

colesnicov commented 4 years ago

Hello. I trying to create custom font by command:

$ ./create_font.py -f ../../../res/fonts/ObelusCompact.ttf -n obelux_complact -c utf-8 And i get this error message..

Traceback (most recent call last):
  File "./create_font.py", line 89, in <module>
    main(parser.parse_args(sys.argv[1:]))
  File "./create_font.py", line 47, in main
    fnt = ImageFont.load(args.font)
  File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 230, in load
    f._load_pilfont(filename)
  File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 81, in _load_pilfont
    raise IOError("cannot find glyph data file")
OSError: cannot find glyph data file
colesnicov commented 4 years ago

Now works.

Replace this:

def main(args):
    fnt = ImageFont.load(args.font)

to:

def main(args):
    if args.truetype == 0: 
        fnt = ImageFont.load(args.font)
    else:
    # use a truetype font
        fnt = ImageFont.truetype(args.font, args.size)

And add this:

 parser.add_argument('-s', '--size', type=int, help='Height for glyphs (default=8)', default=8)
    parser.add_argument('-ttf', '--truetype', type=int, required=True, help='TrueType font (0=no|1=yes)')

to: if __name__ == "__main__":

Also you can modify template.c and add this line:

#include <stdint.h> ..

Regards..

colesnicov commented 4 years ago

6c993f9