
    kh                     B    d Z ddlmZ ddlmZ ddlmZ  G d de      Zy)a  Char object based on PDF raw dict extracted with ``PyMuPDF``.

Data structure refer to this `link <https://pymupdf.readthedocs.io/en/latest/textpage.html>`_::

    {
        'bbox'  : (x0, y0, x1, y1), 
        'c'     : str, 
        'origin': (x,y)
    }
   )INVALID_CHARS)Element)Shapec                   F     e Zd ZdZddef fdZd	dedefdZ fdZ	 xZ
S )
Charz Object representing a character.rawc                     |i }|j                  dd      }|t        v rd}|| _        |j                  dd       | _        t        |   |       y )Nc origin)getr   r
   r   super__init__)selfr   r
   	__class__s      N/var/www/teggl/fontify/venv/lib/python3.12/site-packages/pdf2docx/text/Char.pyr   zChar.__init__   sP    ;b GGC2qggh-    rect
horizontalc                    | j                   |j                   v ry| j                   |j                   z  }|j                  ry|r&|j                  d| j                   j                  z  kD  S |j                  d| j                   j                  z  kD  S )a  Detect whether it locates in a rect.

        Args:
            rect (Shape): Target rect to check.
            horizontal (bool, optional): Text direction is horizontal if True. Defaults to True.

        Returns:
            bool: Whether a Char locates in target rect.

        .. note::
            It's considered as contained in the target rect if the intersection is larger than 
            half of the char bbox.
        TFg      ?)bboxis_emptywidthheight)r   r   r   ss       r   contained_in_rectzChar.contained_in_rect"   so     99		!$ II		!::eaggDIIOO(;;;xx#dii.....r   c                 t    t         |          }|j                  | j                  | j                  d       |S )N)r
   r   )r   storeupdater
   r   )r   resr   s     r   r   z
Char.store:   s4    gmo

kk
 	
 
r   )N)T)__name__
__module____qualname____doc__dictr   r   boolr   r   __classcell__)r   s   @r   r   r      s/    *	4 	/U /t /0 r   r   N)r$   common.constantsr   common.Elementr   shape.Shaper   r    r   r   <module>r,      s!   	 - $ -7 -r   