
    Ph]W                       d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZmZmZ ddlmZmZ dd	lmZ dd
lmZmZmZmZ ddlmZmZ ddlm Z  ddl!m"Z" ddl#m$Z$ ddl#m%Z% ddl&Z&ddl'Z'ddl(Z(ddl)Z)ddl*Z*ddl+Z+ddlm,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8  e)jr                  e:      Z;djy                   ejz                  d      dd       ZdZ> G d de$jH                        Z? edd      Z@dZAdZBdZCd ZDd!ZEd"ZFd#ZGd$ZHd%ZIeBeHz   eIz   ZJddeFdeCeFz  deCd&eGdeDeGz  deDd&iZKd' ZLd( ZMd) ZNd* ZOd+ ZPdZQdZRd ZSd!ZTd"ZUd#ZVd$ZWd%ZXd,ZYd-ZZd.Z[d/Z\d0Z] ed1g d2      Z^ G d3 d4e_      Z` e4e j                  e5      Zbd6ecd7ecd8ecd9edfd:Zed;e`d9e8ef   fd<Zg G d= d>e_      Zh G d? d@e_      Zie:dAk(  r4ddljZjddl&Z& e&j                   ejj                         j                         yy)Bz6_g_l_y_f.py -- Converter classes for the 'glyf' table.    )
namedtuple)sstruct)ttLib)version)DecomposedTransform)tostrsafeEvalpad)updateBoundspointInRect)calcQuadraticBounds)fixedToFloatfloatToFixedfloatToFixedToStrstrToFixedToFloat)noRoundotRound)Vector)Number   )DefaultTable)	ttProgramN)	xmlWriter)userNameToFileName)deprecateFunction)IntFlag)partial)SimpleNamespace)Set.   c                      e Zd ZdZdgZdZd Zd"dZd Zd"dZ	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZeZd#dZd Zd Zd Zd Zd#dZ	 d#eddZd#dZd Z ede      d#d       Z ede      d#d       Z  ed e      d!        Z!y)$table__g_l_y_fa  Glyph Data table

    This class represents the `glyf <https://docs.microsoft.com/en-us/typography/opentype/spec/glyf>`_
    table, which contains outlines for glyphs in TrueType format. In many cases,
    it is easier to access and manipulate glyph outlines through the ``GlyphSet``
    object returned from :py:meth:`fontTools.ttLib.ttFont.getGlyphSet`::

                    >> from fontTools.pens.boundsPen import BoundsPen
                    >> glyphset = font.getGlyphSet()
                    >> bp = BoundsPen(glyphset)
                    >> glyphset["A"].draw(bp)
                    >> bp.bounds
                    (19, 0, 633, 716)

    However, this class can be used for low-level access to the ``glyf`` table data.
    Objects of this class support dictionary-like access, mapping glyph names to
    :py:class:`Glyph` objects::

                    >> glyf = font["glyf"]
                    >> len(glyf["Aacute"].components)
                    2

    Note that when adding glyphs to the font via low-level access to the ``glyf``
    table, the new glyphs must also be added to the ``hmtx``/``vmtx`` table::

                    >> font["glyf"]["divisionslash"] = Glyph()
                    >> font["hmtx"]["divisionslash"] = (640, 0)

    fvarr   c                    d|v r'|d   j                   D cg c]  }|j                   c}ng | _        |d   }t        |d         }d}d}i | _        |j                         x| _        }i | _        t        dt        |      dz
        D ]`  }		 ||	   }
t        ||	dz            }||| }t        |      ||z
  k7  rt        j                  d      t        |      }|| j                  |
<   |}b t        |      |z
  dk\  r t        j                  d|t        |             |rt        j                  d	|       |j                   d
u r| j#                          y y c c}w # t        $ r |dz   }d|	z  }
Y w xY w)Nr$   locar   r   zttxautoglyph%sznot enough 'glyf' table data   z:too much 'glyf' table data: expected %d, received %d bytesz%s glyphs have no nameF)axesaxisTagaxisTagsintglyphsgetGlyphOrder
glyphOrder_reverseGlyphOrderrangelen
IndexErrorr   
TTLibErrorGlyphlogwarninglazyensureDecompiled)selfdatattFontaxisr&   posnextPosnonamer.   i	glyphName	glyphdataglyphs                jC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\fontTools/ttLib/tables/_g_l_y_f.py	decompileztable__g_l_y_f.decompile_   s   >D>NfVn&9&9:&9dT\\&9:TV 	 f~$q'l'-';';'==*"$q#d)a-(A1&qM	 $q1u+&GS)I9~'C-0&&'EFF)$E%*DKK	"C ) t9w!#KKLD	
 KK0&9;;%!!#  = ;  1!,q0	1s   EEE.-E.c                 d    | j                   j                         D ]  }|j                  |         y N)r,   valuesexpand)r9   recurserC   s      rD   r8   ztable__g_l_y_f.ensureDecompiled   s'     [['')ELL *    c                 2   |j                   t        j                     }d|v r'|d   j                  D cg c]  }|j                   c}ng | _        t        | d      s|j                         | _        | j                  }|dv sJ g }d}g }|j                  }t               }	| j                  D ]i  }
| j                  |
   }|j                  | ||	|       }|dkD  rt        ||      }|j                  |       |t!        |      z   }|j                  |       k |j                  |       |dk(  r|dk  rt#        |      D cg c]  \  }}t!        |      d	z  dk(  s| }}}|r[|t!        |      z   dk  rJ|D ]  }||xx   d
z  cc<    d}t#        |      D ]  \  }}|||<   |t!        |      z  } ||t!        |      <   dj%                  |      }d|v r|d   j                  |       d|v rt!        | j                        |d   _        |sd
}|S c c}w c c}}w )Nr$   r.   )r   r   r!   r'   r   
boundsDoneoptimizeSizer   )sizei   r!       rK   r&   maxp)cfgr   OPTIMIZE_FONT_SPEEDr(   r)   r*   hasattrr-   r.   paddingrecalcBBoxessetr,   compiler
   appendr1   	enumeratejoin	numGlyphs)r9   r;   optimizeSpeedr<   rV   	locationscurrentLocationdataListrW   rN   rA   rC   	glyphDatar@   indicesr:   s                   rD   rY   ztable__g_l_y_f.compile   s=   

5#<#<= ?E>NfVn&9&9:&9dT\\&9:TV 	 t\*$224DO,,,&&&	**U
IKK	*E%!..	 & I {	8	_--I>OOOI& ) 	)a<Og5 '0&9&9laS^a=OST=T&9   ?S\9GC AQK5(K !"#$-h$7LAy#2IaL#s9~5O %8 ,;	#h-(xx!V6Ny)V'*4;;'7F6N$
 Dk ;:s   H HHc           
      "   d}|j                         }|sA|j                          |j                  |       |j                          |j                          t        |      }|r@t        j
                  j                  |j                  j                        \  }}t               }	|D ]g  }
| j                  |
      }|t        j                  d|
       .|j                  r|rt        t        |
d      	dz         }|	j!                  |j#                                t%        j&                  ||j(                  |j*                        }|j-                  dt.               |j                          |j-                  d	       |j                          |j                  |       |j                          |j1                  d
t        j
                  j3                  |             n|}|j-                  d
d|
fd|j4                  fd|j6                  fd|j8                  fd|j:                  fg       |j                          |j=                  ||       |j?                  d
       |j                          |r|j?                  d	       |j                          |j?                  d       |j                          |jA                          n6|j1                  d
|
       |j                  d       |s|j                          |j                          j y )NzJThe xMin, yMin, xMax and yMax values
will be recalculated by the compiler.z'glyph '%s' does not exist in glyf tablezutf-8r    )prefixsuffix)idlefunc
newlinestrr;   )ttLibVersionglyfTTGlyph)srcnamexMinyMinxMaxyMax)rm   zcontains no outline data)!getGlyphNamesnewlinecommentr1   ospathsplitextfilerm   rX   getr5   r6   numberOfContoursr   r   addlowerr   	XMLWriterrg   rh   begintagr   	simpletagbasenamern   ro   rp   rq   toXMLendtagclose)r9   writerr;   splitGlyphsnotice
glyphNamesr]   rv   extexistingGlyphFilesrA   rC   	glyphPathglyphWriters                 rD   r   ztable__g_l_y_f.toXML   s   4 	 ))+
NNNN6"NNNN
O	(()9)9:ID#!$#IHHY'E}EyQ%% 2i1*#cz"	!I '**9??+<="+"5"5!!'#)#4#4#K
  (((H'')((0'')''/'')$$YBGG4D4DY4O$P"(K$$+,,,,	 ##%K0""9-##%&&v.'')&&x0'')%%'   ;9:"NN$NNk $rK   c                    |dk7  ry t        | d      si | _        t        | d      s|j                         | _        |d   }t        j                  d|       t               }dD ](  }t        ||t        |j                  |d                   * || j                  |<   |D ]-  }t        |t              s|\  }}}|j                  ||||       / |j                  s|j                  | d       y y )	Nrk   r,   r.   rm   zunpacking glyph '%s')rn   ro   rp   rq   0r   )rU   r,   r-   r.   r5   debugr4   setattrr	   ry   
isinstancetuplefromXMLrW   compact)	r9   rm   attrscontentr;   rA   rC   attrelements	            rD   r   ztable__g_l_y_f.fromXML	  s    9tX&DKt\*$224DO&M			()44DE4%))D#*>!?@ 5!&IGgu-#* D%MM$w7	 
 ""MM$" #rK   c                      || _         i | _        y)znSets the glyph order

        Args:
                glyphOrder ([str]): List of glyph names in order.
        N)r.   r/   )r9   r.   s     rD   setGlyphOrderztable__g_l_y_f.setGlyphOrder  s     %"$rK   c                      | j                   |   S )zReturns the name for the glyph with the given ID.

        Raises a ``KeyError`` if the glyph name is not found in the font.
        )r.   )r9   glyphIDs     rD   getGlyphNameztable__g_l_y_f.getGlyphName'  s    
 w''rK   c                 Z    i x| _         }t        | j                        D ]
  \  }}|||<    y rG   )r/   r[   r.   )r9   dr   rA   s       rD   _buildReverseGlyphOrderDictz*table__g_l_y_f._buildReverseGlyphOrderDict.  s0    &((!"+DOO"<GY"AiL #=rK   c                     | j                   }t        | di       j                  |      }||t        |      k\  s||   |k7  r+| j	                          | j
                  j                  |      }|t        |      |S )zReturns the ID of the glyph with the given name.

        Raises a ``ValueError`` if the glyph is not found in the font.
        r/   )r.   getattrry   r1   r   r/   
ValueError)r9   rA   r.   ids       rD   
getGlyphIDztable__g_l_y_f.getGlyphID3  sy    
 __
T/488C:s:.*R.I2M,,.((,,Y7B:Y''	rK   c                 b    | j                   j                         D ]  }|j                           y)zmRemoves TrueType hints from all glyphs in the glyphset.

        See :py:meth:`Glyph.removeHinting`.
        N)r,   rH   removeHinting)r9   rC   s     rD   r   ztable__g_l_y_f.removeHintingA  s'    
 [['')E! *rK   c                 6    | j                   j                         S rG   )r,   keysr9   s    rD   r   ztable__g_l_y_f.keysI  s    {{!!rK   c                     || j                   v S rG   )r,   r9   rA   s     rD   has_keyztable__g_l_y_f.has_keyL  s    DKK''rK   Nc                 d    | j                   j                  ||      }||j                  |        |S rG   )r,   ry   rI   )r9   rA   defaultrC   s       rD   ry   ztable__g_l_y_f.getQ  s-    	73LLrK   c                 F    | j                   |   }|j                  |        |S rG   )r,   rI   r9   rA   rC   s      rD   __getitem__ztable__g_l_y_f.__getitem__W  s!    I&TrK   c                 v    || j                   |<   || j                  vr| j                  j                  |       y y rG   )r,   r.   rZ   r   s      rD   __setitem__ztable__g_l_y_f.__setitem__\  s3    !&IDOO+OO""9- ,rK   c                 T    | j                   |= | j                  j                  |       y rG   )r,   r.   remover   s     rD   __delitem__ztable__g_l_y_f.__delitem__a  s     KK	"y)rK   c                     t        | j                        t        | j                        k(  sJ t        | j                        S rG   )r1   r.   r,   r   s    rD   __len__ztable__g_l_y_f.__len__e  s1    4??#s4;;'77774;;rK   c                     | |   }t        |d      s|j                  |        ||   \  }}|j                  |z
  }||z   }|r||   \  }	}
|
|j                  z   }||	z
  }ndx}}|df|dfd|fd|fgS )a+  Compute the four "phantom points" for the given glyph from its bounding box
        and the horizontal and vertical advance widths and sidebearings stored in the
        ttFont's "hmtx" and "vmtx" tables.

        'hMetrics' should be ttFont['hmtx'].metrics.

        'vMetrics' should be ttFont['vmtx'].metrics if there is "vmtx" or None otherwise.
        If there is no vMetrics passed in, vertical phantom points are set to the zero coordinate.

        https://docs.microsoft.com/en-us/typography/opentype/spec/tt_instructing_glyphs#phantoms
        rn   r   )rU   recalcBoundsrn   rq   )r9   rA   hMetricsvMetricsrC   horizontalAdvanceWidthleftSideBearing	leftSideX
rightSideXverticalAdvanceWidthtopSideBearingtopSideYbottomSideYs                rD   _getPhantomPointsz table__g_l_y_f._getPhantomPointsi  s     Yuf%t$2:92E/JJ0	!77
3;I3F0 .%

2H"%99K%&&K( NOM	
 	
rK   roundc                   | j                  |      }|y|j                         rt        |j                  D cg c]  }t	        |dd      t	        |dd      f c}      }t        |j                  t        t        t        |j                                    d|j                  D cg c]  }|j                  t	        |dd      f c}      }n>|j                  |       \  }}	}
|j                         }t        |j                  |	|
d      }| j                  |||      }|j                  |       |j                  |       ||fS c c}w c c}w )a  Return glyph coordinates and controls as expected by "gvar" table.

        The coordinates includes four "phantom points" for the glyph metrics,
        as mandated by the "gvar" spec.

        The glyph controls is a namedtuple with the following attributes:
                - numberOfContours: -1 for composite glyphs.
                - endPts: list of indices of end points for each contour in simple
                glyphs, or component indices in composite glyphs (used for IUP
                optimization).
                - flags: array of contour point flags for simple glyphs (None for
                composite glyphs).
                - components: list of base glyph names (str) for each component in
                composite glyphs (None for simple glyphs).

        The "hMetrics" and vMetrics are used to compute the "phantom points" (see
        the "_getPhantomPoints" method).

        Return None if the requested glyphName is not present.
        Nxr   y	transform)rz   endPtsflags
componentsr   )ry   isCompositeGlyphCoordinatesr   r   _GlyphControlsrz   listr0   r1   rA   getCoordinatescopyr   extendtoInt)r9   rA   r   r   r   rC   ccoordscontrolsr   r   phantomPointss               rD   _getCoordinatesAndControlsz)table__g_l_y_f._getCoordinatesAndControls  sL   . #=%CHCSCSTCSa'!S!$gaa&89CSTF &!&!7!7E#e&6&6"789 #--- [['![$"?@-	H %*$8$8$>!FFE[[]F%!&!7!7	H ..y(HMm$5!x1 Us   !E% Ec                    | |   }t        |      dk\  sJ |d   d   }|d   d   }|d   d   }|d   d   }	|dd }|j                         r^t        |      t        |j                        k(  sJ t        ||j                        D ]!  \  }
}t	        |d	      s|
\  |_        |_        # nR|j                  dk(  rt        |      dk(  s5J t        |      t        |j                        k(  sJ t        |      |_        |j                  | t               
       t        ||z
        }|dk  rd}t        |j                  |z
        }||f||<   |5t        ||	z
        }|dk  rd}t        ||j                  z
        }||f||<   yy)a(  Set coordinates and metrics for the given glyph.

        "coord" is an array of GlyphCoordinates which must include the "phantom
        points" as the last four coordinates.

        Both the horizontal/vertical advances and left/top sidebearings in "hmtx"
        and "vmtx" tables (if any) are updated from four phantom points and
        the glyph's bounding boxes.

        The "hMetrics" and vMetrics are used to propagate "phantom points"
        into "hmtx" and "vmtx" tables if desired.  (see the "_getPhantomPoints"
        method).
        r'   r   r   Nr   rN   )r1   r   r   ziprU   r   r   rz   coordinatesr   r   rX   r   rn   rq   )r9   rA   coordr   r   rC   r   r   r   r   pcompr   r   r   r   s                   rD   _setCoordinatesztable__g_l_y_f._setCoordinates  s    Y 5zQ"IaL	2Yq\
9Q<Bilcr
u:U%5%5!6666ue&6&6744%%&NDFDF 8 ##q(u:?"?u:U%6%6!7777 0 7E4CE2!(i)?!@!A% &'"!%**y"894oE#*8k+A#B #a''($$X

%:;N"6"FHY  rK   c                    t        |j                  d      dd      }|h|d   j                  }t        |j                  d      dd      }|||}n|}| |   }|j                  |        t	        ||j
                  z
        }|||fi}|S )zThis method is wrong and deprecated.
        For rationale see:
        https://github.com/fonttools/fonttools/pull/2266/files#r613569473
        vmtxmetricsNheadhheaascent)r   ry   
unitsPerEmr   r   rq   )	r9   rA   r;   defaultVerticalOriginr   r   r   rC   r   s	            rD   _synthesizeVMetricsz"table__g_l_y_f._synthesizeVMetrics  s    
 6::f-y$?#)&>#<#< vzz&18TBH(44H3HOEt$$X

%:;N!$8.#IJHrK   zuse '_getPhantomPoints' instead)categoryc                 l    |d   j                   }| j                  |||      }| j                  |||      S )zkOld public name for self._getPhantomPoints().
        See: https://github.com/fonttools/fonttools/pull/2266hmtx)r   r   r   r9   rA   r;   r   r   r   s         rD   getPhantomPointsztable__g_l_y_f.getPhantomPoints  s=     &>))++Iv?TU%%i8DDrK   z(use '_getCoordinatesAndControls' insteadc                 l    |d   j                   }| j                  |||      }| j                  |||      S )ztOld public name for self._getCoordinatesAndControls().
        See: https://github.com/fonttools/fonttools/pull/2266r   )r   r   r   r   s         rD   getCoordinatesAndControlsz(table__g_l_y_f.getCoordinatesAndControls  s=     &>))++Iv?TU..y(HMMrK   zuse '_setCoordinates' insteadc                     |d   j                   }t        |j                  d      dd      }| j                  |||       y)ziOld public name for self._setCoordinates().
        See: https://github.com/fonttools/fonttools/pull/2266r   r   r   N)r   r   ry   r   )r9   rA   r;   r   r   s        rD   setCoordinatesztable__g_l_y_f.setCoordinates  s<     &>))6::f-y$?Y(;rK   FrG   )"__name__
__module____qualname____doc__dependenciesrV   rE   r8   rY   r   r   r   r   r   r   r   r   r   __contains__ry   r   r   r   r   r   r   r   r   r   r   DeprecationWarningr   r   r    rK   rD   r#   r#   8   s    < 8L G!$F9vDL#*%(#
""( L
.
*  
F -14 ;B4 l3Gn( 8CUVE WE 2=ONN 6AST< U<rK   r#   r   z(numberOfContours endPts flags componentsz\
		>	# big endian
		numberOfContours:	h
		xMin:				h
		yMin:				h
		xMax:				h
		yMax:				h
r'             @      r   c                 *   |rt         nd}d}| dk(  r
|t        z  }n0d| cxk  rdk  r n n|t        z  }| dkD  r	|t        z  }|dz  }n|dz  }|dk(  r|t        z  }||fS d|cxk  rdk  r#n n |t        z  }|dkD  r	|t        z  }|dz  }||fS |dz  }||fS )zFor a given x,y delta pair, returns the flag that packs this pair
    most efficiently, as well as the number of byte cost of such flag.r      r   r!   )flagOnCurve	flagXsame
flagXShort	flagYsame
flagYShort)r   r   onCurveflagcosts        rD   flagBestr  M  s     ";qDDAvi		c	j q5)#D		Avi : 
	c	j q5)#D	 : 		:rK   c                 n    t         | |z     }t         ||z     }||k(  xs t        |      t        |      kD  S rG   )_flagSignBytesabs)newFlagoldFlagmasknewBytesoldBytess        rD   flagFitsr  j  s;    gn-Hgn-Hx@3x=3x=#@@rK   c                     |t         z  | t         z  k(  xr2 t        | |t        t        z        xr t        | |t        t
        z        S rG   )r  r  r  r  r  r  )r  r  s     rD   flagSupportsr  p  sE    	;	Gk$9: 	?Wgy:'=>	?Wgy:'=>rK   c                     t         | |z     }|dk(  r|j                  |       y |dk(  r|j                  |        y |dk(  r&|j                  t        j                  d|             y y )Nr   r   r!   >h)r  rZ   r   structpack)r  r  r   
coordBytes	byteCounts        rD   flagEncodeCoordr%  x  sa    td{+IA~% 	b5&!	a&++dE23 
rK   c                 h    t        | t        t        z  ||       t        | t        t        z  ||       y rG   )r%  r  r  r  r  )r  r   r   xBytesyBytess        rD   flagEncodeCoordsr)    s(    D)j0!V<D)j0!V<rK      i   i   i   i   CompositeMaxpValues)nPoints	nContoursmaxComponentDepthc                       e Zd ZdZd#dZd$dZd Z	 d$ddddZd	 Zd
 Z	d%dZ
d Zd Zd Zd&dZd ZdddZd Zd Zd ZdddZdddZd ZeddZd Zd'dZd Zd&dZd&d Zd! Zd" Zy)(r4   a  This class represents an individual TrueType glyph.

    TrueType glyph objects come in two flavours: simple and composite. Simple
    glyph objects contain contours, represented via the ``.coordinates``,
    ``.flags``, ``.numberOfContours``, and ``.endPtsOfContours`` attributes;
    composite glyphs contain components, available through the ``.components``
    attributes.

    Because the ``.coordinates`` attribute (and other simple glyph attributes mentioned
    above) is only set on simple glyphs and the ``.components`` attribute is only
    set on composite glyphs, it is necessary to use the :py:meth:`isComposite`
    method to test whether a glyph is simple or composite before attempting to
    access its data.

    For a composite glyph, the components can also be accessed via array-like access::

            >> assert(font["glyf"]["Aacute"].isComposite())
            >> font["glyf"]["Aacute"][0]
            <fontTools.ttLib.tables._g_l_y_f.GlyphComponent at 0x1027b2ee0>

    c                 &    |sd| _         y || _        y Nr   )rz   r:   )r9   r:   s     rD   __init__zGlyph.__init__  s    $%D!	rK   Tc                 j    | j                  ||      }| j                  j                          || _        y rG   )rY   __dict__clearr:   )r9   	glyfTablerW   r:   s       rD   r   zGlyph.compact  s)    ||I|4	rK   c                 &   t        | d      sy | j                  s
| `d| _        y t        j                  t
        | j                  |       \  }}| `| j                  dk(  ry | j                         r| j                  ||       y | j                  |       y )Nr:   r   )	rU   r:   rz   r   unpack2glyphHeaderFormatr   decompileComponentsdecompileCoordinates)r9   r6  dummyr:   s       rD   rI   zGlyph.expand  s    tV$yy	$%D!oo&7DItI   A%$$T95%%d+rK   NrM   c                R   t        | d      r |r| j                  |       n| j                  S | j                  dk(  ry|r| j	                  ||       t        j                  t        |       }| j                         r|| j                  |      z   }|S || j                  |      z   }|S )Nr:   r   rK   r   rO   )rU   rI   r:   rz   r   r   r"  r9  r   compileComponentscompileCoordinates)r9   r6  rW   rN   rO   r:   s         rD   rY   zGlyph.compile  s     4 I&yy   A%iJ?||-t4$00;;D  $11|1LLDrK   c                 &   | j                         r1| j                  D ]  }|j                  ||        t        | d      }nQd}t	        | j
                        D ]'  }|j                  d       |j                          t	        || j                  |   dz         D ]  }d| j                  |   d   fd| j                  |   d   fd| j                  |   t        z  fg}| j                  |   t        z  r|j                  d       | j                  |   t        z  r|j                  d	       |j                  d
|       |j                           | j                  |   dz   }|j!                  d       |j                          * | j
                  dkD  }|r}| j"                  rO|j                  d       |j                          | j"                  j                  ||       |j!                  d       n|j                  d       |j                          y y )Nprogramr   contourr   r   r   on)overlapr   )cubicr   ptinstructions)r   r   r   rU   r0   rz   r~   rs   endPtsOfContoursr   r   r  flagOverlapSimplerZ   	flagCubicr   r   rB  )	r9   r   r;   compohaveInstructionslastr@   jr   s	            rD   r   zGlyph.toXML  s   FF+ )&tY7D4001	* tT%:%:1%=%ABAd..q1!45d..q1!45tzz!}{:;E
 zz!}'88^4zz!}y0\2$$T51NN$ C ,,Q/!3i( % 2&  $44q8||/ ""662n-  0NN rK   c                    |dk(  r| j                   dk  rt        j                  d      | j                   dz   | _         t               }t	               }|D ]  }t        |t              s|\  }}}|dk7  r |j                  t        |d         t        |d         f       t        t        |d               }d	|v r t        t        |d	               r	|t        z  }d
|v r t        t        |d
               r	|t        z  }|j                  |        t        | d      s#|| _        || _        t        |      dz
  g| _        y | j                  j#                  |       | j                  j#                  |       | j                   j                  t        | j                        dz
         y |dk(  rx| j                   dkD  rt        j                  d      d| _         t        | d      sg | _        t'               }	| j$                  j                  |	       |	j)                  ||||       y |dk(  rVt+        j,                         | _        |D ]7  }t        |t              s|\  }}}| j.                  j)                  ||||       9 y y )NrC  r   z*can't mix composites and contours in glyphr   rG  r   r   rD  rE  rF  r   	componentr   r   rH  )rz   r   r3   r   	bytearrayr   r   rZ   r	   boolrJ  rK  rU   r   r   r1   rI  r   r   GlyphComponentr   r   ProgramrB  )
r9   rm   r   r   r;   r   r   r   r  rQ  s
             rD   r   zGlyph.fromXML  sD   9$$q(&&'STT$($9$9A$=D!*,KKE"!'51'.$eW4<""HU3Z$8(5::N#OPHU4[12%$xi8H/I*J--De#XeGn-E(FI%DT" # 4/#. "
),[)9A)=(>%  ''4

!!%(%%,,S1A1A-BQ-FG[ $$q(&&'STT$&D!4."$&(IOO""9-dE7F;^#$,,.DL"!'51'.$eW$$T5'6B	 # $rK   c                 P   | j                         sJ d}d}|}| j                  D ]s  }||j                     }|j                  dk(  r"|j                  dkD  r|j	                         \  }}	n%|j                  ||dz         \  }}	}
t        ||
      }||z   }||	z   }u t        |||      S )Nr   r   )r   r   rA   rz   getMaxpValuesgetCompositeMaxpValuesmaxr+  )r9   r6  r.  r-  r,  initialMaxComponentDepthrL  	baseGlyphnPnCcomponentDepths              rD   rX  zGlyph.getCompositeMaxpValues;  s    !!!	#4 __E!%//2I))Q.++a/"002B)2)I)I7!;*&B %((9>$J!lG!BI % #7I7HIIrK   c                 x    | j                   dkD  sJ t        | j                        t        | j                        fS r1  )rz   r1   r   rI  r   s    rD   rW  zGlyph.getMaxpValuesO  s7    $$q(((4##$c$*?*?&@@@rK   c                    g | _         d}d}|rCt               }|j                  ||      \  }}}||z  }| j                   j                  |       |rC|rt	        j
                  d|d d       \  }|dd  }t        j                         | _        | j                  j                  |d |        ||d  }t        |      dk\  r t        j                  dt        |             y y y )Nr   r   r   r!   r'   zBtoo much glyph data at the end of composite glyph: %d excess bytes)r   rT  rE   rZ   r!  unpackr   rU  rB  fromBytecoder1   r5   r6   )r9   r:   r6  morerM  rQ  	haveInstrnumInstructionss           rD   r:  zGlyph.decompileComponentsS  s    &(I$-$7$7i$H!D)T/);OO""9-	 
 !'tT"1X!>_8D$,,.DLLL%%d+;O&<=()D4yA~XI  rK   c                 >   t        j                   d      }|j                  |d d| j                  z          t        j                  dk7  r|j                          |j                         | _        d| j                  z  }t        j                  d|||dz          \  }t        j                         | _        | j                  j                  ||dz   |dz   |z           |d|z   z  }| j                  d   dz   }| j                  |||      \  }}}t        j!                  |      x| _        }	d}
d}t%        |      D ]  }||   }|t&        z  r|t(        z  r||
   }n||
    }|
dz   }
n|t(        z  rd}n
||
   }|
dz   }
|t*        z  r|t,        z  r||   }n||    }|dz   }n|t,        z  rd}n
||   }|dz   }||f|	|<    |
t/        |      k(  sJ |t/        |      k(  sJ |	j1                          t%        t/        |            D ]  }||xx   t2        z  cc<    || _        y )NHr!   bigr   r   r   r   )array	frombytesrz   sys	byteorderbyteswaptolistrI  r!  ra  r   rU  rB  rb  decompileCoordinatesRawr   zerosr   r0   r  r  r  r  r1   relativeToAbsolute	keepFlagsr   )r9   r:   rI  r=   instructionLengthnCoordinatesr   xCoordinatesyCoordinatesr   xIndexyIndexr@   r  r   r   s                   rD   r;  zGlyph.decompileCoordinatesh  sI    ;;s+""4(C!d.C.C*C#DE==E!%%' 0 7 7 9$'''%}}T4cAg3FG	 ((*!!$sQwq;L1L"MNq$$$,,R014,0,H,H$-
)|\
 *:)?)?)MM;|$A8Dj )#$V,A%f--A!	! (!j )#$V,A%f--A!	! (!VKN5 %6 \****\****&&(s5z"A!H	!H #
rK   c                    t        |      }d}d}d}	 ||   }|dz  }d}	|t        z  r||   dz   }	|dz  }t        |	      D ]F  }
|t        z  r|dz   }n|t        z  s|dz   }|t
        z  r|dz   }n|t        z  s|dz   }|||<   |dz   }H ||k\  rn}||k(  sJ d       t        j                  |      }t        j                  |      }t        |      |z
  ||z   z
  dk\  r(t        j                  dt        |      |z
  ||z   z
         t        j                  |||||z          }t        j                  ||||z   ||z   |z          }|||fS )	N>r   r   Bhbad glyph flagsr'   z$too much glyph data: %d excess bytes)rR  
flagRepeatr0   r  r  r  r  r!  calcsizer1   r5   r6   ra  )r9   rt  r:   r=   r   xFormatyFormatrO  r  repeatkxDataLenyDataLenru  rv  s                  rD   ro  zGlyph.decompileCoordinatesRaw  s   ,' 9D1HCFj cQq6]*$%mG*%mG*$%mG*%mGaE # L ' ( L 3"33 ??7+??7+t9s?h12a7KK6D	C8h#67 }}Wd3x.HI}}T#.3>H+DE
 lL00rK   c                 z   d}t        | j                        dz
  }d}d}t        t        | j                              D ]:  }||k(  rt        | d      }d}| j                  |   }||j	                  |||      z   }< |r?| j
                  j                         }|t        j                  dt        |            z   |z   }|S )NrK   r   r   rB  r   )	r1   r   r0   rU   rY   rB  getBytecoder!  r"  )	r9   r6  r:   lastcomponentrc  rM  r@   rL  rH  s	            rD   r?  zGlyph.compileComponents  s    DOO,q0s4??+,AM!#*4#; OOA&E%--.>	JJD - <<335L&++dC,=>>MDrK   r>  c                   t        | j                        t        | j                        k(  sJ g }t        j                  d| j                        }t
        j                  dk7  r|j                          |j                  |j                                | j                  j                         }|j                  t        j                  dt        |                   |j                  |       | j                  j                         }|j                          |j!                          |r| j#                  | j                  |      }n| j%                  | j                  |      }|j'                  |       dj)                  |      S )Nrg  rh  r   rK   )r1   r   r   ri  rI  rk  rl  rm  rZ   tobytesrB  r  r!  r"  r   r   absoluteToRelativecompileDeltasGreedycompileDeltasForSpeedr   r\   )r9   rO   r:   rI  rH  deltass         rD   r@  zGlyph.compileCoordinates  s   4##$DJJ777 ;;sD,A,AB==E!%%'$,,./||//1FKKc,&789L!!!&&(!!#--djj&AF //

FCFFxx~rK   c                    t               }t               }t               }d }d}t        ||      D ]4  \  }\  }	}
|	dk(  r
|t        z  }n`d|	cxk  rdk  r0n n-|t        z  }|	dkD  r
|t        z  }n|	 }	|j	                  |	       n%|j                  t        j                  d|	             |
dk(  r
|t        z  }n`d|
cxk  rdk  r0n n-|t        z  }|
dkD  r
|t        z  }n|
 }
|j	                  |
       n%|j                  t        j                  d|
             ||k(  r3|dk7  r.|dz   }|dk(  r|j	                  |       n%|t        z  |d<   ||d<   nd}|j	                  |       |}7 |||fS )Nr   r	  r
  r   r   r   r   )rR  r   r  r  rZ   r   r!  r"  r  r  r~  )r9   r   r  compressedFlagscompressedXscompressedYslastflagr  r  r   r   s              rD   r  zGlyph.compileDeltasGreedy  sz    $+ { {v.LD&1a Avi'!c!j(q5)+DA##A&##FKKa$89Avi'!c!j(q5)+DA##A&##FKKa$89xFcM!Q;#**40*.*;OB'*0OB'&&t,HK /L  |<<rK   c           	         g }d }d}d}t        ||      D ]  \  }\  }}	t        ||	|      \  }}
|d|
z   z  }||||
f|dz   ||t        z  |
fg}|D ]c  \  }}}}
||
z   |dz   k  s|t        z  s|dk  s$t        ||      s1|dz  |t        z  k(  r	||dz   k(  rI|j	                  ||
z   ||dz   |
f       e |}t        |d       }|d   } g }|r|\  }}}}
|j	                  |       |r|j                          t               }t               }t               }t        |      }g }|D ]  }|dz	  |dz  }}|j	                  |       |t        z  r|dkD  sJ |j	                  |       n|dk(  sJ t        d|z         D ]0  }t        |      \  }}	t        |||	||       |j	                  |       2  	 t        |       t        d	      # t        $ r Y nw xY w|||fS )
Nr   r   i   r
  r*  c                     | d   S r1  r  )ts    rD   <lambda>z,Glyph.compileDeltasOptimal.<locals>.<lambda>C  s    adrK   )keyr  zinternal error)r   r  r~  r  rZ   minreverserR  iterr0   nextr)  	ExceptionStopIteration)r9   r   r  
candidates	bestTuplebestCostr  r  r   r   r#  newCandidateslastCost	lastTuplelastFlagr  r  r  r  r   ffrepeatCountr@   s                          rD   compileDeltasOptimalzGlyph.compileDeltasOptimal%  sB    
	v.LD&1a'1d3D*J&H9dJ7Ay4*+<zJM >H9)Xzz)X\9!J.!F*$Xt4 4z)"hl2 !((!J.	8c>:V >H 'JJN;I |H1 /4 09-D)T:LL  	#+ { {fD $	4$;K""4(j "Q&&&{3"a'''1{?+F|1 q!\<H		$ , 	L,-- 		  |<<s   2G 	GGc                    t               }t               }t               }|D cg c]  }|d   	 }}|D cg c]  }|d   	 }}t        |      t        |      t        |      t        |      f\  }	}
}}|	dk(  xr |dk(  }|
dk(  xr |dk(  }d|	cxk  xr |cxk  xr dk  nc }d|
cxk  xr |cxk  xr dk  nc }d }d}t        ||      D ]  \  }\  }}|r
|t        z  }nT|r-|t
        z  }|dkD  r
|t        z  }n| }|j                  |       n%|j                  t        j                  d|             |r
|t        z  }nT|r-|t        z  }|dkD  r
|t        z  }n| }|j                  |       n%|j                  t        j                  d|             ||k(  r3|dk7  r.|dz   }|dk(  r|j                  |       n%|t        z  |d<   ||d<   nd}|j                  |       |} |||fS c c}w c c}w )Nr   r   r	  r
  r   r   r   )rR  r  rY  r   r  r  rZ   r   r!  r"  r  r  r~  )r9   r   r  r  r  r  r   xsysminXminYmaxXmaxYxZeroyZeroxShortyShortr  r  r  r   r   s                         rD   r  zGlyph.compileDeltasForSpeede  s
   #+ { { ##FqadF#"#FqadF#!$R#b'3r7CG!CdD$	'dai	'dai,,,,,,v.LD&1a i'j(q5)+DA##A&##FKKa$89i'j(q5)+DA##A&##FKKa$89xFcM!Q;#**40*.*;OB'*0OB'&&t,HK /L  |<<a $#s
   G)G.r   c                    | j                         r| j                  ||      ry	 | j                  |t              \  }}}|j	                         \  | _        | _        | _        | _        y# t        $ r Y yw xY w)a=  Recalculates the bounds of the glyph.

        Each glyph object stores its bounding box in the
        ``xMin``/``yMin``/``xMax``/``yMax`` attributes. These bounds must be
        recomputed when the ``coordinates`` change. The ``table__g_l_y_f`` bounds
        must be provided to resolve component bounds.
        r   Nr   )
r   tryRecalcBoundsCompositer   r   calcIntBoundsrn   ro   rp   rq   NotImplementedError)r9   r6  rN   r   r   r   s         rD   r   zGlyph.recalcBounds  s     $"?"?* #@ #
 	$($7$7	$7$Q!FFE9?9M9M9O6DIty$)TY" 		s   AA+ +	A76A7c                ^   | j                   D ]  }|j                         r y d}| j                   D ]  }|j                  }||   }|||vr&|j                  ||       ||j	                  |       |j
                  |j                  k(  r|j                  |j                  k(  rs|j                  |j                  }}t        ||j                  |z   |j
                  |z   f      }t        ||j                  |z   |j                  |z   f      } |d}|\  | _        | _        | _        | _        y)a=  Try recalculating the bounds of a composite glyph that has
        certain constrained properties. Namely, none of the components
        have a transform other than an integer translate, and none
        uses the anchor points.

        Each glyph object stores its bounding box in the
        ``xMin``/``yMin``/``xMax``/``yMax`` attributes. These bounds must be
        recomputed when the ``coordinates`` change. The ``table__g_l_y_f`` bounds
        must be provided to resolve component bounds.

        Return True if bounds were calculated, False otherwise.
        FNr   r   r   r   r   T)r   _hasOnlyIntegerTranslaterA   r   r{   ro   rq   rn   rp   r   r   r   )	r9   r6  rN   rL  boundsrA   gr   r   s	            rD   r  zGlyph.tryRecalcBoundsComposite  s    __E113 %
 __EI)$A!Yj%@yZ@)NN9-vvAFFaff$477EGGqA!&166A:qvvz*BCF!&166A:qvvz*BCF %  >!F5;2	49dirK   c                     t        | d      r7| j                  r)t        j                  d| j                  dd       d   dk(  S dS | j                  dk(  S )z#Test whether a glyph has componentsr:   r   Nr!   r   r   F)rU   r:   r!  ra  rz   r   s    rD   r   zGlyph.isComposite  sN    4 BF))6==tyy!}5a8B>VQVV((B..rK   r   c                ,   | j                   dkD  r#| j                  | j                  | j                  fS | j	                         rt               }t               }g }| j                  D ]  }||j                     }	 |j                  ||      \  }}	}
t        |      }|t        ur!|j                   dkD  r|j                  |       t        |d      rgt        |d      r|j!                  |j                          ||j"                     \  }}||j$                     \  }}||z
  ||z
  f}|j'                  |       n|j(                  |j*                  f}t        |d      s|j'                  |       n|j                  t,        z  }|j                  t.        z  }|r|rJ |s	|st0        }n|}|r-|j'                  |       |j!                  |j                          n,|j!                  |j                          |j'                  |       t3        |      |j5                  fd|	D               |j5                  |       |j5                  |
        |||fS t               g t               fS # t        $ r# t        j                  d|j                  z        w xY w)a  Return the coordinates, end points and flags

        This method returns three values: A :py:class:`GlyphCoordinates` object,
        a list of the indexes of the final points of each contour (allowing you
        to split up the coordinates list into contours) and a list of flags.

        On simple glyphs, this method returns information from the glyph's own
        contours; on composite glyphs, it "flattens" all components recursively
        to return a list of coordinates representing all the components involved
        in the glyph.

        To interpret the flags for each point, see the "Simple Glyph Flags"
        section of the `glyf table specification <https://docs.microsoft.com/en-us/typography/opentype/spec/glyf#simple-glyph-description>`.
        r   r   z3glyph '%s' contains a recursive component referencefirstPtr   c              3   (   K   | ]	  }|z     y wrG   r  ).0eoffsets     rD   	<genexpr>z'Glyph.getCoordinates.<locals>.<genexpr>+  s      <VVVs   )rz   r   rI  r   r   r   rR  r   rA   r   RecursionErrorr   r3   r   r   rU   r   r  secondPt	translater   r   SCALED_COMPONENT_OFFSETUNSCALED_COMPONENT_OFFSETSCALE_COMPONENT_OFFSET_DEFAULTr1   r   )r9   r6  r   	allCoordsallFlags	allEndPtsrL  r  r   r   r   x1y1x2y2move	apple_wayms_wayscale_component_offsetr  s                      @rD   r   zGlyph.getCoordinates  sp       1$##T%:%:DJJFF(*I {HIeoo.121A1A! 2B 2.K /{; 'A,>,>,B%%E%25), uk2#--eoo>&u}}5FB(8FB7BG+D))$/ !77EGG+D"5+6#--d3$)KK2I$I	!&/H!H$-&99 )V > 3 6?21'11$7'11%//B (11%//B'11$7Y   <V <<  -&o )p i11#%r9;66i & **M//* s   ;I'',Jc                 r   t        | d      s6| j                         r$| j                  D cg c]  }|j                   c}S g S | j                  r)t        j                  d| j                  dd       d   dk\  rg S | j                  }d}g }d}|rt        j                  d|||d	z          \  }}|d	z  }t        |      }|j                  |j                  t        |                   |t        z  r|d	z  }n|dz  }|t        z  r|dz  }n|t        z  r|d	z  }n|t        z  r|d
z  }|t        z  }|r|S c c}w )zReturns a list of names of component glyphs used in this glyph

        This method can be used on simple glyphs (in which case it returns an
        empty list) or composite glyphs.
        r:   r   Nr!   r   
   r   >HHr'   r  )rU   r   r   rA   r:   r!  ra  r+   rZ   r   ARG_1_AND_2_ARE_WORDSWE_HAVE_A_SCALEWE_HAVE_AN_X_AND_Y_SCALEWE_HAVE_A_TWO_BY_TWOMORE_COMPONENTS)	r9   r6  r   r:   r@   r   rc  r   r   s	            rD   getComponentNameszGlyph.getComponentNames2  s?    tV$!-1__=__==	 yyFMM$		"1>qAQFIyy
#]]5$q1q5/BNE7FAJEi44S\BC,,QQ&Q11Q--Q?*D! $ ? >s   D4c                    t        | d      sV|rS| j                         rt        | d      r| `yt        j                         | _        | j                  j                  g        y| j                  syt        j                  d| j                  dd       d   }t        | j                        }d}|dk\  r|d|z  z  }||dz
     dz  ||d	z
     z  d	z   }||   dz  ||d	z      z  }|r%dx||<   ||d	z   <   |dz  }|r|d| |||z   d z   }d}n|d|z   z  }d}d}	 ||   }	|d	z   }d	}
|	t        z  r||   d	z   }
|d	z   }dx}}|	t        z  rd	}n|	t        z  sd}|	t        z  rd	}n|	t        z  sd}|||z   |
z  z  }||
z  }||k\  rnk||k(  sJ d       ||z  }|d| }|| _        y| j                         rd	}d}|r||   dz  ||d	z      z  }|r
|t         z  }|t        z  rd
}|dz	  ||dz   <   |dz  ||d	z   <   |dz  }t!        |      }|t"        z  r|dz  }n|dz  }|t$        z  r|dz  }n|t&        z  r|dz  }n|t(        z  r|dz  }|t*        z  }|r|r||   dz  ||d	z      z  }|d|z   z  }|d| }|| _        y)zRemove padding and, if requested, hinting, from a glyph.
        This works on both expanded and compacted glyphs, without
        expanding it.r:   rB  Nr   r!   r   r  r  r   Tr}  Fr
  r'   )rU   r   rB  r   rU  rb  r:   r!  ra  rR  r~  r  r  r  r  WE_HAVE_INSTRUCTIONSr+   r  r  r  r  r  )r9   remove_hintingnumContoursr:   r@   rt  instructionLenr#  rO  r  r  r'  r(  rc  we_have_instructionsr   s                   rD   trimz
Glyph.trim[  sG    tV$##%tY/ L
  $-#4#4#6DLLL--b1yymmD$))BQ-8;#![ A!!a%[A-a!e<AL"1gld1q5k9N())Q$q1u+Q!8d1~+=+?&@@D!"Q''JAAwE*$!!Wq[FAA"##*$F*F*$F*Fv&88
V$' ( $7&77$OA8D@ 	? D#( aAa!e4!222E//+/(#qjQU#dlQUQE
00FAFA?*FA55FA11FA.+ , $"&q'Q,$q1u+!=Q''8D	rK   c                 (    | j                  d       y)z5Removes TrueType hinting instructions from the glyph.T)r  N)r  r   s    rD   r   zGlyph.removeHinting  s    			&rK   c                 Z   | j                         r7| j                  D ]'  }|j                         \  }}|j                  ||       ) y| j	                  |       | j                  |      \  }}}	|r#|j                         }|j                  |df       d}
d }|D ]  }|dz   }||
| }|	|
| D cg c]  }t        |z   }}|	|
| D cg c]  }t        |z   }}|}
d|vrt        |      st        |      rJ t        |      }|rt        |      }|dz  dk(  sJ d       |d   }|d   } ||d   |d   z   dz         ||d   |d   z   dz        f}|j                  |       t        d|d      D ]\  }||   }||dz      }||dz   |k  r|dz   nd   } ||d   |d   z   dz         ||d   |d   z   dz        f}|j                  |||       ^ n|j!                  d        |j"                  |  n|j%                  d      dz   }||d |d| z   }||d |d| z   }||d |d| z   }|j                  |d          |rK|j%                  d      dz   }|dk(  r$t        |      dkD  r|j'                  |d          n|d|dz
   D cg c]  }| }}t        |      st        |      rJ t        |      }|rt        |      sJ d	       |}|d
k\  sJ d       |dz
  dz  dk(  sJ d       t        d|d
z
  d      D ]T  }||   }||dz      }||dz      } ||d   |d   z   dz         ||d   |d   z   dz        f}|}|j                  |||       V  |j                  ||d
z
  |   n |j"                  |d|   ||d }||d }||d }|rK|j)                           yc c}w c c}w c c}w )ah  Draws the glyph using the supplied pen object.

        Arguments:
                pen: An object conforming to the pen protocol.
                glyfTable: A :py:class:`table__g_l_y_f` object, to resolve components.
                offset (int): A horizontal offset. If provided, all coordinates are
                        translated by this offset.
        Nr   c                 8    | t        |       k(  rt        |       S | S rG   )r+   )vs    rD   r  zGlyph.draw.<locals>.<lambda>  s    qCF{SV99rK   r   r!   z(Odd number of cubic off-curves undefinedr         ?z+Mixed cubic and quadratic segment undefined   z,At least two cubic off-curve points required)r   r   getComponentInfoaddComponentrI   r   r   r  r  rK  allanyr1   moveTor0   curveTorZ   qCurveToindexlineTo	closePath)r9   penr6  r  rQ  rA   r   r   r   r   startmaybeIntendrC  fcFlagscuFlagsrF  countlp0r@   p1p2p4p3firstOnCurvenextOnCurve
cubicFlagslastOnCurves                                 rD   drawz
Glyph.draw  s    !__	'0'A'A'C$	9  I6 - I%)%8%8%C"VU%**,K!!61+.9C'C!%,G/4U3/?@/?!kAo/?F@.3E#.>?.>y1}.>G?E7|3w<77GLE 19>U+UU>A
A"AaD1Q4K3#671Q4!A$;RUBU9VWBJJrN"1eQ/$QZ$QU^$a!eemQUC$bebems%:;$bebems%:; BB/ 0 NN4( CLL'*
  &||A2!,-07=L3II.1FF!,-07=L3II

72;'"(,,q/A"5K"a' w<!+JJwqz2189J;?1K%L1KAa1K
%L":c*oEE #J #& *$ MLM $ %0E %
NMN * !&	 !$"%&$' S(RS $' &+1eai%;%,QZ%,QU^%,QU^$,bebems-B$C$,bebems-B$C&" /1 #BB 7 &< (CKKU)CD(CLL',;*?@%kl3G#KL1F%kl3GM N MMO_  A?X &Ms   /NN#	N(c                 f   | j                         r7| j                  D ]'  }|j                         \  }}|j                  ||       ) y| j	                  |      \  }}}	|r#|j                         }|j                  |df       d}
|D ]  }|dz   }||
| }|	|
| }|}
|j                          |d   t        z  rd}n|d   t        z  rd}nd}t        |      D ]H  \  }}||   t        z  r|j                  ||       d}(|j                  |       ||   t        z  rdnd}J |j                           y)	zDraw the glyph using the supplied pointPen. As opposed to Glyph.draw(),
        this will not change the point indices.
        Nr   r   r   linecurveqcurve)segmentType)r   r   r  r  r   r   r  	beginPathr  rK  r[   addPointendPath)r9   r  r6  r  rQ  rA   r   r   r   r   r  r  rC  r  r  r@   rG  s                    rD   
drawPointszGlyph.drawPoints$  sD   
 !__	'0'A'A'C$	9  I6 - %)%8%8%C"VU%**,K!!61+.C'C!%,G5%FEMMO bzK'$i'%&"7+2!9{*LLL="(KLL$-3AY-B'K , KKM+ rK   c                 n    t        |       t        |      k7  rt        S | j                  |j                  k(  S rG   typeNotImplementedr4  r9   others     rD   __eq__zGlyph.__eq__K  +    :e$!!}}..rK   c                 >    | j                  |      }|t        u r|S | S rG   r  r  r9   r  results      rD   __ne__zGlyph.__ne__P  $    U#>1vA6zArK   )rK   )T)r   )r   r   ) r   r   r   r   r2  r   rI   rY   r   r   rX  rW  r:  r;  ro  r?  r@  r  r  r  r   r  r   r   r   r  r  r   r  r  r  r  r  rK   rD   r4   r4     s    ,
,, '+:>T,#J+CZJ(A*6p*1X  26 2.=`>=@7=r 59 $ AE &P/ 29 Q7f'R[z'fP%N/
BrK   r4   r   r  r   r  returnc                     t        |       } t        |      }t        |      }| |z   dz  j                  |      xs& t        |       t        |      z   t        |      dz  k(  S )Nr  r!   )r   isclose_roundv)r  r   r  s      rD   _is_mid_pointr$  Z  sW    	B	B	B"WO$$R(XGBK'"+,EQSWX,XXrK   interpolatable_glyphsc                  :   t        ddd      }dg }t        |       D ]G  \  }}|j                  dk  r|j                  D ]F  }t	        ||      }t	        ||      }|t        |||       +||k7  s1t        d| d| d| d|        t               }d}	|j                  |j                  |j                  }
|
D ]  }t        |	|dz         D ]g  }|   t        z  s||	kD  r|dz
  n|}||k  r|dz   n|	}|   t        z  s|   |   k7  r@t        |   |   |         sW|j                  |       i |dz   }	 |nj                  |       |j!                  |       J r |j                  J t#        j"                  d	fd
t        t%                    D              }|j                  }|J g }d}d}t'              D ]4  }|||   kD  r%|j!                  ||   |z
         |dz  }|||   kD  r%|dz  }6 |t%        |      k  r+|j!                  ||   |z
         |dz  }|t%        |      k  r+|D ]H  }|j                  t)        fdt        t%                    D              |_        ||_	        ||_
        J S t               S )a  Drop impliable on-curve points from the (simple) glyph or glyphs.

    In TrueType glyf outlines, on-curve points can be implied when they are located at
    the midpoint of the line connecting two consecutive off-curve points.

    If more than one glyphs are passed, these are assumed to be interpolatable masters
    of the same glyph impliable, and thus only the on-curve points that are impliable
    for all of them will actually be implied.
    Composite glyphs or empty glyphs are skipped, only simple glyphs with 1 or more
    contours are considered.
    The input glyph(s) is/are modified in-place.

    Args:
        interpolatable_glyphs: The glyph or glyphs to modify in-place.

    Returns:
        The set of point indices that were dropped if any.

    Raises:
        ValueError if simple glyphs are not in fact interpolatable because they have
        different point flags or number of contours.

    Reference:
    https://developer.apple.com/fonts/TrueType-Reference-Manual/RM01/Chap1.html
    N)rz   r   rI  r   zIncompatible z for glyph at master index z: expected z, found r   r{  c              3   2   K   | ]  }|vs|     y wrG   r  )r  r@   dropr   s     rD   r  z+dropImpliedOnCurvePoints.<locals>.<genexpr>  s     G$5q$%($5   	
c              3   2   K   | ]  }|vs|     y wrG   r  )r  r@   r   r(  s     rD   r  z+dropImpliedOnCurvePoints.<locals>.<genexpr>  s       1#5a$q	#5r)  )r   r[   rz   r4  r   r   r   rX   r   r   rI  r0   r  r$  r{   intersection_updaterZ   ri  r1   sortedr   )r%  staticAttributessimple_glyphsr@   rC   r   expectedfoundmay_dropr  rI  rN  prvnxtnewFlagsr   	newEndPtsdeltar   r   r(  r   s                      @@@rD   dropImpliedOnCurvePointsr7  b  s   4 'TD DM345!!A%$--D/6HE4(E($6U" #D6)DQC H  (z%:  . 5"" &&+<<$D5$(+a;. 5ya!ed 4xa!eU#J,suSz1I$VC[&)VC[IQ , 1HE % <D$$X.U#S 5V  &&   ;;GE#e*$5G
 "22!!!	AfQi-  U!23Q fQi- QJE	 
 #f+oVAY./FA #f+o #E&&F 0 1#(V#51 !E #EK%.E" # #4..rK   c                   F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)rT  a?  Represents a component within a composite glyph.

    The component is represented internally with four attributes: ``glyphName``,
    ``x``, ``y`` and ``transform``. If there is no "two-by-two" matrix (i.e
    no scaling, reflection, or rotation; only translation), the ``transform``
    attribute is not present.
    c                      y rG   r  r   s    rD   r2  zGlyphComponent.__init__  s    rK   c                     t        | d      r2| j                  \  \  }}\  }}||||| j                  | j                  f}ndddd| j                  | j                  f}| j                  |fS )a  Return information about the component

        This method returns a tuple of two values: the glyph name of the component's
        base glyph, and a transformation matrix. As opposed to accessing the attributes
        directly, ``getComponentInfo`` always returns a six-element tuple of the
        component's transformation matrix, even when the two-by-two ``.transform``
        matrix is not present.
        r   r   r   )rU   r   r   r   rA   )r9   xxxyyxyytranss         rD   r  zGlyphComponent.getComponentInfo  sg     4%#'>> Xb"xBRTVVTVV4E1a0E~~u$$rK   c                    t        j                  d|d d       \  }}t        |      | _        t        |      }|j	                  t        |            | _        |dd  }| j                  t        z  r}| j                  t        z  r't        j                  d|d d       \  | _        | _	        n=t        j                  d|d d       \  }}t        |      t        |      c| _
        | _        |dd  }n|| j                  t        z  r't        j                  d|d d       \  | _        | _	        n=t        j                  d|d d       \  }}t        |      t        |      c| _
        | _        |dd  }| j                  t        z  rBt        j                  d|d d       \  }t        |d      d	gd	t        |d      gg| _        |dd  }n| j                  t        z  rCt        j                  d|d d       \  }}	t        |d      d	gd	t        |	d      gg| _        |dd  }nk| j                  t         z  rXt        j                  d
|d d       \  }}
}}	t        |d      t        |
d      gt        |d      t        |	d      gg| _        |dd  }| j                  t"        z  }| j                  t$        z  }| j                  t&        t(        z  t*        z  t,        z  t.        z  t0        z  z  | _        |||fS )Nr  r'   >hh>bbr!   >BBr      r   >hhhhr  )r!  ra  r+   r   r   rA   r  ARGS_ARE_XY_VALUESr   r   r  r  r  fi2flr   r  r  r  r  ROUND_XY_TO_GRIDUSE_MY_METRICSr  r  NON_OVERLAPPINGOVERLAP_COMPOUND)r9   r:   r6  r   r   r   r   scalexscaleyscalescale01scale10rc  rM  s                 rD   rE   zGlyphComponent.decompile  s   ud2Ah7wZ
g,"//G=ABx::--zz..!'ud2Ah!?}}UD!H51.1!fc!f+dm8Dzz..!'ud2Ah!?}}UD!H51.1!fc!f+dm8D::'}}T484HUub!1%E%$%DN 8DZZ22#]]5$r(;NFFvr"A&E&"%&DN 8DZZ..17wRa1Q.VWgvvr"E'2$67w#U62%67DN 8DzzO+::(<<ZZ%& (( 	
 

 %t++rK   c                 j   d}| j                   t        t        z  t        z  t        z  t
        z  t        z  z  }|r	|t        z  }|r	|t        z  }t        | d      rd| j                  cxk  rdk  rJn nGd| j                  cxk  rdk  r2n n/|t        j                  d| j                  | j                        z   }n|t        j                  d| j                  | j                        z   }|t        z  }nt        | j                         }t        | j"                        }|t$        z  }d|cxk  rdk  r,n n)d|cxk  rdk  rn n|t        j                  d	||      z   }n#|t        j                  d
||      z   }|t        z  }t        | d      r| j&                  D cg c]  }|D cg c]  }t)        |d       c} }	}}|	d   d   s|	d   d   r>|t*        z  }|t        j                  d|	d   d   |	d   d   |	d   d   |	d   d         z   }ni|	d   d   |	d   d   k7  r0|t,        z  }|t        j                  d
|	d   d   |	d   d         z   }n(|t.        z  }|t        j                  d|	d   d         z   }|j1                  | j2                        }
t        j                  d||
      |z   S c c}w c c}}w )NrK   r  r   r
  rC  r  i   rB  rA  r   rD  r   rE  r   )r   rH  rI  r  r  rJ  rK  r  r  rU   r  r  r!  r"  r  r   r   r   rF  r   fl2fir  r  r  r   rA   )r9   rc  rM  r6  r:   r   r   r   rowr   r   s              rD   rY   zGlyphComponent.compile)  s    

%& (( 	
 
 O+E00E4#T\\(S(qDMM/HS/Hfkk%t}}MMfkk%t}}MM 55AA..E S tq'7C'7fkk%A66fkk%A66 554%@DO41%2,4IO|A)A,q/ 44fkkaLOaLOaLOaLO  1aIaLO3 88fkk%1a)A,q/RR/fkk$	!Q@@&&t~~6{{5%1D88% 5Os   	J/#J*6J/*J/c           	         d| j                   fg}t        | d      s |d| j                  fd| j                  fgz   }n|d| j                  fd| j
                  fgz   }t        | d      r| j                  }|d   d   s|d   d   rR|d	t        |d   d   d
      fdt        |d   d   d
      fdt        |d   d   d
      fdt        |d   d   d
      fgz   }nU|d   d   |d   d   k7  r,|d	t        |d   d   d
      fdt        |d   d   d
      fgz   }n|dt        |d   d   d
      fgz   }|dt        | j                        fgz   }|j                  d|       |j                          y )NrA   r  r   r   r  r   r   r   scalexrD  rO  rP  scaleyrL  r   rQ  )rA   rU   r   r   r  r  r   fl2strhexr   r   rs   )r9   r   r;   r   r   s        rD   r   zGlyphComponent.toXML_  s   t~~./tY'c466]S$&&M::Ei6T]]8STTE4%I|A)A,q/vil1or:;y|A ;<y|A ;<vil1or:;	!  1aIaLO3vil1or:;vil1or:;! 
 '6)A,q/2+F!G HH'3tzz?344e,rK   c                    |d   | _         d|v r't        |d         | _        t        |d         | _        n&t        |d         | _        t        |d         | _        d|v rJt        |d   d      }t        |d   d      }t        |d	   d      }t        |d
   d      }||g||gg| _        nPd|v r,t        |d   d      }t        |d
   d      }|dgd|gg| _        n d|v rt        |d   d      }	|	dgd|	gg| _        t        |d         | _        y )NrA   r  r  r   r   rO  rV  rD  rP  rW  r   rL  r   )	rA   r	   r  r  r   r   str2flr   r   )
r9   rm   r   r   r;   rV  rO  rP  rW  rL  s
             rD   r   zGlyphComponent.fromXMLz  s0   {+#E)$45DL$U:%67DMeCj)DFeCj)DFE(OR0FU9-r2GU9-r2GE(OR0F%w/'61BCDNE(OR0FE(OR0F%qkAv;7DN5>2.E$aj1e*5DNeGn-
rK   c                 n    t        |       t        |      k7  rt        S | j                  |j                  k(  S rG   r  r  s     rD   r  zGlyphComponent.__eq__  r  rK   c                 >    | j                  |      }|t        u r|S | S rG   r  r  s      rD   r  zGlyphComponent.__ne__  r  rK   c                     t        | d       xrW t        | d       xrH t        | j                        j                         xr# t        | j                        j                         S )zReturn True if it's a 'simple' component.

        That is, it has no anchor points and no transform other than integer translate.
        r  r   )rU   floatr   
is_integerr   r   s    rD   r  z'GlyphComponent._hasOnlyIntegerTranslate  s\     i(( +D+..+dff((*+ dff((*		
rK   N)r   r   r   r   r2  r  rE   rY   r   r   r  r  r  r  rK   rD   rT  rT    s7    %*5,n49l6../
B

rK   rT  c                      e Zd ZdZg fdZed        Zed        Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd ZeddZd ZefdZd Zd Zd Zd Zd Zd Zd Zd Zd ZeddZd Zd Z d Z!d Z"eZ#e!Z$d Z%d  Z&d! Z'd" Z(d# Z)d$ Z*e*Z+y%)&r   zA list of glyph coordinates.

    Unlike an ordinary list, this is a numpy-like matrix object which supports
    matrix addition, scalar multiplication and other operations described below.
    c                 Z    t        j                   d      | _        | j                  |       y )Nr   )ri  _ar   )r9   iterables     rD   r2  zGlyphCoordinates.__init__  s    ++c"HrK   c                     | j                   S )z+Returns the underlying array of coordinates)rc  r   s    rD   ri  zGlyphCoordinates.array  s     wwrK   c                     t               }|j                  j                  t        | dz  |j                  j                  z               |S )zKCreates a new ``GlyphCoordinates`` object with all coordinates set to (0,0)r!   )r   rc  rj  bytesitemsize)r  r  s     rD   rp  zGlyphCoordinates.zeros  s7     	uUQY678rK   c                 d    t               }|j                  j                  | j                         |S )zMCreates a new ``GlyphCoordinates`` object which is a copy of the current one.)r   rc  r   )r9   r   s     rD   r   zGlyphCoordinates.copy  s#    	DGGrK   c                 2    t        | j                        dz  S )z/Returns the number of coordinates in the array.r!   r1   rc  r   s    rD   r   zGlyphCoordinates.__len__  s    477|q  rK   c                    | j                   }t        |t              rt        |j	                  t        |              }g }|D ]^  }|d|z     }|d|z  dz      }|j                  |j                         rt        |      n||j                         rt        |      n|f       ` |S |d|z     }|d|z  dz      }|j                         rt        |      n||j                         rt        |      fS |fS )z!Returns a two element tuple (x,y)r!   r   )	rc  r   slicer0   rc   r1   rZ   r`  r+   )r9   r  arc   retr   r   s          rD   r   zGlyphCoordinates.__getitem__  s    GGaQYYs4y12GCa!eHa!eaiL

 ||~SV1c!fTUV  Ja!eHa!eaiL,,.Aa1<<>QQQqQQrK   c                     t        |t              r<t        |j                  t	        |              }t        |      D ]  \  }}||   | |<    y|\  | j                  d|z  <   | j                  d|z  dz   <   y)z7Sets a point's coordinates to a two element tuple (x,y)Nr!   r   )r   rm  r0   rc   r1   r[   rc  )r9   r  r  rc   rO  r@   s         rD   r   zGlyphCoordinates.__setitem__  sm    aQYYs4y12G!'*1A$Q +-.*AA	*rK   c                 n    d|z  t        | j                        z  }| j                  |= | j                  |= y)zRemoves a point from the listr!   Nrk  )r9   r@   s     rD   r   zGlyphCoordinates.__delitem__  s.    Uc$''l"GGAJGGAJrK   c                 >    ddj                  d | D              z   dz   S )NzGlyphCoordinates([,c              3   2   K   | ]  }t        |        y wrG   )str)r  r   s     rD   r  z,GlyphCoordinates.__repr__.<locals>.<genexpr>  s     .Dt!s1vts   z]))r\   r   s    rD   __repr__zGlyphCoordinates.__repr__  s!    #chh.Dt.D&DDtKKrK   c                 L    | j                   j                  t        |             y rG   )rc  r   r   )r9   r   s     rD   rZ   zGlyphCoordinates.append  s    uQx rK   c                 H    |D ]  }| j                   j                  |        y rG   )rc  r   )r9   rd  r   s      rD   r   zGlyphCoordinates.extend  s    AGGNN1 rK   r   c                |    |t         u ry | j                  }t        t        |            D ]  } |||         ||<    y rG   )r   rc  r0   r1   )r9   r   rn  r@   s       rD   r   zGlyphCoordinates.toInt  s9    GGGs1vA1;AaD rK   c                     | j                   }|sy|dd d   }|dd d   }t        |      t        |      t        |      t        |      fS )Nr  r   r!   r   )rc  r  rY  )r9   rn  r  r  s       rD   
calcBoundszGlyphCoordinates.calcBounds  sN    GGqt!tWqt!tW2wBR#b'11rK   c                 H    t        fd| j                         D              S )Nc              3   .   K   | ]  } |        y wrG   r  )r  r  r   s     rD   r  z1GlyphCoordinates.calcIntBounds.<locals>.<genexpr>  s     9'8!U1X'8s   )r   r{  )r9   r   s    `rD   r  zGlyphCoordinates.calcIntBounds  s    9t'8999rK   c                     | j                   }d\  }}t        dt        |      d      D ]"  }||   |z   x||<   }||dz      |z   x||dz   <   }$ y N)r   r   r   r!   r   rc  r0   r1   )r9   rn  r   r   r@   s        rD   rq  z#GlyphCoordinates.relativeToAbsolute  s_    GG1q#a&!$AtaxAaD1QU8a<'Aa!eHq %rK   c                     | j                   }d\  }}t        dt        |      d      D ]&  }||   }||dz      }||z
  ||<   ||z
  ||dz   <   |}|}( y r  r  )r9   rn  r   r   r@   nxnys          rD   r  z#GlyphCoordinates.absoluteToRelative  si    GG1q#a&!$A1B1q5B6AaDAvAa!eHAA %rK   c                     |\  }}|dk(  r|dk(  ry| j                   }t        dt        |      d      D ]  }||xx   |z  cc<   ||dz   xx   |z  cc<   ! y)zA
        >>> GlyphCoordinates([(1,2)]).translate((.5,0))
        r   Nr!   r   r  r9   r   r   r   rn  r@   s         rD   r  zGlyphCoordinates.translate  [     16a1fGGq#a&!$AaDAIDa!eHMH %rK   c                     |\  }}|dk(  r|dk(  ry| j                   }t        dt        |      d      D ]  }||xx   |z  cc<   ||dz   xx   |z  cc<   ! y)z=
        >>> GlyphCoordinates([(1,2)]).scale((.5,0))
        r   Nr   r!   r  r  s         rD   rL  zGlyphCoordinates.scale$  r  rK   c                     | j                   }t        dt        |      d      D ]J  }||   }||dz      }||d   d   z  ||d   d   z  z   }||d   d   z  ||d   d   z  z   }|||<   |||dz   <   L y)zK
        >>> GlyphCoordinates([(1,2)]).transform(((.5,0),(.2,.5)))
        r   r!   r   Nr  )r9   r  rn  r@   r   r   pxpys           rD   r   zGlyphCoordinates.transform0  s     GGq#a&!$A!A!a%AQqT!Wq1Q47{*BQqT!Wq1Q47{*BAaDAa!eH %rK   c                 n    t        |       t        |      k7  rt        S | j                  |j                  k(  S )z
        >>> g = GlyphCoordinates([(1,2)])
        >>> g2 = GlyphCoordinates([(1.0,2)])
        >>> g3 = GlyphCoordinates([(1.5,2)])
        >>> g == g2
        True
        >>> g == g3
        False
        >>> g2 == g3
        False
        )r  r  rc  r  s     rD   r  zGlyphCoordinates.__eq__=  s-     :e$!!ww%((""rK   c                 >    | j                  |      }|t        u r|S | S )z
        >>> g = GlyphCoordinates([(1,2)])
        >>> g2 = GlyphCoordinates([(1.0,2)])
        >>> g3 = GlyphCoordinates([(1.5,2)])
        >>> g != g2
        False
        >>> g != g3
        True
        >>> g2 != g3
        True
        r  r  s      rD   r  zGlyphCoordinates.__ne__M  s&     U#>1vA6zArK   c                 "    | j                         S )a-  
        >>> g = GlyphCoordinates([(1,2)])
        >>> g
        GlyphCoordinates([(1, 2)])
        >>> g2 = +g
        >>> g2
        GlyphCoordinates([(1, 2)])
        >>> g2.translate((1,0))
        >>> g2
        GlyphCoordinates([(2, 2)])
        >>> g
        GlyphCoordinates([(1, 2)])
        )r   r   s    rD   __pos__zGlyphCoordinates.__pos__^  s     yy{rK   c                     | j                         }|j                  }t        t        |            D ]  }||    ||<    |S )z
        >>> g = GlyphCoordinates([(1,2)])
        >>> g
        GlyphCoordinates([(1, 2)])
        >>> g2 = -g
        >>> g2
        GlyphCoordinates([(-1, -2)])
        >>> g
        GlyphCoordinates([(1, 2)])
        )r   rc  r0   r1   )r9   rrn  r@   s       rD   __neg__zGlyphCoordinates.__neg__n  s>     IIKDDs1vAaD5AaD rK   c                J    | j                         }|j                  |       |S )Nr   )r   r   )r9   r   r  s      rD   	__round__zGlyphCoordinates.__round__  s     IIK	erK   c                 @    | j                         j                  |      S rG   )r   __iadd__r  s     rD   __add__zGlyphCoordinates.__add__      yy{##E**rK   c                 @    | j                         j                  |      S rG   )r   __isub__r  s     rD   __sub__zGlyphCoordinates.__sub__  r  rK   c                 @    | j                         j                  |      S rG   )r   __imul__r  s     rD   __mul__zGlyphCoordinates.__mul__  r  rK   c                 @    | j                         j                  |      S rG   )r   __itruediv__r  s     rD   __truediv__zGlyphCoordinates.__truediv__  s    yy{''..rK   c                     ||  z   S rG   r  r  s     rD   __rsub__zGlyphCoordinates.__rsub__  s    rK   c                 L   t        |t              r#t        |      dk(  sJ | j                  |       | S t        |t              r\|j
                  }| j
                  }t        |      t        |      k(  sJ t        t        |            D ]  }||xx   ||   z  cc<    | S t        S )z
        >>> g = GlyphCoordinates([(1,2)])
        >>> g += (.5,0)
        >>> g
        GlyphCoordinates([(1.5, 2)])
        >>> g2 = GlyphCoordinates([(3,4)])
        >>> g += g2
        >>> g
        GlyphCoordinates([(4.5, 6)])
        r!   r   r   r1   r  r   rc  r0   r  r9   r  rn  r@   s       rD   r  zGlyphCoordinates.__iadd__  s     eU#u:?"?NN5!Ke-.HHEAq6SZ'''3q6]!a  #KrK   c                 `   t        |t              r-t        |      dk(  sJ | j                  |d    |d    f       | S t        |t              r\|j
                  }| j
                  }t        |      t        |      k(  sJ t        t        |            D ]  }||xx   ||   z  cc<    | S t        S )z
        >>> g = GlyphCoordinates([(1,2)])
        >>> g -= (.5,0)
        >>> g
        GlyphCoordinates([(0.5, 2)])
        >>> g2 = GlyphCoordinates([(3,4)])
        >>> g -= g2
        >>> g
        GlyphCoordinates([(-2.5, -2)])
        r!   r   r   r  r  s       rD   r  zGlyphCoordinates.__isub__  s     eU#u:?"?NNU1XIay12Ke-.HHEAq6SZ'''3q6]!a  #KrK   c                 
   t        |t              r#t        |      dk(  sJ | j                  |       | S t        |t              r;|dk(  r| S | j
                  }t        t        |            D ]  }||xx   |z  cc<    | S t        S )z
        >>> g = GlyphCoordinates([(1,2)])
        >>> g *= (2,.5)
        >>> g *= 2
        >>> g
        GlyphCoordinates([(4, 2)])
        >>> g = GlyphCoordinates([(1,2)])
        >>> g *= 2
        >>> g
        GlyphCoordinates([(2, 4)])
        r!   r   )r   r   r1   rL  r   rc  r0   r  r  s       rD   r  zGlyphCoordinates.__imul__  sx     eU#u:?"?JJuKeV$zA3q6]! #KrK   c                     t        |t              r||f}t        |t              r8|dk(  r| S t        |      dk(  sJ | j	                  d|d   z  d|d   z  f       | S t
        S )z
        >>> g = GlyphCoordinates([(1,3)])
        >>> g /= (.5,1.5)
        >>> g /= 2
        >>> g
        GlyphCoordinates([(1, 1)])
        )r   r   r!   g      ?r   r   )r   r   r   r1   rL  r  r  s     rD   r  zGlyphCoordinates.__itruediv__  si     eV$ENEeU#u:?"?JJeAheAh78KrK   c                 ,    t        | j                        S )aH  
        >>> g = GlyphCoordinates([])
        >>> bool(g)
        False
        >>> g = GlyphCoordinates([(0,0), (0.,0)])
        >>> bool(g)
        True
        >>> g = GlyphCoordinates([(0,0), (1,0)])
        >>> bool(g)
        True
        >>> g = GlyphCoordinates([(0,.5), (0,0)])
        >>> bool(g)
        True
        )rS  rc  r   s    rD   __bool__zGlyphCoordinates.__bool__  s     DGG}rK   N),r   r   r   r   r2  propertyri  staticmethodrp  r   r   r   r   r   rv  rZ   r   r   r   r{  r  rq  r  r  rL  r   r  r  r  r  r  r  r  r  r  __radd____rmul__r  r  r  r  r  r  __nonzero__r  rK   rD   r   r     s     !#     !R$/L! % 2 #* :(	

# B" " ") 
+++/ HH002$" KrK   r   __main__)nr   collectionsr   fontTools.miscr   	fontToolsr   r   fontTools.misc.transformr   fontTools.misc.textToolsr   r	   r
   fontTools.misc.arrayToolsr   r   fontTools.misc.bezierToolsr   fontTools.misc.fixedToolsr   rG  r   rS  r   rX  r   r[  fontTools.misc.roundToolsr   r   fontTools.misc.vectorr   numbersr    r   r   rk  r!  ri  loggingmathru   r   fontTools.misc.filenamesr   fontTools.misc.loggingToolsr   enumr   	functoolsr   typesr   typingr   	getLoggerr   r5   r\   splitr  r#   r   r9  r  r  r  r~  r  r  rJ  rK  rr  r  r  r  r  r%  r)  r  rF  rH  r  rJ  r  r  r  r  rI  rK  r  r  r+  objectr4   r  r#  r   rS  r$  r+   r7  rT  r   doctestexittestmodfailedr  rK   rD   <module>r     so   < " "   8 9 9 ? :  7 (    
     	 $ 7 9   ! g!
 ((=7==%bq)
* "# l<\.. l<^ @
  


		 	 ++i7	 qqBqB:A4=
    !      "  !H 
wBF wBx &""'
2Ye Y YE Yd Yh/U h/s3x h/VW
V W
t[v [|
 zCHH_W__%%& rK   