B ] @sDddlmZddlZddlmZmZdZddZGdd d eZ dS) )print_functionN)Image_binaryi cCs2x,|D]$}|dkr|d7}|t|qWdS)Nri)writerZo16be)fpvaluesvr ./tmp/pip-build-ktz6qwqq/Pillow/PIL/FontFile.pyputi16s r c@s0eZdZdZddZddZddZdd ZdS) FontFileNcCsi|_dgd|_dS)N)infoglyph)selfr r r __init__*szFontFile.__init__cCs |j|S)N)r)rixr r r __getitem__/szFontFile.__getitem__cCs|jr dSd}}}d}xp|D]h}|r |\}}}} t||d|d}||d|d}|tkr~|d7}|d|d}t||}q W|} ||} | dkr| dkrdS||_td| | f|_dgd|_d} } xtdD]}||}|r|\}}}} |d|d}| | }}| |} | tkrFd| |} } | | }}|} |d||d||d||d|f}|j| |||||f|j|<qWdS) zCreate metrics and bitmapNrr1r) bitmapmaxWIDTHysizernewmetricsrangeZpasteZcrop)rhwZmaxwidthlinesrddstsrcZimZxsizerxyiZxxZx0Zy0sr r r compile2sF        ,zFontFile.compilec Cs||jtj|dddttj|ddd}|d|d|j d|d xNt d D]B}|j |}|st |dgd qvt ||d|d |d qvWWdQRXdS)z Save fontrz.pbmZPNGz.pilwbsPILfont z ;;;;;;%d; asciisDATA r rrN) r*rsaveospathsplitextopenrrencoderrr )rfilenameridmr r r r.as   z FontFile.save)__name__ __module__ __qualname__rrrr*r.r r r r r &s /r ) __future__rr/rrrrr objectr r r r r s