acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

built_in_font_gen.py (2465B)

      1 #!/usr/bin/env python3
      2 
      3 import argparse
      4 from argparse import RawTextHelpFormatter
      5 import os
      6 import sys
      7 
      8 parser = argparse.ArgumentParser(description="""Create fonts for LVGL including the built-in symbols. lv_font_conv needs to be installed. See https://github.com/lvgl/lv_font_conv
      9 Example: python built_in_font_gen.py --size 16 -o lv_font_roboto_16.c --bpp 4 -r 0x20-0x7F""", formatter_class=RawTextHelpFormatter)
     10 parser.add_argument('-s', '--size',
     11 					type=int,
     12 					metavar = 'px',
     13 					nargs='?',
     14 					help='Size of the font in px')
     15 parser.add_argument('--bpp',
     16 					type=int,
     17 					metavar = '1,2,4',
     18 					nargs='?',
     19 					help='Bit per pixel')
     20 parser.add_argument('-r', '--range',
     21 					nargs='+',
     22 					metavar = 'start-end',
     23 					default=['0x20-0x7F,0xB0,0x2022'],
     24 					help='Ranges and/or characters to include. Default is 0x20-7F (ASCII). E.g. -r 0x20-0x7F, 0x200, 324')
     25 parser.add_argument('--symbols',
     26 					nargs='+',
     27 					metavar = 'sym',
     28 					default=[''],
     29 					help=u'Symbols to include. E.g. -s ÁÉŐ'.encode('utf-8'))
     30 parser.add_argument('--font',
     31 					metavar = 'file',
     32 					nargs='?',
     33 					default='Montserrat-Medium.ttf',
     34 					help='A TTF or WOFF file')
     35 parser.add_argument('-o', '--output',
     36 					nargs='?',
     37 					metavar='file',
     38 					help='Output file name. E.g. my_font_20.c')
     39 parser.add_argument('--compressed', action='store_true',
     40 					help='Compress the bitmaps')
     41 parser.add_argument('--subpx', action='store_true',
     42 					help='3 times wider letters for sub pixel rendering')
     43 
     44 args = parser.parse_args()
     45 
     46 if args.compressed == False:
     47 	compr = "--no-compress --no-prefilter"
     48 else:
     49 	compr = ""
     50 
     51 if len(args.symbols[0]) != 0:
     52 	args.symbols[0] = "--symbols " +  args.symbols[0]
     53 
     54 subpx = ""
     55 if args.subpx: subpx = "--lcd"
     56 
     57 #Built in symbols
     58 syms = "61441,61448,61451,61452,61452,61453,61457,61459,61461,61465,61468,61473,61478,61479,61480,61502,61507,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61550,61552,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61641,61664,61671,61674,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62087,62099,62212,62189,62810,63426,63650"
     59 
     60 #Run the command (Add degree and bullet symbol)
     61 cmd = "lv_font_conv {} {} --bpp {} --size {} --font {} -r {} {} --font FontAwesome5-Solid+Brands+Regular.woff -r {} --format lvgl -o {} --force-fast-kern-format".format(subpx, compr, args.bpp, args.size, args.font, args.range[0], args.symbols[0], syms, args.output)
     62 os.system(cmd)