Пример #1
0
def make_alphabet_dict_old():
    d = {}
    for i, letter in enumerate(alphabet):
        filename='images/hebrew_%s.png' % i
        if not os.path.exists(filename):
            import make_font_png
            make_font_png.render_title(letter,size=20, filename = filename)
        d[i] = dict(letter=letter, image=Image.open(filename))
        d[i]['width'] = d[i]['image'].size[0]
    return d
Пример #2
0
def write_hebrew_alphabet():
    """ writes a py file with uuencode64-ed png files
    """
    import make_font_png
    output_file = 'generated_hebrew_alphabet.py'
    fd = open(output_file, 'w+')
    fd.write('images = [\n')
    for i, letter in enumerate(alphabet):
        filename='hebrew_%s.png' % i
        make_font_png.render_title(letter, size=20, filename=filename)
        img = Image.open(filename)
        s = binascii.b2a_base64(img.tostring('raw'))
        os.unlink(filename)
        fd.write('(%s, r"%s"),\n' % (repr(img.size), s.strip()))
    fd.write(']\n')
    fd.close()