
    jkeW	                     R    d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	  G d de      Z
y)    )otRound	roundFunc)T2CharString)BasePen)specializeCommandscommandsToProgramc                   P     e Zd ZdZd
 fd	Zd Zd Zd Zd Zd Z	d Z
dd	Z xZS )T2CharStringPena  Pen to draw Type 2 CharStrings.

    The 'roundTolerance' argument controls the rounding of point coordinates.
    It is defined as the maximum absolute difference between the original
    float and the rounded integer value.
    The default tolerance of 0.5 means that all floats are rounded to integer;
    a value of 0 disables rounding; values in between will only round floats
    which are close to their integral part within the tolerated range.
    c                     t         t        |   |       t        |      | _        || _        || _        g | _        d| _        y )N)r   r   )	superr
   __init__r   round_CFF2_width	_commands_p0)selfwidthglyphSetroundToleranceCFF2	__class__s        @/usr/lib/python3/dist-packages/fontTools/pens/t2CharStringPen.pyr   zT2CharStringPen.__init__   s:    ot-h7~.

    c                     | j                   }| j                  |d         | j                  |d         fx}| _         |d   |d   z
  |d   |d   z
  gS )Nr      )r   r   )r   ptp0s      r   _pzT2CharStringPen._p   sY    XXBqE*DJJr!u,=>>TX11r!ur!u}--r   c                 \    | j                   j                  d| j                  |      f       y )Nrmovetor   appendr   r   r   s     r   _moveTozT2CharStringPen._moveTo"   !    y$''"+67r   c                 \    | j                   j                  d| j                  |      f       y )Nrlinetor"   r$   s     r   _lineTozT2CharStringPen._lineTo%   r&   r   c                     | j                   }| j                  j                  d ||       ||      z    ||      z   f       y )N	rrcurveto)r   r   r#   )r   pt1pt2pt3r   s        r   _curveToOnezT2CharStringPen._curveToOne(   s8    WW{BsGbg,=3,GHIr   c                      y N r   s    r   
_closePathzT2CharStringPen._closePath,       r   c                      y r1   r2   r3   s    r   _endPathzT2CharStringPen._endPath/   r5   r   c                 R   | j                   }|r| j                  sdnd}t        |d|      }t        |      }| j                  8| j                  rJ d       |j                  dt        | j                               | j                  s|j                  d       t        |||      }|S )	N0   i  F)generalizeFirstmaxstackz7CFF2 does not allow encoding glyph width in CharString.r   endchar)programprivateglobalSubrs)	r   r   r   r   r   insertr   r#   r   )r   r>   r?   optimizecommandsr;   r=   
charStrings           r   getCharStringzT2CharStringPen.getCharString2   s    >>!%rH)%(H $H-;;"JJIHINN1gdkk23zzNN9%!W+

 r   )g      ?F)NNT)__name__
__module____qualname____doc__r   r   r%   r)   r/   r4   r7   rD   __classcell__)r   s   @r   r
   r
   
   s1    .
88Jr   r
   N)fontTools.misc.roundToolsr   r   fontTools.misc.psCharStringsr   fontTools.pens.basePenr   fontTools.cffLib.specializerr   r   r
   r2   r   r   <module>rN      s    9 5 * N:g :r   