o
    b                     @  s   d dl mZ d dlZd dlmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZmZ d dlmZ d d	lmZ d
dlmZmZmZ eG dd dZdS )    )annotationsN)Optional)definefield)Identity	Transform)AbstractPen)AbstractPointPenPointToSegmentPen)BoundingBox)GlyphSet   )_convert_transform	getBoundsgetControlBoundsc                   @  sr   e Zd ZU dZded< 	 eeedZded< 	 dZ	ded	< 	 dddZ
d ddZd ddZd!ddZd"ddZdS )#	Componenta)  Represents a reference to another glyph in the same layer.

    See http://unifiedfontobject.org/versions/ufo3/glyphs/glif/#component.

    Note:
        Components always refer to glyphs in the same layer. Referencing different
        layers is currently not possible in the UFO data model.
    str	baseGlyph)defaultZ	converterr   transformationNzOptional[str]
identifierdeltatuple[float, float]returnNonec           
      C  s:   |\}}| j \}}}}}}	t|||||| |	| | _ dS )a  Moves this component by (x, y) font units.

        NOTE: This interprets the delta to be the visual delta, as in, it
        replaces the x and y offsets of the component's transformation
        directly, rather than going through
        :meth:`fontTools.misc.transform.Transform.translate`. Otherwise,
        composites that use flipped components (imagine a ``quotedblleft``
        composite using two x- and y-inverted ``comma`` components)
        would move in the opposite direction of the delta.
        N)r   r   )
selfr   xyZxxZxyZyxZyyZdxZdy r   ;/usr/lib/python3/dist-packages/ufoLib2/objects/component.pymove%   s    zComponent.movelayerr   BoundingBox | Nonec                 C  
   t | |S )zReturns the (xMin, yMin, xMax, yMax) bounding box of the component,
        taking the actual contours into account.

        Args:
            layer: The layer of the containing glyph to look up components.
        )r   r   r!   r   r   r   r   4      
zComponent.getBoundsc                 C  r#   )zReturns the (xMin, yMin, xMax, yMax) bounding box of the component,
        taking only the control points into account.

        Args:
            layer: The layer of the containing glyph to look up components.
        )r   r$   r   r   r   r   =   r%   zComponent.getControlBoundspenr   c                 C  s   t |}| | dS )zDraws component with given pen.N)r
   
drawPoints)r   r&   pointPenr   r   r   drawJ   s   zComponent.drawr(   r	   c                 C  sN   z|j | j| j| jd W dS  ty&   | | j| j tdt Y dS w )z/Draws points of component with given point pen.)r   zgThe addComponent method needs an identifier kwarg. The component's identifier value has been discarded.N)ZaddComponentr   r   r   	TypeErrorwarningswarnUserWarning)r   r(   r   r   r   r'   O   s   
zComponent.drawPoints)r   r   r   r   )r!   r   r   r"   )r&   r   r   r   )r(   r	   r   r   )__name__
__module____qualname____doc____annotations__r   r   r   r   r   r    r   r   r)   r'   r   r   r   r   r      s   
 	


	
r   )Z
__future__r   r+   typingr   attrr   r   ZfontTools.misc.transformr   r   ZfontTools.pens.basePenr   ZfontTools.pens.pointPenr	   r
   ZufoLib2.objects.miscr   ZufoLib2.typingr   Zmiscr   r   r   r   r   r   r   r   <module>   s    