
    h^.                     "   S SK J r   S SKJrJrJrJrJr  S SKJrJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJrJr  S SKJrJr  S S	KJr  S S
KJrJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKrSS/r  " S S5      r! " S S\!\5      r" " S S\!\\5      r#g)    )array)AnyCallableDictOptionalTuple)MAX_F2DOT14floatToFixedToFloat)LogMixin)AbstractPointPenotRound)
LoggingPenPenError)TransformPenTransformPointPen)	ttProgram)flagOnCurve	flagCubic)Glyph)GlyphComponent)GlyphCoordinates)dropImpliedOnCurvePointsN
TTGlyphPenTTGlyphPointPenc                       \ rS rSr SS\\\\4      S\SS4S jjr	S\S\
\\\\\\4   4S	 jrS
 rSS jr SS\S\
\\\\\\4   S\\   S\SS4
S jjrS r  S\S.S\S\S\\/\4   S\4S jjjrSrg)_TTGlyphBasePen   glyphSethandleOverflowingTransformsreturnNc                 <    Xl         X l        U R                  5         g)a  
Construct a new pen.

Args:
    glyphSet (Dict[str, Any]): A glyphset object, used to resolve components.
    handleOverflowingTransforms (bool): See below.

If ``handleOverflowingTransforms`` is True, the components' transform values
are checked that they don't overflow the limits of a F2Dot14 number:
-2.0 <= v < +2.0. If any transform value exceeds these, the composite
glyph is decomposed.

An exception to this rule is done for values that are very close to +2.0
(both for consistency with the -2.0 case, and for the relative frequency
these occur in real fonts). When almost +2.0 values occur (and all other
values are within the range -2.0 <= x <= +2.0), they are clamped to the
maximum positive value that can still be encoded as an F2Dot14: i.e.
1.99993896484375.

If False, no check is done and all components are translated unmodified
into the glyf table, followed by an inevitable ``struct.error`` once an
attempt is made to compile them.

If both contours and components are present in a glyph, the components
are decomposed.
N)r   r    init)selfr   r    s      K/var/www/html/env/lib/python3.13/site-packages/fontTools/pens/ttGlyphPen.py__init___TTGlyphBasePen.__init__   s    > !+F(		    	glyphNametransformationc                 x    U R                  X5      n[        U R                  U   U R                  5      " U5        g N)transformPengetattrr   
drawMethod)r$   r)   r*   tpens       r%   
_decompose_TTGlyphBasePen._decompose9   s0    
   6i($//:4@r(   c                     [         e)z&
Check if the current path is closed.
)NotImplementedErrorr$   s    r%   	_isClosed_TTGlyphBasePen._isClosedA   s
     "!r(   c                 <    / U l         / U l        / U l        / U l        g r,   )pointsendPtstypes
componentsr5   s    r%   r#   _TTGlyphBasePen.initG   s    
r(   baseGlyphName
identifierkwargsc                 <    U R                   R                  X45        g)z
Add a sub glyph.
N)r<   append)r$   r>   r*   r?   r@   s        r%   addComponent_TTGlyphBasePen.addComponentM   s     	>?r(   c                    U R                   (       a  [        S U R                   5       5      n/ nU R                   GH  u  pEX@R                  ;  a!  U R                  R                  SU S35        M6  U R                  (       d  U R                   (       a  W(       a  U R                  XE5        Mr  [        5       nXFl	        S USS   5       u  Ul
        Ul        [        S US S  5       5      nUS:w  aI  U R                   (       a)  [        S U 5       5      (       a  [        S	 U 5       5      nUS S
 US
S  4Ul        Xl        UR                  U5        GM     U$ )Nc              3   b   #    U  H%  u  pUS S   H  nUS:  =(       d    US:  v   M     M'     g 7f)N       ).0r)   r*   ss       r%   	<genexpr>3_TTGlyphBasePen._buildComponents.<locals>.<genexpr>]   s<      3B/Y'+A AR+  3Bs   -/z skipped non-existing component ''c              3   8   #    U  H  n[        U5      v   M     g 7fr,   r   rK   vs     r%   rM   rN   n   s     'O<Nq

<Ns   rG   c              3   :   #    U  H  n[        US 5      v   M     g7f)   N)r
   rQ   s     r%   rM   rN   q   s      #4Fq#Ar**4Fs   )   r   r   rU   c              3   T   #    U  H  n[         Us=:  =(       a    S :*  Os  v   M      g7frH   Nr	   rK   rL   s     r%   rM   rN   u   s#      <2@QK!((q((.s   &(c              3   Z   #    U  H!  n[         Us=:  a  S ::  a	  O  O[         OUv   M#     g7frW   rX   rY   s     r%   rM   rN   y   s(      +!/A (3Q';!';B!/s   )+rH   )r    anyr<   r   logwarningr9   r1   r   r)   xytuple	transformflagsrB   )r$   componentFlagsoverflowingr<   r)   r*   	components          r%   _buildComponents _TTGlyphBasePen._buildComponentsY   sN   ++  37?? K
 
)-%I-  #CI;a!PQ{{t??K	:&(I"+'ON12<N'O$IK # #4B2A4F# N -33 <2@< 9 9 &+ +!/+ &N (6bq'9>!";M&N	#,Oi(9 *9: r(   roundrc   dropImpliedOnCurvesri   c                H   U R                  5       (       d  [        S5      eU R                  U5      n[        5       n[	        U R
                  5      Ul        U R                  Ul        [        SU R                  5      Ul        U R                  5         U(       a  XEl        SUl        U$ [        UR                  5      Ul        [         R"                  " 5       Ul        UR$                  R'                  S5        U(       a  [)        U5        UR                  R+                  US9  U$ )z
Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph.

Args:
    componentFlags: Flags to use for component glyphs. (default: 0x04)

    dropImpliedOnCurves: Whether to remove implied-oncurve points. (default: False)
zDidn't close last contour.Br(   rh   )r6   r   rf   r   r   r9   coordinatesr:   endPtsOfContoursr   r;   rb   r#   r<   numberOfContourslenr   ProgramprogramfromBytecoder   toInt)r$   rc   rj   ri   r<   glyphs         r%   rv   _TTGlyphBasePen.glyph   s     ~~788**>:
,T[[9!%C,		  *%'E"  &))?)?%@E"%--/EMMM&&s+"(/##%#0r(   )r<   r:   r   r    r9   r;   )Tr!   Nr,   )rG   F)__name__
__module____qualname____firstlineno__r   r   strr   boolr&   r   floatr1   r6   r#   rC   rf   r   intr   r   rv   __static_attributes__rJ   r(   r%   r   r      s    -1!4S>*! &*! 
	!FAA eUE5%FGA" %)	
@
@ eUE5%FG
@ SM	
@
 
@ 

@'V #$)&
 )0&& "&
 %& 
& &r(   r   c            	          ^  \ rS rSrSrSr\r   SS\\	\
\4      S\S\SS4U 4S	 jjjrS
\\\4   S\SS4S jrSS jrS\4S jrS
\\\4   SS4S jrS
\\\4   SS4S jrSS jrSS jrSS jrSS jrSrU =r$ )r      z
Pen used for drawing to a TrueType glyph.

This pen can be used to construct or modify glyphs in a TrueType format
font. After using the pen to draw, use the ``.glyph()`` method to retrieve
a :py:class:`~._g_l_y_f.Glyph` object representing the glyph.
drawNr   r    outputImpliedClosingLiner!   c                 0   > [         TU ]  X5        X0l        g r,   )superr&   r   )r$   r   r    r   	__class__s       r%   r&   TTGlyphPen.__init__   s     	?(@%r(   pttpc                 p    U R                   R                  U5        U R                  R                  U5        g r,   )r9   rB   r;   )r$   r   r   s      r%   	_addPointTTGlyphPen._addPoint   s&    2

"r(   c                 l    U R                   R                  5         U R                  R                  5         g r,   )r9   popr;   r5   s    r%   	_popPointTTGlyphPen._popPoint   s    

r(   c                     U R                   (       + =(       d;    U R                  =(       a(    U R                  S   [        U R                   5      S-
  :H  $ )Nrm   rU   )r9   r:   rq   r5   s    r%   r6   TTGlyphPen._isClosed   s<    KK 
KKCDKKOs4;;/?!/CC	
r(   c                 0    U R                  U[        5        g r,   )r   r   r$   r   s     r%   lineToTTGlyphPen.lineTo   s    r;'r(   c                 p    U R                  5       (       d  [        S5      eU R                  U[        5        g )Nz+"move"-type point must begin a new contour.)r6   r   r   r   r   s     r%   moveToTTGlyphPen.moveTo   s)    ~~HIIr;'r(   c                     [        U5      S-  S:X  d   eUS S  H  nU R                  U[        5        M     US   b  U R                  US   S5        g g )NrH   rU   rm   )rq   r   r   r$   r9   r   s      r%   curveToTTGlyphPen.curveTo   sY    6{Q!###"+BNN2y)  ":!NN6":q) "r(   c                     [        U5      S:  d   eUS S  H  nU R                  US5        M     US   b  U R                  US   S5        g g )NrU   rm   r   )rq   r   r   s      r%   qCurveToTTGlyphPen.qCurveTo   sU    6{a"+BNN2q!  ":!NN6":q) "r(   c                    [        U R                  5      S-
  nUS:X  d&  U R                  (       a&  XR                  S   S-   :X  a  U R                  5         g U R                  (       dZ  SnU R                  (       a  U R                  S   S-   nU R                  U   U R                  U   :X  a  U R                  5         US-  nU R                  R                  U5        g )NrU   r   rm   )rq   r9   r:   r   r   rB   )r$   endPtstartPts      r%   	closePathTTGlyphPen.closePath   s    DKK 1$ A:$++%;;r?Q3F*FNN,,G{{++b/A-{{7#t{{5'99 
5!r(   c                 $    U R                  5         g r,   )r   r5   s    r%   endPathTTGlyphPen.endPath   s    r(   )r   )NTFrx   )ry   rz   r{   r|   __doc__r/   r   r-   r   r   r}   r   r~   r&   r   r   r   r   r   r6   r   r   r   r   r   r   r   __classcell__r   s   @r%   r   r      s     JL .2,0).	A4S>*A &*A #'	A
 
A AE%,/ S T 
4 

(ue|, ( ((ue|, ( (
**"& r(   c                      ^  \ rS rSrSrSr\rSU 4S jjrS\	4S jr
SS\\   S	\SS4S
 jjrSS jr    SS\\\4   S\\   S\	S\\   S\\   S	\SS4S jjrSrU =r$ )r      a  
Point pen used for drawing to a TrueType glyph.

This pen can be used to construct or modify glyphs in a TrueType format
font. After using the pen to draw, use the ``.glyph()`` method to retrieve
a :py:class:`~._g_l_y_f.Glyph` object representing the glyph.

drawPointsr!   Nc                 0   > [         TU ]  5         S U l        g r,   )r   r#   _currentContourStartIndex)r$   r   s    r%   r#   TTGlyphPointPen.init  s    )-&r(   c                     U R                   S L $ r,   r   r5   s    r%   r6   TTGlyphPointPen._isClosed  s    --55r(   r?   r@   c                 x    U R                  5       (       d  [        S5      e[        U R                  5      U l        g)z
Start a new sub path.
zDidn't close previous contour.N)r6   r   rq   r9   r   )r$   r?   r@   s      r%   	beginPathTTGlyphPointPen.beginPath  s.     ~~;<<),T[[)9&r(   c                 6   U R                  5       (       a  [        S5      eU R                  [        U R                  5      :X  a  SU l        gU R
                  (       a  U R
                  S   S-   OSnU R
                  R                  [        U R                  5      S-
  5        SU l        U R                  n[        U[        U5      5       HL  nX#   S:X  d  M  US-
  nXA:  a  [        U5      S-
  nX$   S:X  a  [        X$'   US-  nX$   S:X  a  M  [        X#'   MN     g)z
End the current sub path.
zContour is already closed.Nrm   rU   r   curve)r6   r   r   rq   r9   r:   rB   r;   ranger   r   )r$   contourStartrb   ijs        r%   r   TTGlyphPointPen.endPath  s    
 >>788))S-==-1D*.2kkt{{2*q3t{{+a/0)-& 

|SZ0Ax7"E#E
QAh!m(EHFA h!m ' 1r(   r   segmentTypesmoothnamec                    U R                  5       (       a  [        S5      eUc  U R                  R                  S5        OyUS;   a   U R                  R                  [        5        OSUS:X  a   U R                  R                  [        5        O-US:X  a  U R                  R                  S5        O[        U5      eU R                  R                  U5        g)z&
Add a point to the current sub path.
z&Can't add a point to a closed contour.Nr   )linemoveqcurver   )r6   r   r;   rB   r   AssertionErrorr9   )r$   r   r   r   r   r?   r@   s          r%   addPointTTGlyphPointPen.addPoint6  s     >>CDDJJa ,,JJk*H$JJk*G#JJg& --2r(   r   rx   r,   )NFNN)ry   rz   r{   r|   r   r/   r   r-   r#   r~   r6   r   r}   r   r   r   r   r   r   r   r   r   s   @r%   r   r      s     J$L.64 6:HSM :C :D :'> &*"$(%, c] 	
 sm SM  
 r(   )$r   typingr   r   r   r   r   fontTools.misc.fixedToolsr	   r
   fontTools.misc.loggingToolsr   fontTools.pens.pointPenr   fontTools.misc.roundToolsr   fontTools.pens.basePenr   r   fontTools.pens.transformPenr   r   fontTools.ttLib.tablesr   fontTools.ttLib.tables._g_l_y_fr   r   r   r   r   r   math__all__r   r   r   rJ   r(   r%   <module>r      ss     7 7 F 0 4 - 7 G , B 1 : < D  *
+S SlQ* QhPox1A Pr(   