
    }f                        d Z ddlmZmZ ddlmZ ddlmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlZd	d
gZ ej        d          Zd ZdddZddZedk    r,ddlZ ej         eej        dd                              dS dS )zCFF2 to CFF converter.    )TTFontnewTable)makeOutputFileName)TopDictIndex
buildOrderbuildDefaultstopDictOperatorsprivateDictOperators   )optimizeWidths)defaultdictNconvertCFF2ToCFFmainzfontTools.cffLibc                    d| _         t          dd          }| j        D ]}|                    |           || _        |d         }t	          |d          rt          d          t          t                    }||_        |j	        
                                D ].}||vr(|j	        |= t	          ||          rt          ||           /|j        }|j        }t          t                    }	t          t                    }
|D ]}|                    d           |j        }|
|_        |
D ]}||j	        vr||	v r|	|         |j	        |<    |j	        
                                D ].}||
vr(|j	        |= t	          ||          rt          ||           /|                                D ]0}|                                 |j                            d	           1| j        gd
 |D             z   D ]!}|D ]}|j                            d           "t-          t.                    }|d         j        }|
                                D ]I}|                    |          \  }}|dk    rd}||                             ||         d                    J|                                D ]2\  }}t7          |          \  }}||         j        }||_        ||_        3|
                                D ]k}|                    |          \  }}|dk    rd}||         j        }||         d         }||j        k    r#|j                            d||j        z
             ldS )al  Converts this object from CFF2 format to CFF format. This conversion
    is done 'in-place'. The conversion cannot be reversed.

    The CFF2 font cannot be variable. (TODO Accept those and convert to the
    default instance?)

    This assumes a decompiled CFF table. (i.e. that the object has been
    filled via :meth:`decompile` and e.g. not loaded from XML.)r   NT)isCFF2r   VarStorez5Variable CFF2 font cannot be converted to CFF format.Fendcharc                 :    g | ]}t          |j        d g           S )Subrs)getattrPrivate).0fds     S/var/www/rtfcompare/venv/lib/python3.11/site-packages/fontTools/cffLib/CFF2ToCFF.py
<listcomp>z%_convertCFF2ToCFF.<locals>.<listcomp>J   s3     ) ) )-/
GR(() ) )    returnhmtx)majorr   topDictIndexappendhasattr
ValueErrorr   r	   orderrawDictkeysdelattrFDArrayCharStringsr   r
   setCFF2r   values	decompileprogramGlobalSubrsr   listmetricsgetItemAndSelectoritemsr   defaultWidthXnominalWidthXinsert)cffotFonttopDictDataitemtopDictopOrderkeyfdArraycharStringsdefaultsr$   r   privateDictcssubrSetswidthsr0   	glyphNamefdIndex	widthListbestDefaultbestNominalprivatewidths                           r   _convertCFF2ToCFFrK      s    CItD111K  ! !4    "C!nGw
## RPQQQ)**GGM##%% & &g$w$$ &%%%oG%K122H+,,E . .


5j! 	9 	9C+---#//+3C=#C(&++-- 	. 	.C%',;,, .K---		.   "" % %


)$$$$_% ) )3:) ) )  ( (  	( 	(BJh''''	( FVn$G %%'' 6 6	!44Y??Gd??Gwwy1!45555$llnn , ,#1)#<#< ['"* + + %%'' @ @	!44Y??Gd??G'"*	"1%G)))Ja)>!>???@ @r   T)updatePostTablec                    | d         j         }t          ||            | d= t          d          x}| d<   ||_         |r d| v r| d         }|j        dk    rd|_        d S d S d S d S )NCFF2zCFF postg       @g      @)r6   rK   r   
formatType)fontrL   r6   tablerO   s        r   r   r   g   s    
v,
Cc4   V#F+++EDLEI "6T>>F|?c!!!DOOO	" ">> "!r   c                    | ddl }|j        dd         } ddl}|                    dd          }|                    ddd	
           |                    ddddd           |                    dddd           |                    d          }|                    dddd           |                    dddd           |                    |           }ddlm}  ||j	        rd n
|j
        rd!nd"#           ddl}|j        }|j                            |          s(|                    d$                    |                     |j        st%          |d%d&'          n|j        }	t'          ||j        d(          }
t+          |
           t,                              d)|	           |
                    |	           dS )*z%Convert CFF OTF font to CFF2 OTF fontNr   r   zfonttools cffLib.CFFToCFF2zUpgrade a CFF font to CFF2.)descriptioninputz	INPUT.ttfzInput OTF file with CFF table.)metavarhelpz-oz--outputz
OUTPUT.ttfz3Output instance OTF file (default: INPUT-CFF2.ttf).)rV   defaultrW   z--no-recalc-timestamprecalc_timestampstore_falsez:Don't set the output font's timestamp to the current time.)destactionrW   F)requiredz-vz	--verbose
store_truezRun more verbosely.)r\   rW   z-qz--quietzTurn verbosity off.)configLoggerDEBUGERRORINFO)levelzNo such file '{}'Tz-CFF)	overWritesuffix)recalcTimestamprecalcBBoxesz	Saving %s)sysargvargparseArgumentParseradd_argumentadd_mutually_exclusive_group
parse_args	fontToolsr_   verbosequietosrU   pathisfileerrorformatoutputr   r   rY   r   loginfosave)argsrh   rj   parserloggingGroupoptionsr_   rr   infileoutfilerQ   s              r   r   r   u   s[   |


x|OOO$$$1 %  F +K     B     I	     666FFLk,5J     i3H     %%G&&&&&&L!/Sww'-/SwwV    III]F7>>&!! 9(//77888 ~	6T&AAAA^  &'*BQVWWWDTHH   	IIgr   __main__)N)__doc__fontTools.ttLibr   r   fontTools.misc.cliToolsr   fontTools.cffLibr   r   r   r	   r
   rJ   r   collectionsr   logging__all__	getLoggerrx   rK   r   r   __name__rh   exitri    r   r   <module>r      sb     , , , , , , , , 6 6 6 6 6 6              " ! ! ! ! ! # # # # # #  v
& g*++M@ M@ M@` /3 " " " " "@ @ @ @F zJJJCHTT#(122,      r   