
    h:                      ^   S SK Jr  S SKr S SKJrJrJr  S SKJrJ	r	  S SK
Jr  S SKr S SKJr  S SKJr  S SKrS SKr\R&                  " S5      r\" \R&                  " \S	-   5      \R,                  S
9r " S S\5      r/ SQr\" S5      SS j5       r\S:X  a  \R8                  " \" 5       5        gg)    )ttLibN)computeMegaGlyphOrdercomputeMegaCmaprenameCFFCharStrings)layoutPreMergelayoutPostMerge)Options)Timer)reducezfontTools.mergez.timer)loggerlevelc                   @    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
rg)Merger   aN  Font merger.

This class merges multiple files into a single OpenType font, taking into
account complexities such as OpenType layout (``GSUB``/``GPOS``) tables and
cross-font metrics (for example ``hhea.ascent`` is set to the maximum value
across all the fonts).

If multiple glyphs map to the same Unicode value, and the glyphs are considered
sufficiently different (that is, they differ in any of paths, widths, or
height), then subsequent glyphs are renamed and a lookup in the ``locl``
feature will be created to disambiguate them. For example, if the arguments
are an Arabic font and a Latin font and both contain a set of parentheses,
the Latin glyphs will be renamed to ``parenleft.1`` and ``parenright.1``,
and a lookup will be inserted into the to ``locl`` feature (creating it if
necessary) under the ``latn`` script to substitute ``parenleft`` with
``parenleft.1`` etc.

Restrictions:

- All fonts must have the same units per em.
- If duplicate glyph disambiguation takes place as described above then the
  fonts must have a ``GSUB`` table.

Attributes:
        options: Currently unused.
Nc                 2    U(       d
  [        5       nXl        g N)r	   options)selfr   s     J/var/www/html/env/lib/python3.13/site-packages/fontTools/merge/__init__.py__init__Merger.__init__5   s    iG    c                     U Vs/ s H  n[         R                  " U5      PM     nn[        X15       H$  u  pBX$l        US   R	                  S5      Ul        M&     U$ s  snf )Nname   )r   TTFontzip_merger__fontfilegetDebugName_merger__name)r   	fontfilesfontfilefontsfonts        r   
_openFontsMerger._openFonts;   sZ    8AB	Hh'	B!%3ND%-"!%f!:!:1!=D 4 	 Cs    Ac           	         U R                  U5      nU Vs/ s H  n[        UR                  5       5      PM     nn[        X5        US   R                  nU R                  U5      n[        X$5       H-  u  p6UR                  U5        SU;   d  M  [        XUS   5        M/     U Vs/ s H  o3S   PM	     nnU Vs/ s H  n0 PM     snU l        [        X5        [        R                  " US9n	U	R                  U R                  5        U H  nU R                  U5        M     X l        [        [         R"                  S U 5       [!        5       5      n
U
R%                  S5        ['        U
5       H  nXR(                  R*                  ;   a  M  [-        SU-  5         U Vs/ s H  o3R/                  U[0        5      PM     nn[2        R5                  SU5        [        R6                  " U5      nU" U5      R9                  X5      nU[0        La   US	La  XU'   [2        R5                  S
U5        O[2        R5                  SU5        SSS5        M     U ?U ?U R;                  U	5        U	$ s  snf s  snf s  snf s  snf ! , (       d  f       GM  = f)zMerges fonts together.

Args:
        fontfiles: A list of file names to be merged

Returns:
        A :class:`fontTools.ttLib.TTFont` object. Call the ``save`` method on
        this to write it out to an OTF file.
r   zCFF cmap)sfntVersionc              3   T   #    U  H  n[        UR                  5       5      v   M      g 7fr   )listkeys).0r$   s     r   	<genexpr>Merger.merge.<locals>.<genexpr>i   s     $I54T$))+%6%65s   &(
GlyphOrderz
merge '%s'zMerging '%s'.FzMerged '%s'.zDropped '%s'.N)r%   r+   getGlyphOrderr   r)   r   setGlyphOrderr   duplicateGlyphsPerFontr   r   r   
glyphOrder	_preMerger#   r   setunionremovesortedr   drop_tablestimergetNotImplementedloginfogetTableClassmerge
_postMerge)r   r!   r#   r$   glyphOrdersr)   r4   cmaps_megaallTagstagtablesclazztables                  r   rA   Merger.mergeB   s!    	*>CDedtD..01eDd0 Ah** 	* #E 7Dz*~$TtF|D !8
 +00%$f%038&95ar5&9#$||44??+DNN4   
$I5$I35Q|$'?Cll...|c)*DIJED((37EJ#.++C0c
((6 .53E %IHH^S1HH_c2 +*	 #$ 'Jg E 1&9& K +*s0   #I%&I*:I/I9I4>BI94I99
J		c           	        ^ [         R                  " [        5       /S U 5       Q76 nU HT  m[        R                  ST5         UT   nU[        L a  M*  U" U4S jU 5       5      nU[        Ld  MG  [        UTU5        MV     U$ ! [         a>     US   n NM! [         a(    [        ST< SUR                  R                  < 35      ef = ff = f)Nc              3   h   #    U  H(  o[         Ld  M  [        U5      R                  5       v   M*     g 7fr   )r=   varsr,   )r-   rK   s     r   r.   &Merger.mergeObjects.<locals>.<genexpr>   s(     TfU^8S d5k  fs   2 2z %s*zDon't know how to merge key z
 of class c              3   F   >#    U  H  n[        UT[        5      v   M     g 7fr   )getattrr=   )r-   rK   keys     r   r.   rP      s     WPVuwuc>BBPVs   !)
r6   r7   r>   r?   KeyError	Exception	__class____name__r=   setattr)r   returnTablelogicrI   allKeys
mergeLogicvaluerT   s          @r   mergeObjectsMerger.mergeObjects   s     ))E
TfT
 CHHUC 	"3Z
 ^+WPVWWEN*S%0! $   !&sJ # 5 5 > >@ s   B
CB2CCc                     [        U5        g r   )r   r   r$   s     r   r5   Merger._preMerge   s
    tr   c                 P    [        U5        SU;   a  US   R                  U5        g g )NzOS/2)r   recalcAvgCharWidthrb   s     r   rB   Merger._postMerge   s*    T> L++D1 r   )r3   r#   r   r   )rX   
__module____qualname____firstlineno____doc__r   r%   rA   r_   r5   rB   __static_attributes__ r   r   r   r      s'    6AF82r   r   )r	   r   mainz%make one with everything (TOTAL TIME)c                    SSK Jn  U c  [        R                  SS n [	        5       nUR                  U 5      n / nUR                  (       ar  [        UR                  5       nUR                  5        Vs/ s H9  nUR                  5       R                  S5      (       a  M)  UR                  5       PM;     nnSSS5        U  H  nUR                  U5        M     [        U5      S:  a  [        S[        R                  S9  [        S[        R                  S9  [        S	[        R                  S9  [        S
[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  [        S[        R                  S9  gU" UR                   (       a  ["        R$                  O["        R&                  S9  UR(                  (       a.  [*        R,                  R/                  ["        R0                  5        OS[*        R,                  l        [5        US9nUR7                  U5      nUR8                  (       a  UR;                  UR8                  5        [+        S5         UR=                  UR>                  5        SSS5        gs  snf ! , (       d  f       GN-= f! , (       d  f       g= f)zMerge multiple fonts into oner   )configLoggerN   #ztusage: pyftmerge [font1 ... fontN] [--input-file=filelist.txt] [--output-file=merged.ttf] [--import-file=tables.ttx])filezN                                   [--drop-tables=tags] [--verbose] [--timing] z- font1 ... fontN              Files to merge.zp --input-file=<filename>      Read files to merge from a text file, each path new line. # Comment lines allowed.zM --output-file=<filename>     Specify output file name (default: merged.ttf).za --import-file=<filename>     TTX file to import after merging. This can be used to set metadata.zY --drop-tables=<table tags>   Comma separated list of table tags to skip, case sensitive.z: --verbose                    Output progress information.z5 --timing                     Output progress timing.)r   T)r   zcompile and save font) 	fontToolsro   sysargvr	   
parse_opts
input_fileopen	readlineslstrip
startswithstripappendlenprintstderrverboseloggingINFOWARNINGtimingr;   r   setLevelDEBUGdisabledr   rA   import_file	importXMLsaveoutput_file)	argsro   r   r!   	inputfilelinegmergerr$   s	            r   rm   rm      s2    '|xx|iGd#DI'$$% &//11D{{}//4 

1   &   9~ C	
 	\	
 	bszz"=CJJO~	
 	[	
 	o	
 	g	
 	H	
 	ECJJWww||GOOL~~gmm, $G$F<<	"Dw**+	&	'		'%%& 
(	'm &%n 
(	's0    K3(KK3K1K-K
K*-
K;__main__r   )rt   r   fontTools.merge.basefontTools.merge.cmapr   r   r   fontTools.merge.layoutr   r   fontTools.merge.optionsr	   fontTools.merge.tablesfontTools.misc.loggingToolsr
   	functoolsr   ru   r   	getLoggerr>   rX   r   r;   objectr   __all__rm   exitrl   r   r   <module>r      s   
   
 C +  -  
  )*W&&x(':;7<<PQ2V Q2h ( ./C' 0C'L zHHTV r   