
    h                        S SK r S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
r
SSKJrJr  Sr S SKr\R&                  " S5      rS rS rSS	 jrS
 rS rSS jrg! \ a     S SKr N6! \ a  r SrC NBSrCff = ff = f)    N)closing)partial   )font_to_quadraticfonts_to_quadraticzfontTools.cu2quc                  N     [         R                  " 5       $ ! [         a     gf = f)Nr   )mp	cpu_countNotImplementedError     E/var/www/html/env/lib/python3.13/site-packages/fontTools/cu2qu/cli.py
_cpu_countr      s%    ||~ s    
$$c                     [        [        R                  S5      (       a  [        R                  R                  U 5      $ [        R                  " U 5      $ )Nopen)hasattr
ufo_moduleFontr   )paths    r   open_ufor       s7    z''##D))??4  r   c                    [        U 5      n[        R                  SU 5        [        U40 UD6(       a@  [        R                  SU5        U(       a  UR	                  U5        g UR	                  5         g U(       a  [        X5        g g )NzConverting curves for %s	Saving %s)r   loggerinfor   save	_copytree)
input_pathoutput_pathkwargsufos       r   _font_to_quadraticr!   &   s^    
:
C
KK*J7''K-HH[!HHJ	** 
r   c                 n   [         R                  R                  [         R                  R                  [         R                  R	                  U 5      5      5      n [         R                  R                  [         R                  R                  [         R                  R	                  U5      5      5      nX:H  $ N)osr   normcaseabspathrealpath)path1path2s     r   	_samepathr*   3   sj    GGRWW__RWW-=-=e-DEFEGGRWW__RWW-=-=e-DEFE>r   c                     [        X5      (       a  [        R                  S5        g [        R                  R                  U5      (       a  [        R                  " U5        [        R                  " X5        g )Nz6input and output paths are the same file; skipped copy)	r*   r   debugr$   r   existsshutilrmtreecopytree)r   r   s     r   r   r   :   sH    ))MN	ww~~k""k"
OOJ,r   c                 	   [         R                  " SS9nUR                  SS[        R                  S9  UR                  SSSS	S
9  UR                  SSSSS9  UR                  SS[
        SSSS9  UR                  SSSSSS9  UR                  SSSSS 9  UR                  5       nUR                  S!S"SS#S$9  UR                  S%S&[        S'S([        5       S)S*S+9  UR                  5       nUR                  S,S-SS.S/S09  UR                  S1S2SS3S4S09  UR                  U 5      n[        c  UR                  S55        UR                  (       d  S6nOUR                  S(:X  a  S7nOS8n[        R                  " US99  [        UR                   5      S(:  a"  UR"                  (       a  UR                  S:5        UR$                  (       a  UR$                  n[&        R(                  R+                  U5      (       d  [&        R,                  " U5        O8[&        R(                  R/                  U5      (       d  UR                  S;U-  5        UR                    Vs/ s H@  n[&        R(                  R1                  U[&        R(                  R3                  U5      5      PMB     nnO8UR"                  (       a  UR"                  /nOS/[        UR                   5      -  n[5        UR                  S:  UR6                  UR8                  UR:                  (       a  SOS<S=9n	UR<                  (       a  [>        RA                  S>5        UR                    V
s/ s H  n
[C        U
5      PM     nn
[E        U40 U	D6(       aU  [G        X5       HE  u  p[>        RA                  S?U5        U(       a  URI                  U5        M5  URI                  5         MG     g[G        UR                   U5       H  u  pU(       d  M  [K        X5        M     gURL                  S(:  a)  [O        [        UR                   5      URL                  5      OS(nUS(:  au  [Q        [R        40 U	D6n[>        RA                  S@U5        [U        [V        RX                  " U5      5       nUR[                  U[G        UR                   U5      5        SSS5        g[G        UR                   U5       H  u  p[S        X40 U	D6  M     gs  snf s  sn
f ! , (       d  f       g= f)Az1Convert a UFO font from cubic to quadratic curvescu2qu)progz	--versionversion)actionr4   infiles+INPUTz%one or more input UFO source file(s).)nargsmetavarhelpz-vz	--verbosecountr   )r5   defaultz-ez--conversion-errorERRORNz<maxiumum approximation error measured in EM (default: 0.001))typer:   r=   r;   z-mz--mixedF
store_truez0whether to used mixed quadratic and cubic curves)r=   r5   r;   z--keep-directionreverse_directionstore_falsez$do not reverse the contour direction)destr5   r;   z-iz--interpolatablez@whether curve conversion should keep interpolation compatibility)r5   r;   z-jz--jobs?r   Nz9Convert using N multiple processes (default: %(default)s))r?   r9   r=   constr:   r;   z-oz--output-fileOUTPUTzsoutput filename for the converted UFO. By default fonts are modified in place. This only works with a single input.)r=   r:   r;   z-dz--output-dir	DIRECTORYz-output directory where to save converted UFOsz9Either ufoLib2 or defcon are required to run this script.WARNINGINFODEBUG)levelz2-o/--output-file can't be used with multile inputsz'%s' is not a directoryT)
dump_stats
max_err_emrA   all_quadraticzConverting curves compatiblyr   zRunning %d parallel processes).argparseArgumentParseradd_argument	fontTools__version__floatadd_mutually_exclusive_groupintr   
parse_argsr   errorverboseloggingbasicConfiglenr6   output_file
output_dirr$   r   r-   mkdirisdirjoinbasenamedictconversion_errorrA   mixedinterpolatabler   r   r   r   zipr   r   jobsminr   r!   r   r	   Poolstarmap)argsparsermode_parseroutput_parseroptionsrL   r_   poutput_pathsr   infileufosr    r   r   ri   funcpools                     r   _mainrx   C   s^   $$'2F
Iy?T?TU
4	   k'1E
K   ?    3	   557KO	   lH  	 779MF  	 <   %GPQ??	A	e$
7??aG$7$7IJ''
ww~~j))HHZ z**LL2Z?@CJ??
CRaBGGLLRWW%5%5a%89? 	 
 
		++, vGOO 44??Q&++!33&}}e$	F 23/6?V ?d-f-$'$; K5HH[)HHJ %< ,/w+M'
;j6 ,N ;B,,:Js3w'6PQ!8-88DKK7>'4T3w#EF (' ,/w+M'
":EfE ,NM
$ @" ('s   ASS;'S!!
S/r#   )r$   rP   r[   r.   multiprocessingr	   
contextlibr   	functoolsr   rS   r    r   r   r   ufoLib2ImportErrordefcone	getLoggerr   r   r   r!   r*   r   rx   r   r   r   <module>r      s    	        6
  
		,	-!
+-CFi  # s)   A A?$A**A;0A?6A;;A?