
    7j                        d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
mZmZ ddlmZ  ej                  ddd	d
       ej                  ddd	d       ej                  dddd       ej                  ddd	dd       ej                  dddd       ej                  ddd	dd       ej                   d       d!                                                  Z ej                  d"d#d$%       ej                  dddd&       ej                  ddd	dd       ej                  dddd       ej                  dd'd	d(d)j%                   ej&                                       ej                  d*d+d	dd,       ej                  d-d.d	dd/       ej                   d0      d1                                                         Zy2)3z[This script automates the conversion of font files into a format QMK firmware understands.
    )BytesIO)normpath)_generate_font_glyphs_listQFFFont)generate_subsrender_headerrender_sourcevalid_formats)cliz-fz--fontTzSpecify input font file.)requiredhelpz-oz--outputzSpecify output image path.z-sz--size   zSpecify font size. Default 12.)defaultr   z-nz
--no-ascii
store_truezbDisables output of the full ASCII character set (0x20..0x7E), exporting only the glyphs specified.)arg_onlyactionr   z-uz--unicode-glyphs z+Also generate the specified unicode glyphs.z-az--no-aazDisable anti-aliasing on fonts.z3Converts an input font to something QMK understandsc                    t        |       }t        | j                  j                        | j                  _        |j	                  | j                  j                  | j                  j
                  | j                  j                   | j                  j                  | j                  j                  rdnd       |j                  t        | j                  j                               y )NFT)include_ascii_glyphsunicode_glyphsuse_aa)r   r   argsfontgenerate_imagesizeno_asciir   no_aasave_to_imageoutput)r   r   s     R/home/hanthebot/chat/keyboard/qmk_firmware/lib/python/qmk/cli/painter/make_font.pypainter_make_font_imager!      s     3<DSXX]]+CHHMsxx}}PSPXPXPaPaLasvs{s{  tK  tK  ^a  ^f  ^f  ^l  ^l  UZ  rv  xx01    z-iz--inputzSpecify input graphic file.)r   z>Specify output directory. Defaults to same directory as input.z--formatzOutput format, valid types: z, z-rz--no-rlez8Disable the use of RLE to minimise converted image size.z-wz--rawz9Writes out the QFF file as raw data instead of c/h combo.zBConverts an input font image to something QMK firmware understandsc                    t         | j                  j                     }t        | j                        }t        | j                  j                        | j                  _        |j                  | j                  j                  | j                  j                   | j                  j                         t        | j                  j                        dk(  r/| j                  j                  j                  | j                  _        t        | j                  j                        | j                  _        t               }|j                  || j                  j                   |       |j!                         }| j                  j"                  ra| j                  j                  | j                  j                  j$                   dz  }t'        |d      5 }|j)                  |       d d d        y dt+        | j                  j                   | j                  j                        i}t-        | ||d      }t/        |      }	| j                  j                  | j                  j                  j$                   dz  }
t'        |
d	      5 }t1        d
|
 d       |j)                  |	       d d d        t3        |      }| j                  j                  | j                  j                  j$                   dz  }t'        |d	      5 }t1        d
| d       |j)                  |       d d d        y # 1 sw Y   y xY w# 1 sw Y   xY w# 1 sw Y   y xY w)N)r   r   r   z.qffwbglyphspainter_convert_font_image)font_metadatacommand_namez.qff.hwzWriting z...z.qff.c)r
   r   formatr   logr   inputread_from_imager   r   lenr   parentr   save_to_qffno_rlegetvaluerawstemopenwriter   r   r   printr	   )r   r*   r   out_data	out_bytesraw_filer3   metadatasubsheader_textheader_fileheadersource_textsource_filesources                  r    r&   r&      sy    388??+F 377D chhnn-CHHN388CTCT?Tfifnfnf}f}~ 388??q ((..//sxx/CHHO yHV0(;!!#I
xx||88??(;(;'<D%AA(D! 	!SIIi 	! 49J9J5JCHHLcLcdeHixNjkD  %K((//sxx~~':':&;6$BBK	k3	 "6S)*[!"
  %K((//sxx~~':':&;6$BBK	k3	 "6S)*[!" "%	!" "" "s$   L%!L1;!L=%L.1L:=MN)__doc__ior   qmk.pathr   qmk.painter_qffr   r   qmk.painterr   r   r	   r
   milcr   argument
subcommandr!   joinkeysr&    r"   r    <module>rN      s     ? R R  dHt2LMdJ4PQdHb/OPdL4  Lp  qd&9fgdI\HijEF2 G k h q Q R N2 dI$ABdJ1qrdL4  Lp  qd&9fgdJ6RSWS\S\]o]j]o]o]qSrRs4tudJl  JD  EdGd<  GB  CTU+" V C E v h q s C+"r"   